[英]Plot Polar Gridded Sea Ice Concentrations using Cartopy
我正在尝试从NSIDC绘制一些极地网格海冰浓度图。 数据在极地立体投影和网格中传输,示例文件(二进制,北极,25 km分辨率)可从以下网站下载: http : //nsidc.org/data/NSIDC-0081
当我使用numpy读取数据,然后仅使用matplotlib的imshow函数对其进行绘制时,它就可以工作。
import numpy as np
import matplotlib.pyplot as 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 to the fractional parameter range of 0.0 to 1.0
ice = ice/250.
#mask all land and missing values
ice=np.ma.masked_greater(ice,1.0)
fr.close()
#Show ice concentration
plt.imshow(ice)
当我尝试使用Cartopy对其进行绘制时,它运行时没有任何错误,但仅返回了一条空的海岸线。
import matplotlib.pyplot as plt
import cartopy.crs as 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 from Polar Stereographic Projection and 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())
哪里不对了? 如何显示冰浓度数据?
我的Cartopy版本是0.12.0rc1。
以下是文档中的北极极地立体栅格:
北半球网格坐标
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
这是IPython笔记本: http : //nbviewer.ipython.org/github/xue1527/MyWork/blob/master/Plot%20Arctic%20Sea%20Ice%20Concentration.ipynb
下载数据时,我发现了网格规格:
这样,您可以创建一个网格并使用pcolormesh代替imshow。
import numpy as np
dx = dy = 25000
x = np.arange(-3850000, +3750000, +dx)
y = np.arange(+5850000, -5350000, -dy)
这是完整的笔记本: http : //nbviewer.ipython.org/gist/ocefpaf/47ef0c38a5a429704170
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.