- 积分
- 16982
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2019-8-24
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 Tao_Xu 于 2019-9-1 21:17 编辑
- from netCDF4 import Dataset
- import numpy as np
- import matplotlib.pyplot as plt
- from mpl_toolkits.basemap import Basemap
- import matplotlib.cm as cm
- meteo_file = "/Users/ACER-PC/PycharmProjects/ERA-interim_Vertical integral of divergence of moisture flux/Data/ERA-interim_Vertical integral of divergence of moisture flux201812.nc"
- fh = Dataset(meteo_file, mode='r')
- # 获取每个变量的值
- lons = fh.variables['longitude'][:]
- lats = fh.variables['latitude'][:]
- tlml = fh.variables['p84.162'][:]
- elml = fh.variables['p71.162'][:]
- nlml = fh.variables['p72.162'][:]
- m = Basemap(llcrnrlon=50., llcrnrlat=-10.,
- urcrnrlon=160., urcrnrlat=60,
- projection='cyl', resolution='l')
- lon, lat = np.meshgrid(lons, lats)
- xi, yi = m(lon, lat)
- # 数据只绘制第1个时间的(tlml_0)
- tlml_0 = tlml[0:1:, ::, ::]
- cs = m.contourf(xi, yi, np.squeeze(tlml_0), range (-21,1), cmap=cm.bone)
- elml_0 = elml[0:1:, ::, ::]
- nlml_0 = nlml[0:1:, ::, ::]
- wind= m.quiver(lon, lat, np.squeeze(elml_0), np.squeeze(nlml_0), color='red', width=0.0005, headwidth=60, headlength=100)
- # Add Grid Lines
- # 绘制经纬线
- m.drawparallels(np.arange(-90., 91., 20.),labels=[True,False,True,True],color='dimgrey',dashes=[1, 3])
- m.drawmeridians(np.arange(-180., 181., 30.),labels=[True,True,False,True],color='dimgrey',dashes=[1, 3])
- # Add Coastlines
- m.drawcoastlines(color='grey', linewidth=0.3)
- # Add Colorbar
- cbar = m.colorbar(cs, location='bottom', pad="10%")
- cbar.set_label('Divergence of moisture flux (kg m**-2 s**-1)')
- # Add Title
- plt.title('Vertical integral of divergence of moisture flux', fontsize= 12)
- plt.savefig("Vertical integral of divergence of moisture flux.png", dpi=500, bbox_inches='tight')
- plt.show()
复制代码
|
|