- 积分
- 2280
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-9-11
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2016-8-4 09:15:54
|
显示全部楼层
本帖最后由 良辰 于 2016-8-4 09:34 编辑
恩,知道了王老师!那我想把我计算出来的涡度,Get meteorological data along trajectory。该如何设置那?例如温度是temp = meteof.tostation(tvar, lon, lat, pres, t)。- #-----------------------------------------------------
- # Author: Yaqiang Wang
- # Date: 2015-9-30
- # Purpose: Get meteorological data along trajectory
- # Note: Sample
- #-----------------------------------------------------
- # 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_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)
- u = meteof['UWND'][0,0,:,:]
- v = meteof['VWND'][0,0,:,:]
- vort = hcurl(u, v)
- #axesm()
- #mlayer = shaperead('D:\Temp\MeteoInfo\map/country1.shp')
- #geoshow(mlayer)
- #layer = contourfm(vort, 20)
- #layer = contourfm(divg, 20)
- #title('Vorticity')
- #title('Divergence')
- #colorbar(layer, orientation='horizontal', aspect=50)
- #print u;print v;print vort
- # 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,PBLH,UWND,VWND,WWND,HGTS,TEMP,RELH,CAPE,vort\n')
- pblvar = 'PBLH'
- uvar = 'UWND'
- vvar = 'VWND'
- wvar = 'WWND'
- hvar = 'HGTS'
- tvar = 'TEMP'
- rhvar = 'RELH'
- capevar = 'CAPE'
- vortvar = 'vort'
- #divg = hdivg(uvar, vvar)
- 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
- pbl = meteof.tostation(pblvar, lon, lat, None, t)
- uwnd = meteof.tostation(uvar, lon, lat, pres, t)
- vwnd = meteof.tostation(vvar, lon, lat, pres, t)
- wwnd = meteof.tostation(wvar, lon, lat, pres, t)
- hgt = meteof.tostation(hvar, lon, lat, pres, t)
- temp = meteof.tostation(tvar, lon, lat, pres, t)
- rh = meteof.tostation(rhvar, lon, lat, pres, t)
- cape = meteof.tostation(capevar, lon, lat, None, t)
- # vort = meteof.tostation(vortvar, lon, lat, pres, t) 这个地方如何写?????????
- print 'lon: %.3f; lat: %.3f; time: %s; height: %.1f; pres:%.1f; PBLH: %.1f; UWND: %.1f;VWND: %.1f;WWND: %.5f;HGTS: %.1f;TEMP: %.1f;RELH: %.1f;CAPE: %.1f;vort:%.5f' % (lon, lat, t.strftime('%Y%m%d_%H:%M'), z, pres, pbl, uwnd, vwnd, wwnd, hgt, temp, rh, cape, vort)
- line = '%.3f,%.3f,%s,%.1f,%.1f,%.1f,%.1f,%.1f,%.5f,%.1f,%.1f,%.1f,%.1f,%.5f' % (lon,lat,t.strftime('%Y%m%d_%H:%M'),z,pres,pbl,uwnd,vwnd,wwnd,hgt,temp,rh,cape,vort)</P>
- <P> outf.write(line + '\n')
- t = t + datetime.timedelta(hours=-1)
- idx += 1
- outf.close()
- print 'Finish...' </P>
复制代码
|
|