制图:底图上的位移经度数据
Mapping: Displaced longitude data on basemap
我有这个基本的 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)
看起来像是符号错误,因为这些点看起来错了 180 度;您应该检查输入数据的符号是否正确(北美的点经度应为负值。)
我有这个基本的 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)
看起来像是符号错误,因为这些点看起来错了 180 度;您应该检查输入数据的符号是否正确(北美的点经度应为负值。)