- 积分
- 55945
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 MeteoInfo 于 2023-10-16 22:28 编辑
读取HYSPLIT输出的轨迹数据文件和相应时间的气象数据文件,生成轨迹图层,循环每条轨迹的节点,读出该节点的经度、纬度、气压、时间,通过对气象数据插值获得该节点的气象数据。
脚本程序:
- # Set working directory
- trajDir = 'D:/Temp/HYSPLIT'
- meteoDir = 'D:/Temp/arl'
- # Open trjactory data file
- print 'Open trajectory data file ...'
- trajfn = os.path.join(trajDir, 'traj_20090731')
- print 'Trajectory file: ' + trajfn
- trajf = addfile_hytraj(trajfn)
- # Read coordinates
- lons = trajf['lon'][:]
- lats = trajf['lat'][:]
- press = trajf['PRESSURE'][:]
- heights = trajf['height'][:]
- tt = trajf['time'][:]
- ntraj, np = lons.shape
- # Open meteorological data file
- print 'Open meteorological data file...'
- meteofn = os.path.join(meteoDir, 'gdas1.jul09.w5')
- print 'Meteorological file: ' + meteofn
- meteof = addfile(meteofn)
- # Get meteorological data along trajectory
- print 'Get meteorological data along trajectory...'
- outfn = os.path.join(trajDir, 'pblh_traj-1.txt')
- outf = open(outfn, 'w')
- outf.write('TrajID,Lon,Lat,Time,Heigh,PBLH,UWND\n')
- pbldata = meteof['PBLH'][:]
- udata = meteof['UWND'][:]
- idx = 0
- for i in range(ntraj):
- for j in range(np):
- lon = lons[i,j]
- lat = lats[i,j]
- pres = press[i,j]
- z = heights[i,j]
- t = tt[i,j]
- pbl = pbldata.interpn([t, lat, lon])
- uwnd = udata.interpn([t, pres, lat, lon])
- t = miutil.num2date(t)
- print 'TrajID: %i; lon: %.2f; lat: %.2f; time: %s; height: %.2f; PBLH: %.2f; UWND: %.2f' \
- % (i, lon, lat, t.strftime('%Y%m%d_%H:%M'), z, pbl, uwnd)
- line = '%i,%.4f,%.4f,%s,%.2f,%.2f,%.2f' % (i,lon,lat,t.strftime('%Y%m%d_%H:%M'),z,pbl,uwnd)
- outf.write(line + '\n')
- t = t + datetime.timedelta(hours=-1)
- idx += 1
- outf.close()
- print 'Finish...'
|
|