- 积分
- 3363
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2013-4-19
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 ︶ㄣ安定■丶 于 2019-7-16 15:38 编辑
分享一个使用MiLab绘制3维水平、经向剖面图的脚本
(1) 3维水平剖面图
脚本如下:
- # add data
- f = addfile(r'D:\test\MERRA2_100.instM_3d_asm_Np.198001.SUB.nc')
- RH = f['RH'][0,:,:,:]*100.0
- lev1 = f['lev'][:]
- lev2 = meteo.pressure_to_height_std(lev1)
- lev2 = lev2/1000.0
- RH.setdimvalue(0, lev2)
- tdata_0km = RH['0',:,:]
- tdata_2km = RH['2',:,:]
- tdata_4km = RH['4',:,:]
- tdata_6km = RH['6',:,:]
- #plot
- levs = arange(0,100,1)
- cols=makecolors(len(levs)+1,cmap='NCV_jet')
- ax = axes3d(position=[0.11, 0.11, 0.775, 0.88],tickfontsize=24,bbox=True)
- china = shaperead('D:/Temp/map/china.shp')
- world = shaperead('D:/Temp/map/country1.shp')
- layer=ax.contourf(tdata_0km,levs,colors=cols,offset=0,alpha=1,zdir='z',smooth=True)
- ax.plot_layer(china,edgecolor='gray',offset=0)
- layer=ax.contourf(tdata_2km,levs,colors=cols,offset=2,alpha=1,zdir='z',smooth=True)
- ax.plot_layer(china,edgecolor='gray',offset=2)
- layer=ax.contourf(tdata_4km,levs,colors=cols,offset=4,alpha=1,zdir='z',smooth=True)
- ax.plot_layer(china,edgecolor='gray',offset=4)
- layer=ax.contourf(tdata_6km,levs,colors=cols,offset=6,alpha=1,zdir='z',smooth=True)
- ax.plot_layer(china,edgecolor='gray',offset=6)
- xlim(70,140)
- ylim(15,55)
- zlim(0,6)
- ylabel('Latitude (degrees)',fontsize=24)
- xlabel('Longitude (degrees)',fontsize=24)
- zlabel('Altitude (km)',fontsize=24)
- colorbar(layer,labelloc='right',ticks=arange(0,101,20),orientation='horizontal',yshift=25,label='RH (%)',fontsize=25,shrink=0.8,aspect=45)
- antialias(True)
(2) 3维经向剖面图
脚本如下:
- # add data
- f = addfile(r'D:\test\MERRA2_100.instM_3d_asm_Np.198001.SUB.nc')
- RH = f['RH'][0,:,:,:]*100.0
- lev1 = f['lev'][:]
- lev2 = meteo.pressure_to_height_std(lev1)
- lev2 = lev2/1000.0
- RH.setdimvalue(0, lev2)
- #plot
- levs = arange(0,100,1)
- cols=makecolors(len(levs)+1,cmap='NCV_jet')
- ax = axes3d(position=[0.11, 0.11, 0.775, 0.88],tickfontsize=24,bbox=True)
- china = shaperead('D:/Temp/map/china.shp')
- world = shaperead('D:/Temp/map/country1.shp')
- ax.plot_layer(world,edgecolor='gray')
- ax.plot_layer(china,edgecolor='k')
- layer = ax.contourf(RH[:,:,'70'],levs,colors=cols,offset=70,alpha=0.8,zdir='x',smooth=True)
- layer = ax.contourf(RH[:,:,'90'],levs,colors=cols,offset=90,alpha=0.8,zdir='x',smooth=True)
- layer = ax.contourf(RH[:,:,'110'],levs,colors=cols,offset=110,alpha=0.8,zdir='x',smooth=True)
- layer = ax.contourf(RH[:,:,'130'],levs,colors=cols,offset=130,alpha=0.8,zdir='x',smooth=True)
- xlim(70,140)
- ylim(15,55)
- zlim(0,15)
- ylabel('Latitude (degrees)',fontsize=24)
- xlabel('Longitude (degrees)',fontsize=24)
- zlabel('Altitude (km)',fontsize=24)
- colorbar(layer,labelloc='right',ticks=arange(0,101,20),orientation='horizontal',yshift=25,label='RH (%)',fontsize=25,shrink=0.8,aspect=45)
- antialias(True)
总结: 纬向剖面和径向类似,这里就不再展示,大家可以根据示例文件尝试,欢迎跟帖。
附件为示例文件:Merra-2 的RH数据
|
|