- 积分
- 87
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2020-6-22
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2020-7-24 18:58:27
|
显示全部楼层
- import netCDF4 as nc
- 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')
- print(nc_obj.variables.keys())#打印变量信息
- lon=nc_obj.variables['lon']
- lon=np.array(lon)
- lat=nc_obj.variables['lat']
- lat=np.array(lat)
- temperature=nc_obj.variables['air']
- temperature=np.array(temperature)
- level=nc_obj.variables['level']
- level = np.array(level)
- level_need = 5
- temperature_need = temperature[429,level_need,5:34,13:66]
- plt.figure(figsize=(16,8))
- map=Basemap(projection='cyl',llcrnrlat=10,urcrnrlat=90,llcrnrlon=25,urcrnrlon=165,resolution='l')
- map.drawcoastlines()
- map.drawcountries(linewidth=1.5)
- map.drawparallels(np.arange(10.,90.,5.),labels=[1,0,0,0],fontsize=15)
- map.drawmeridians(np.arange(25.,165.,15.),labels=[0,0,0,1],fontsize=15)
- map.drawlsmask()
- Lon,Lat=np.meshgrid(lon[13:66],lat[5:34])
- x,y=map(Lon,Lat)
- c=plt.contour(x,y,temperature_need,colors='red')
- plt.title('20090418 00h 500hpa',size=20)
- plt.savefig('air1.png')
- plt.show()
复制代码 |
|