- 积分
- 1331
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2018-7-3
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
有人试过将ERA5下载的grib文件转hysplit能用的arl吗?
hysplit里面自带的把ECMWF转arl的需要3个文件,在ERA5里我只下载到了3d和2d文件,invariant文件不知道在哪,用不了这个自带的程序。
我又用hysplit论坛上的python程序下载了一个3d文件和一个2d文件,还生成了一个cfg文件,但是后面要怎么转也没搞明白。
meteoinfo里把grib转arl的程序又是用的fnl下载的grib文件,是把3d和2d都放在一个grib里面的,我把程序改成读取两个grib文件的。
#---- Set data folder
datadir = 'E:\ERA5\python'
#---- Set output data file
outfn = os.path.join(datadir, 'test_grib.arl')
#if os.path.exists(outfn):
# os.remove(outfn)
#---- Read a GRIB data file
infn = os.path.join(datadir, 'ERA5_2019.Jan01.2dpl.all.grib')
infn1 = os.path.join(datadir, 'ERA5_2019.Jan01.3dpl.grib')
print infn
inf = addfile(infn)
print infn1
inf1 = addfile(infn1)
print 'GRIB data file has been opened...'
#---- Set output ARL data file
arlf = addfile(outfn, 'c', dtype='arl')
#---- Set variable and level list
gvar2d = ['Pressure_surface','Temperature_surface','u-component_of_wind_height_above_ground',\
'v-component_of_wind_height_above_ground']
gvar3d = ['Geopotential_isobaric','Temperature_isobaric','Pressure_Vertical_velocity_isobaric',\
'u-component_of_wind_isobaric','v-component_of_wind_isobaric','Specific_humidity_isobaric']
avar2d = ['PRSS','T02M','U10M','V10M']
avar3d = ['HGTS','TEMP','WWND','UWND','VWND','SPHU']
gv = inf1['Geopotential_isobaric']
nx = gv.dimlen(gv.ndim - 1)
ny = gv.dimlen(gv.ndim - 2)
levels = gv.dimvalue(gv.ndim - 3)[::-1]
nz = len(levels)
arlf.setlevels(levels)
arlf.set2dvar(avar2d)
for l in levels:
arlf.set3dvar(avar3d)
#---- Write ARL data file
arlf.setx(gv.dimvalue(gv.ndim - 1))
arlf.sety(gv.dimvalue(gv.ndim - 2))
tNum = inf1.timenum()
fhour = 0
for t in range(0, tNum):
print 'Time index: ' + str(t)
atime = inf1.gettime(t)
print atime.strftime('%Y-%m-%d %H:00')
dhead = arlf.getdatahead(inf1.proj, 'RSMC', 2, fhour)
#Pre-write index record without checksum - will be over-write latter
arlf.writeindexrec(atime, dhead)
#Checksum list
ksumlist = []
# Write 2d variables
ksums = []
for avname,gvname in zip(avar2d, gvar2d):
print avname + ' ' + gvname
if avname == 'U10M' or avname == 'V10M':
gdata = inf[gvname][t,0,:,:]
else:
gdata = inf[gvname][t,:,:]
if avname == 'PRSS':
gdata = gdata * 0.01
ksum = arlf.writedatarec(atime, 0, avname, fhour, 99, gdata)
ksums.append(ksum)
ksumlist.append(ksums)
# Write 3d variables
for lidx in range(0, nz):
ksums = []
llidx = nz - lidx - 1
print lidx
print llidx
for avname,gvname in zip(avar3d, gvar3d):
print avname + ' ' + gvname
gdata = inf1[gvname][t,llidx,:,:]
if avname == 'WWND':
gdata = gdata * 0.01
elif avname == 'SPHU':
gdata = gdata * 1000.
ksum = arlf.writedatarec(atime, lidx + 1, avname, fhour, 99, gdata)
ksums.append(ksum)
ksumlist.append(ksums)
#Re-write index record with checksum
arlf.writeindexrec(atime, dhead, ksumlist)
fhour += 1
arlf.close()
print 'Finished!'
显示的错误
Traceback (most recent call last):
File "<iostream>", line 55, in <module>
File "D:\software\MeteoInfo\pylib\mipylib\dataset\dimdatafile.py", line 45, in __getitem__
raise ValueError()
ValueError
45行是标红那里,不知道是什么原因。
有哪位大佬转过这个吗?能教一教我吗?
|
|