- 积分
- 55950
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 MeteoInfo 于 2017-8-25 12:07 编辑
GRIB数据转为MICAP4格式数据的例子:
- fn = 'D:/Temp/grib/fnl_20110416_00_00'
- f = addfile(fn)
- v = f['Temperature_isobaric']
- zn = v.dimlen(1)
- data = v[0,zn-1,:,:] #First level from ground
- data = data - 273.16
- #Save as MICAPS4 data file
- outfn = 'D:/Temp/grib/grib2m4.000'
- t = f.gettime(0)
- data.savegrid(outfn, format='micaps4', description='Temperature', \
- date=t, hours=0, level=0, smooth=1, boldvalue=0)
批量转换:
- fn = 'D:/Temp/grib/Z_NAFP_C_BABJ_2016041800_P_gmf-639-2016041800003.grib1'
- outdir = 'E:/Temp/test'
- f = addfile(fn)
- t = f.gettime(0)
- vnames = ['Pressure_surface', 'Temperature_isobaric']
- for vname in vnames:
- v = f[vname]
- print vname
- if v.ndim == 3:
- data = v[0,:,:]
- #Save as MICAPS4 data file
- outfn = os.path.join(outdir, 'm4_' + vname + '_surface' + '.000')
- data.savegrid(outfn, format='micaps4', description=vname + '_1000', \
- date=t, hours=0, level=0, smooth=1, boldvalue=0)
- elif v.ndim == 4:
- #Get levels
- levels = v.dimvalue(1)
- for idx in range(0, len(levels)):
- level = levels[idx]
- print '\t' + str(level)
- data = v[0,idx,:,:]
- #Save as MICAPS4 data file
- outfn = os.path.join(outdir, 'm4_' + vname + '_' + str(int(level)) + '.000')
- data.savegrid(outfn, format='micaps4', description=vname + '_' + \
- str(int(level)), date=t, hours=0, level=0, smooth=1, boldvalue=0)
|
|