Quantcast
Channel: HYSPLIT Forum: hysplitbbs.arl.noaa.gov
Viewing all articles
Browse latest Browse all 188

MeteoInfo Software • Trajectory animation

$
0
0
The sample script for trajectory animation using MeteoInfoLab.

CODE:

import timefn = os.path.join(migl.get_sample_folder(), 'HYSPLIT', 'tdump')f = addfile_hytraj(fn)lon = f['lon'][:]lat = f['lat'][:]height = f['height'][:]#Plotax = axesm()geoshow('country', edgecolor='gray', facecolor=(230,230,230))levs = arange(0, 600, 50)scatter(lon[:,0], lat[:,0], size=6, color='r', marker='S')yticks(arange(35, 54, 5))title('Trajectory')ntraj, npoint = lon.shapefor i in range(2, npoint+1):    if i > 2:        cll()        cll()    tlayer = plot(lon[:,-i:], lat[:,-i:], zvalues=height[:,-i:], levels=levs, linewidth=2)    scatter(lon[:,-i], lat[:,-i], marker='s', size=5, edgecolor='m', facecolor=None)    if i == 2:        colorbar(tlayer)    xlim(-92, -55)    ylim(34, 54)    plt.draw()        time.sleep(0.1)
Ouput gif animation figure:

CODE:

fn = os.path.join(migl.get_sample_folder(), 'HYSPLIT', 'tdump')f = addfile_hytraj(fn)lon = f['lon'][:]lat = f['lat'][:]height = f['height'][:]#Plotax = axesm()geoshow('country', edgecolor='gray', facecolor=(230,230,230))levs = arange(0, 600, 50)scatter(lon[:,0], lat[:,0], size=6, color='r', marker='S')yticks(arange(35, 54, 5))title('Trajectory')giffn = 'D:/Temp/test/traj_animation.gif'animation = gifanimation(giffn, delay=100)ntraj, npoint = lon.shapefor i in range(2, npoint+1):    print(i)    if i > 2:        cll()        cll()    tlayer = plot(lon[:,-i:], lat[:,-i:], zvalues=height[:,-i:], levels=levs, linewidth=2)    scatter(lon[:,-i], lat[:,-i], marker='s', size=5, edgecolor='m', facecolor=None)    if i == 2:        colorbar(tlayer)    xlim(-92, -55)    ylim(34, 54)    plt.draw()    gifaddframe(animation)animation.finish()
traj_animation.gif

Statistics: Posted by yaqiang — November 3rd, 2023, 4:42 am



Viewing all articles
Browse latest Browse all 188

Trending Articles