I have been using .netCDF files (satellite data) for a few weeks now, and in general, I never had issues plotting them. I've been experimenting with sea ice concentration data but I can't get them right. As far as I can tell, the problem has to do something with the longitude/latitude being in meters. Nothing works right. Data seem to be rotated or falsely projected. The EPSG is 3411. I usually plot with cartopy but I decided to use Basemap also. None of them got the job done with my code. File can be found here.
import os
import xarray as xr
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import numpy as np
from pyproj import Transformer
data = xr.open_dataset('df.nc')
sea_ice = data.F17_ICECON; sea_ice
lons = data.x
lats = data.y
lon, lat = np.meshgrid(lons, lats)
# Also experimented with this but without any results
transformer = Transformer.from_crs("EPSG:3411", "EPSG:4326")
lon_T, lat_T = transformer.transform(lon, lat)
# With Basemap
m = Basemap(width=6000000,height=6000000,
resolution='l',projection='stere',lat_0=90,lon_0=0, epsg=3411)
m.pcolormesh(lon, lat, sea_ice[2])
m.drawcoastlines()
m.fillcontinents(color='grey')
# With Cartopy
day = 4
ax = plt.axes(projection=ccrs.PlateCarree())
plt.contourf(lons, lats, sea_ice[day],
transform=ccrs.PlateCarree())
ax.coastlines()
plt.show()
This is the image produced with Basemap and this is with Cartopy. Actual data should look like this.
