Page 1 of 1

Plot trajectories on 3D earth

Posted: January 6th, 2022, 2:31 am
by yaqiang
3D earth axes is supported from MeteoInfo 3.2.7. This is an example to plot trajectories on 3D earth surface.

Code: Select all

fn = os.path.join(migl.get_sample_folder(), 'HYSPLIT', 'tdump')
f = addfile_hytraj(fn)
lon = f['lon'][:]
lat = f['lat'][:]
alt = f['height'][:] * 1    #scale the height from earth surface
pr = f['PRESSURE'][:]

#Plot
ax = axes3d(earth=True)
ax.lonlat(color='gray')
geoshow('us_states', edgecolor='lightgray')
levs = arange(860, 1030, 10)
traj = plot3(lon, lat, alt, mvalues=pr, levels=levs)
scatter3(lon[:,0], lat[:,0], alt[:,0], s=8, c='c')
colorbar(traj, tickcolor='w', aspect=30, label='Pressure (hPa)', xshift=80)

ax.set_rotation(342)
ax.set_elevation(-51)
ax.set_head(0)
ax.set_pitch(-90)

v = 630
axis([-v,v,-v,v,-v,v])
earth_traj-1.png