映射:基础地图上被替换的经度数据

2024-09-30 00:39:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个基本的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)-(时间,纬度,经度)


Tags: the代码绘制prvariablesfilecmaplon
1条回答
网友
1楼 · 发布于 2024-09-30 00:39:47

这看起来像是一个符号错误,因为这些点看起来要偏移180度;您应该检查输入数据的符号是否正确(北美的点应该具有负的经度值)

相关问题 更多 >

    热门问题