- 积分
- 55946
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
从4维(时间、高度、纬度、经度)气象格点数据中读取风场U/V分量4维数组,然后用vort函数计算涡度,读取气团轨迹节点的4维坐标,将涡度数据插值到轨迹节点上(用到interpn函数)。
- # Set working directory
- trajDir = 'D:/Temp/HYSPLIT'
- meteoDir = r'U:\data\ARL\2015'
- # Open trjactory data file
- print 'Open trajectory data file ...'
- trajfn = os.path.join(trajDir, 'traj_20150331')
- print 'Trajectory file: ' + trajfn
- trajf = addfile_hytraj(trajfn)
- # Create trajectory layer
- trajLayer = trajf.trajlayer()
- # Open meteorological data file
- print 'Open meteorological data file...'
- meteofn = os.path.join(meteoDir, 'gdas1.mar15.w5')
- print 'Meteorological file: ' + meteofn
- meteof = addfile(meteofn)
- # Get meteorological data along trajectory
- print 'Get meteorological data along trajectory...'
- outfn = os.path.join(trajDir, 'traj.txt')
- outf = open(outfn, 'w')
- outf.write('Lon,Lat,Time,Heigh,pres,VORT\n')
- #uwnd = meteof['UWND'][:,:,:,:]
- #vwnd = meteof['VWND'][:,:,:,:]
- uwnd = meteof['UWND'][:,:,[10, 80],[50,140]]
- vwnd = meteof['VWND'][:,:,[10, 80],[50,140]]
- vort = hcurl(uwnd, vwnd)
- idx = 0
- for tline in trajLayer.shapes():
- t = trajLayer.cellvalue('Date', idx)
- h = trajLayer.cellvalue('Hour', idx)
- t.replace(hour=h)
- for ps in tline.getPoints():
- lon = ps.X
- lat = ps.Y
- z = ps.M
- pres = ps.Z
- v = vort.interpn([t,pres,lat,lon])
- print 'lon: %.3f; lat: %.3f; time: %s; height: %.1f; pres: %.1f; VORT: %f' % (lon,lat,t.strftime('%Y%m%d_%H:%M'),z,pres,v)
- line = '%.3f,%.3f,%s,%.1f,%.1f,%f' % (lon,lat,t.strftime('%Y%m%d_%H:%M'),z,pres,v)
- outf.write(line + '\n')
- t = t + datetime.timedelta(hours=-1)
- idx += 1
- outf.close()
- print 'Finish...'
|
评分
-
查看全部评分
|