python - Plot Polar Gridded Sea Ice Concentrations using Cartopy -
i trying make plots of polar gridded sea ice concentrations nsidc. data delivered in polar stereographic projection , grid, example file (binary,arctic,25 km resolution) can downloaded at: http://nsidc.org/data/nsidc-0081
when read data using numpy, , plot using matplotlib's imshow function, works.
import numpy np import matplotlib.pyplot plt infile='c:\\nt_20150326_f17_nrt_n.bin' fr=open(infile,'rb') hdr=fr.read(300) ice=np.fromfile(fr,dtype=np.uint8) ice=ice.reshape(448,304) #convert fractional parameter range of 0.0 1.0 ice = ice/250. #mask land , missing values ice=np.ma.masked_greater(ice,1.0) fr.close() #show ice concentration plt.imshow(ice)
when try plot using cartopy, runs without errors returns empty coastline.
import matplotlib.pyplot plt import cartopy.crs ccrs fig=plt.figure(figsize=(3, 3)) ax = plt.axes(projection=ccrs.northpolarstereo()) ax.coastlines(resolution='110m',linewidth=0.5) ax.set_extent([-180,180,50,90],crs=ccrs.platecarree()) ax.gridlines() #set ice extent polar stereographic projection , grid document extent=[-9.97,168.35,30.98,34.35] ax.imshow(ice,cmap=plt.cm.blues, vmin=1,vmax=100, extent=extent,transform=ccrs.platecarree())
anything wrong? how show ice concentration data?
my cartopy's version 0.12.0rc1.
below arctic polar stereographic grid document:
northern hemisphere grid coordinates
x (km) y (km) latitude (deg) longitude (deg) -3850 5850 30.98 168.35 corner 3750 5850 31.37 102.34 corner 3750 -5350 34.35 350.03 corner -3850 -5350 33.92 279.26 corner
here ipython notebook: http://nbviewer.ipython.org/github/xue1527/mywork/blob/master/plot%20arctic%20sea%20ice%20concentration.ipynb
when downloaded data found grid specifications:
- upper left corner x coordinate: -3850000.0
- upper left corner y coordinate: 5850000.0
- lower right corner x coordinate: 3750000.0
- lower right corner y coordinate: -5350000.0
with can create grid , use pcolormesh instead of imshow.
import numpy np dx = dy = 25000 x = np.arange(-3850000, +3750000, +dx) y = np.arange(+5850000, -5350000, -dy)
here full notebook: http://nbviewer.ipython.org/gist/ocefpaf/47ef0c38a5a429704170
Comments
Post a Comment