- 积分
- 87
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2020-6-22
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 wxylndd 于 2020-7-11 11:47 编辑
- import netCDF4
- from netCDF4 import Dataset
- import numpy as np
- import matplotlib.pyplot as plt
- from mpl_toolkits.basemap import Basemap
- nc_obj=Dataset('D://Anaconda//pressure-Part2//pressure//air.2009.nc')
- data = Dataset('D://Anaconda//pressure-Part2//pressure//hgt.2009.nc')
- lon=nc_obj.variables['lon'][32:160]
- lat=nc_obj.variables['lat'][12:80]
- time =nc_obj.variables['time'][429:432]
- level=nc_obj.variables['level'][:]
- level = np.array(level)
- level_need = 5
- temperature = nc_obj.variables['air'][429,level_need,12:80,32:160]
- hgt = data.variables['hgt'][429,level_need,12:80,32:160]
- hgt=hgt/10
- plt.figure(figsize=(16,8))
- m=Basemap(projection='cyl',llcrnrlat=15,urcrnrlat=55,llcrnrlon=70,urcrnrlon=140,resolution='l')
- lons,lats=m.makegrid(53,29)
- lats=lats[::-1]
- x,y=m(lons,lats)
- m.drawparallels(np.arange(15.,56.,10.),labels=[1,0,0,0],fontsize=15)
- m.drawmeridians(np.arange(75.,141.,15.),labels=[0,0,0,1],fontsize=15)
- m.drawcoastlines(linewidth=1.0, linestyle='solid', color='k',antialiased=1, ax=None, zorder=None)
- c_hgt = m.contour(lons,lats,hgt,colors='b',linewidths=1)
- plt.clabel(c_hgt,fmt='%1.0f',inline=100,colors = 'k',fontsize=15)
- m.drawlsmask()
- plt.title('20090418 00h 500hpa',size=20)
- plt.savefig('air1.png')
- plt.show()
复制代码 这是我的代码,现在提示:Traceback (most recent call last):
File "D:\air.py", line 25, in <module>
c_hgt = m.contour(lons,lats,hgt,colors='b',linewidths=1)
File "D:\Anaconda\lib\site-packages\mpl_toolkits\basemap\__init__.py", line 543, in with_transform
return plotfunc(self,x,y,data,*args,**kwargs)
File "D:\Anaconda\lib\site-packages\mpl_toolkits\basemap\__init__.py", line 3569, in contour
mask = np.logical_or(ma.getmaskarray(data),xymask)
ValueError: operands could not be broadcast together with shapes (61,112) (29,53)
是前面的参数设定有问题吗?我刚学python不久,不太会设定参数。
资料范围是东经32~160,北纬12~80,格距2.5*2.5,研究的范围是2009年4月18-20日
文件好像有大小限制,暂时传不上来
|
|