我有这个基本的python代码来绘制我的全局数据,但是当我绘制它时,经度(x值)似乎被移位 - 向东移动..请在下面检查代码和结果
我的代码是:
file = 'frac_0.50.nc'
fileobj_giems = netCDF4.Dataset(file)
cmap = mpl.colors.ListedColormap([[0.0,0.9,1.0],[0.0,0.9,0.0],[1.0,0.9,0.0],[1.0,0.5,0.0],[1.0,0,0]])
frac = fileobj_giems.variables['fwetl'][8,:,:]
pr = frac[:]*100000
lon=fileobj_giems.variables['longitude'][:]
lat=fileobj_giems.variables['latitude'][:]
[lonall, latall] = meshgrid(lon, lat)
fig = plt.figure()
m = Basemap(llcrnrlat=-90, urcrnrlat=90, llcrnrlon=-180, urcrnrlon=180)
m.drawcoastlines()
m.drawcountries()
m.drawparallels(arange(-90.,90.,10.), labels = [1,0,0,0], fontsize = 10)
m.drawmeridians(arange(-180., 180., 10.), labels = [0,0,0,1], fontsize = 10)
levels=arange(2, 11.6, 0.8)
mymapf = plt.contourf(lonall, latall, pr, levels, cmap=cmap)
m.imshow(ma.masked_less_equal((pr),-999999999.),cmap=cmap)
pyplot.show()
呈现的结果如下:
As you see the 'y' seems to be fine but the 'x - lon' data is moved towards the east
其他信息,fileobj_giems.variables [' fwetl']的形状是(180,360,720) - (time,lat,lon)
答案 0 :(得分:0)
看起来像是一个符号错误,因为这些点看起来要移位180度;你应该检查输入数据的符号是否正确(北美的点数应该是经度的负值。)