- 积分
- 3363
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2013-4-19
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 ︶ㄣ安定■丶 于 2017-11-24 13:10 编辑
结果2D图绘制如下(叠加了地形):
具体脚本如下:
- figure(figsize=[1500,400],newfig=False)
- fig,((ax1,ax2)) = subplots(1,2,position=[0,0.08,1,0.89])
- f = addfile(r'H:\test\data\test.nc')
- fn1 = addfile(r'H:\alldata\dixing/elev.0.5-deg.nc')
- lev1 = f['level'][:]
- lev2 = meteo.pressure_to_height_std(lev1)
- lev2 = lev2[::-1]/1000
- lon1 = 80
- lon2 = 120
- lat1 = 32
- lat2 = 40
- lon = lon1
- lat_c = []
- tdata = []
- tdata_terrain = []
- while lon<=lon2:
- lat = lat1+(lat2-lat1)*(lon-lon1)/(lon2-lon1)
- lat_c.append(lat)
- print lat
- tdata.append(f['w'][0,:,'%f'%lat,'%f'%lon])
- tdata_terrain.append(fn1['data']['%f'%lat,'%f'%lon])
- lon = lon+1
-
- tdata_terrain=array(tdata_terrain)
- tdata_terrain=tdata_terrain/1000.0
- alldata=concatenate(tdata,axis=0)
- alldata=reshape(alldata,(len(tdata),len(lev1)))
- alldata=alldata.T
- alldata = alldata[::-1,:]
- axes(newaxes=False)
- x=arange(lon1,lon2+1,1)
- levs = arange(-0.2,0.22,0.02)
- yaxis(tickin=False,tickfontsize=17)
- xaxis(tickin=False,tickfontsize=17)
- yaxis(location='right',tickin=True,tickfontsize=18)
- layer = contourf(x,lev2,alldata,levs,cmap='BlRe')
- fill_between(x,tdata_terrain,color='gray')
- plot(x,tdata_terrain,color='k')
- ylabel('Hight(km)',fontsize=18,bold=False)
- xlabel('Longitude',fontsize=18)
- ylim(lev2.min(),12.001)
- colorbar(layer,aspect=25)
- caxes(ax2)
- axesm(newaxes=False,tickfontsize=17)
- lat = [32, 40]
- lon = [100, 120]
- geoshow(lat, lon, size=2, color='b')
- lchina = shaperead('D:/Temp/map/bou2_4p.shp')
- geoshow(lchina,edgecolor='k',size=1)
- xlim(70,140)
- ylim(15,55)
- antialias(True)
看到有3D显示斜剖面的需求,感谢王老师及时进行了更新,现在可以将斜剖面显示在3D地图上了。
结果3D图绘制如下(叠加了地形):
3D显示斜剖面具体脚本如下:
- f = addfile(r'H:\test\data\test.nc')
- fn1 = addfile(r'H:\alldata\dixing/elev.0.5-deg.nc')
- lev1 = f['level'][:]
- lev2 = meteo.pressure_to_height_std(lev1)
- lev2 = lev2[::-1]/1000
- lon1 = 80
- lon2 = 120
- lat1 = 32
- lat2 = 40
- lon = lon1
- x = []
- y = []
- tdata = []
- tdata_terrain = []
- while lon<=lon2:
- lat = lat1+(lat2-lat1)*(lon-lon1)/(lon2-lon1)
- print lon
- tdata.append(f['w'][0,:,'%f'%lat,'%f'%lon])
- tdata_terrain.append(fn1['data']['%f'%lat,'%f'%lon])
- x.append(lon)
- y.append(lat)
- lon = lon+1
-
- tdata_terrain=array(tdata_terrain)
- tdata_terrain[tdata_terrain<0] = 0
- tdata_terrain=tdata_terrain/1000.0
- alldata=concatenate(tdata,axis=0)
- alldata=reshape(alldata,(len(tdata),len(lev1)))
- alldata=alldata.T
- alldata = alldata[::-1,:]
- x=array(x)
- y=array(y)
- ax = axes3d(position=[0.11, 0.11, 0.775, 0.815],tickfontsize=17,bbox=False)
- levs = arange(-0.2,0.22,0.02)
- china = shaperead('D:/Temp/map/china.shp')
- world = shaperead('D:/Temp/map/country1.shp')
- ax.plot_layer(china,edgecolor='gray')
- ax.plot_layer(world,edgecolor='gray')
- layer=ax.contourf(x,lev2,alldata,levs,zdir='xy',alpha=0.8,sepoint=[lon1,lat1,lon2,lat2],cmap='BlRe')
- k =(lat2-lat1)/float((lon2-lon1))
- y1=k*(x-lon1)+lat1
- ax.plot(x,y1,tdata_terrain,'-k',linewidth=1)
- ax.fill_between(x,tdata_terrain, zdir='xy',color='gray',y=y1)
- xlim(70,140)
- ylim(15,55)
- zlim(0,12)
- colorbar(layer,aspect=30)
- ylabel('Latitude (degrees)',fontsize=17)
- xlabel('Longitude (degrees)',fontsize=17)
- zlabel(label='Altitude (km)',fontsize=17)
- antialias(True)
|
评分
-
查看全部评分
|