Read the Hysplit output trajectory data file and the corresponding time meteorological data file, generate the trajectory layer, loop each track node, read out the node's longitude, latitude, air pressure, time, through the meteorological data interpolation to obtain the meteorological data of the node.
Script Program:
#-----------------------------------------------------#Author:yaqiang Wang#date:2015-9-30#purpose:get meteorological data along trajectory#Note:sample#-----------------------------------------------------#Set working DirectoryTrajdir ='D:/temp/hysplit'Meteodir='D:/temp/arl'#Open trjactory Data FilePrint 'Open Trajectory data file ...'TRAJFN= Os.path.join (Trajdir,'traj_20090731')Print 'Trajectory file:'+TRAJFNTRAJF=Addfile_hytraj (TRAJFN)#Create Trajectory LayerTrajlayer =Trajf.trajlayer ()#Open Meteorological Data filePrint 'Open Meteorological data file ...'meteofn= Os.path.join (Meteodir,'gdas1.jul09.w5')Print 'Meteorological File:'+meteofnmeteof=AddFile (METEOFN)#Get meteorological data along trajectoryPrint 'Get meteorological data along trajectory ...'OUTFN= Os.path.join (Trajdir,'Pblh_traj.txt') Outf= Open (OUTFN,'W') Outf.write ('lon,lat,time,heigh,pblh,uwnd\n') Pblvar='PBLH'Uvar='Uwnd'idx=0 forTlineinchtrajlayer.shapes (): t= Trajlayer.cellvalue ('StartDate', idx) H= Trajlayer.cellvalue ('Starthour', IDX) t.replace (hour=h) forPsinchtline.getpoints (): Lon=PS. X lat=PS. Y Z=PS. M pres=PS. Z PBL=meteof.tostation (Pblvar, Lon, LAT, None, t) Uwnd=meteof.tostation (Uvar, Lon, LAT, pres, t)Print 'lon:%.2f; Lat:%.2f; time:%s; height:%.2f; PBLH:%.2f; Uwnd:%.2f'% (lon, LAT, t.strftime ('%y%m%d_%h:%m'), Z, PBL, Uwnd) line='%.4f,%.4f,%s,%.2f,%.2f,%.2f'% (Lon,lat,t.strftime ('%y%m%d_%h:%m'), Z,pbl,uwnd) Outf.write ( line+'\ n') T= t + datetime.timedelta (hours=-1) IDX+ = 1outf.close ()Print 'Finish ...'
Meteoinfolab Script Example: Get meteorological data for each node of the air mass trajectory