- 积分
- 2280
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-9-11
- 最后登录
- 1970-1-1
|
发表于 2016-8-16 09:14:31
|
显示全部楼层
- # Set working directory
- trajDir = 'D:/Temp/HYSPLIT'
- meteoDir = r'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)
- # 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,TEMP,RELH,VORT,DIVG,es\n')
- #uwnd = meteof['UWND'][:,:,:,:]
- #vwnd = meteof['VWND'][:,:,:,:]
- tvar = meteof['TEMP'][:,:,:,:]
- rhvar = meteof['RELH'][:,:,:,:]
- uwnd = meteof['UWND'][:,:,[10, 80],[50,160]]
- vwnd = meteof['VWND'][:,:,[10, 80],[50,160]]
- gv = meteof['HGTS']
- nx = gv.dimlen(gv.ndim - 1)
- ny = gv.dimlen(gv.ndim - 2)
- levels = gv.dimvalue(gv.ndim - 3)[::1]
- prs = levels
- #vort = hcurl(uwnd, vwnd)
- #divg = hdivg(uwnd, vwnd)
- #######假相当位温的计算#####
- es = 6.1078*exp(17.2693882*(tvar-273.16)/(tvar-35.86))
- print es
- '''
- qq = rvar*(0.62197*es/(prs-0.378*es))/100.
- e = prs*qq/(0.62197+qq)+1e-10
- tlcl = 55.0+2840.0/(3.5*log(tvar)-log(e)-4.805)
- theta = tvar*pow((1000/prs),(0.2854*(1.0-0.28*qq)))
- eqt = theta*exp(((3376./tlcl)-2.54)*qq*(1.0+0.81*qq))
- thse = eqt-273.15
- print thse
- ###########湿位涡###########grads程序,没有做相应修改###
- f = 2*7.292*sin(lat*3.14159/180.0)*0.00001
- g = 9.8
- dp = 100*(lev(z-1)-lev(z+1))
- deqt = eqt(z-1)-eqt(z+1)
- du = uwnd(z-1)-uwnd(z+1)
- dv = vwnd(z-1)-vwnd(z+1)
- dx = 2.0*6370949.0*cos(lat*3.14159/180.0)*3.14159/180.0
- dy = 2.0*6370949.0*3.14159/180.0
- dtx = cdiff(eqt,x)
- dty = cdiff(eqt,y)
- pv1 = -g*(vort+f)*deqt/dp
- pv2 = g*((dv/dp)*(dtx/dx)-(du/dp)*(dty/dy))
- pv = pv1+pv2
- '''
- 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])
- d = divg.interpn([t,pres,lat,lon])
- # temp = meteof.tostation(tvar, lon, lat, pres, t)
- # rh = meteof.tostation(rhvar, lon, lat, pres, t)
- # es = meteof.tostation(esvar, lon, lat, pres, t)
- print 'lon: %.3f; lat: %.3f; time: %s; height: %.1f; pres: %.1f; TEMP: %.1f; RELH: %.1f; VORT: %f; DIVG: %f' % (lon,lat,t.strftime('%Y%m%d_%H:%M'),z,pres,temp,rh,v,d)
- line = '%.3f,%.3f,%s,%.1f,%.1f,%.1f,%.1f,%f,%f,%f' % (lon,lat,t.strftime('%Y%m%d_%H:%M'),z,pres,temp,rh,v,d)
- outf.write(line + '\n')
- t = t + datetime.timedelta(hours=-1)
- idx += 1
- outf.close()
- print 'Finish...'
复制代码
王老师,我想计算位涡。提取温度数据数组参与计算了,但是还是出错,错误如下:
File "<iostream>", line 36, in <module>
File "D:\Temp\MeteoInfo\pylib\mipylib\dimarray.py", line 210, in __rmul__
return DimArray.__mul__(self, other)
File "D:\Temp\MeteoInfo\pylib\mipylib\dimarray.py", line 206, in __mul__
r = DimArray(self.array.__mul__(other), self.dims, self.fill_value, self.proj)
File "D:\Temp\MeteoInfo\pylib\mipylib\miarray.py", line 166, in __mul__
r = MIArray(ArrayMath.mul(self.array, other))
王老师,有时间帮我看一下呗? |
|