I am trying to make some plots of Polar Gridded Sea Ice Concentrations from NSIDC. The data is delivered in the Polar Stereographic Projection and Grid, an example file (binary,Arctic,25 km resolution) can be downloaded at: http://nsidc.org/data/NSIDC-0081
我正试图从NSIDC中绘制一些极地网格状海冰的浓度图。该数据是在极地立体投影和网格中传输的,一个示例文件(二进制,北极,25公里分辨率)可以在:http://nsidc.org/data/NSIDC-0081上下载。
When I read the data using numpy, and then plot it just using matplotlib's imshow function, it works.
当我使用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)
When I try to plot it using Cartopy, it runs without any errors but only returns an empty coastline.
当我尝试用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())
Anything wrong? How do I show my ice concentration data?
错什么了?如何显示我的冰浓度数据?
My Cartopy's version is 0.12.0rc1.
我的Cartopy的版本是0。12.0rc1。
Below is the Arctic Polar Stereographic Grid from 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 is the IPython Notebook: http://nbviewer.ipython.org/github/xue1527/MyWork/blob/master/Plot%20Arctic%20Sea%20Ice%20Concentration.ipynb
这里是IPython笔记本:http://nbviewer.ipython.org/github/xue1527/ mywork/blob/master/plot%20%20ice%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20
1 个解决方案
#1
1
When I downloaded the data I found the grid specifications:
当我下载数据时,我发现网格规范:
- Upper Left Corner X Coordinate: -3850000.0
- 左上角X坐标:-3850000.0。
- Upper Left Corner Y Coordinate: 5850000.0
- 左上角Y坐标:5850000.0。
- Lower Right Corner X Coordinate: 3750000.0
- 右下角X坐标:3750000.0。
- Lower Right Corner Y Coordinate: -5350000.0
- 右下角Y坐标:-5350000.0。
With that you can create a grid and use pcolormesh instead of imshow.
这样你就可以创建一个网格并使用pcolormesh而不是imshow。
import numpy as np
dx = dy = 25000
x = np.arange(-3850000, +3750000, +dx)
y = np.arange(+5850000, -5350000, -dy)
Here is the full notebook: http://nbviewer.ipython.org/gist/ocefpaf/47ef0c38a5a429704170
这里是完整的笔记本:http://nbviewer.ipyth.org/gist/ocefpaf/47ef0c38a5a429704170。
#1
1
When I downloaded the data I found the grid specifications:
当我下载数据时,我发现网格规范:
- Upper Left Corner X Coordinate: -3850000.0
- 左上角X坐标:-3850000.0。
- Upper Left Corner Y Coordinate: 5850000.0
- 左上角Y坐标:5850000.0。
- Lower Right Corner X Coordinate: 3750000.0
- 右下角X坐标:3750000.0。
- Lower Right Corner Y Coordinate: -5350000.0
- 右下角Y坐标:-5350000.0。
With that you can create a grid and use pcolormesh instead of imshow.
这样你就可以创建一个网格并使用pcolormesh而不是imshow。
import numpy as np
dx = dy = 25000
x = np.arange(-3850000, +3750000, +dx)
y = np.arange(+5850000, -5350000, -dy)
Here is the full notebook: http://nbviewer.ipython.org/gist/ocefpaf/47ef0c38a5a429704170
这里是完整的笔记本:http://nbviewer.ipyth.org/gist/ocefpaf/47ef0c38a5a429704170。