2015-04-01 114 views
1

我想从NSIDC制作一些极地网格海冰浓度图。该数据在极方位立体投影和网路,例如文件传输(二进制,北极25公里分辨率)可从以下网址下载: http://nsidc.org/data/NSIDC-0081使用Cartlot绘制极地网格海冰浓度

当我使用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()) 

有什么问题吗?如何显示我的冰浓度数据?

我的收藏版的版本是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

回答

1

当我下载我发现数据电网规格:

  • 左上角X坐标:-3850000.0
  • 左上角Y坐标上:5850000.0
  • 右下角X坐标:3750000.0
  • 右下角Y坐标上:-5350000.0

随着该您可以创建网格并使用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

+0

PS:检查自述文件,我又可以看到NorthPolar是不正确的投影!这里是proj4字符串: Proj.4 Projection:+ proj = stere + lat_0 = 90 + lat_ts = 70 + lon_0 = -45 + k = 1 + x_0 = 0 + y_0 = 0 + a = 6378273 + b = 6 356889.449 + units = m + no_defs – ocefpaf 2015-04-06 14:00:36