爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
楼主: MeteoInfo

MeteoInfo脚本示例:GRIB to ARL

[复制链接]

新浪微博达人勋

 楼主| 发表于 2016-1-8 11:15:41 | 显示全部楼层
【蓝】 发表于 2016-1-8 10:55
王老师,您好,我现在想把WRF的数据转换成arl,借用了您的程序,但是报错如下,meteoinfo小白,如果问的问 ...

要在MeteoInfoLab里运行(MeteoInfo目录中运行MeteoInfoLab.exe)。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-1-11 19:03:07 | 显示全部楼层
MeteoInfo 发表于 2016-1-8 11:15
要在MeteoInfoLab里运行(MeteoInfo目录中运行MeteoInfoLab.exe)。

王老师,用您的程序从网上下载了一个WRF数据,算出来arl格式的数据没错。但是等自己转出来WRF数据,用meteoinfo打开是没错的,但是转出来的ARL格式数据是有错误的,用HYSPLIT计算时候也总是说 *ERROR* metpos: start point not within (x,y,t) any data file  - start time before start of meteorology data。用meteoinfo无法打开arl格式数据,总是报错说
G:\MeteoInfo\map\country1.shp
G:\MeteoInfo\map\bou2_4p.shp
java.lang.NumberFormatException: For input string: "T  1"
        at java.lang.NumberFormatException.forInputString(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at org.meteoinfo.data.meteodata.arl.ARLDataInfo.readDataLabel(ARLDataInfo.java:546)
        at org.meteoinfo.data.meteodata.arl.ARLDataInfo.readDataInfo(ARLDataInfo.java:452)
        at org.meteoinfo.data.meteodata.MeteoDataInfo.openARLData(MeteoDataInfo.java:471)
        at org.meteoinfo.desktop.forms.FrmMeteoData.onARLDataClick(FrmMeteoData.java:1826)
        at org.meteoinfo.desktop.forms.FrmMeteoData.access$900(FrmMeteoData.java:80)
        at org.meteoinfo.desktop.forms.FrmMeteoData$11.actionPerformed(FrmMeteoData.java:411)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.AbstractButton.doClick(Unknown Source)
        at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
        at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$500(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-1-11 19:09:51 | 显示全部楼层
MeteoInfo 发表于 2016-1-8 11:15
要在MeteoInfoLab里运行(MeteoInfo目录中运行MeteoInfoLab.exe)。

190608.jpg
WRF数据是可以用meteoinfo打开的,数据是逐小时的数据
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-1-12 08:23:29 | 显示全部楼层
【蓝】 发表于 2016-1-11 19:03
王老师,用您的程序从网上下载了一个WRF数据,算出来arl格式的数据没错。但是等自己转出来WRF数据,用met ...

你是怎么把wrf数据转为arl的?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-1-12 08:55:37 | 显示全部楼层
MeteoInfo 发表于 2016-1-12 08:23
你是怎么把wrf数据转为arl的?

用您在另一个帖子里给的程序
#--------------------------------------------------------        # Author: Yaqiang Wang                                          
# Date: 2015-12-2                                            
# Purpose: Convert WRF out netCDF data to ARL data  
# Note: Sample                                                   
#-----------------------------------------------------------
#---- Set data folder
datadir = 'D:/WRFdata'
#---- Set output data file
outfn = os.path.join(datadir, 'WRF2015_05_28-2015_05_28.arl')
if os.path.exists(outfn):
    os.remove(outfn)
#---- Read a netCDF data file
infn = os.path.join(datadir, 'wrfout_d02_2015-05-25_00_00_00')
print infn
inf = addfile(infn)
print 'NetCDF file has been opened...'
#---- Set output ARL data file
arlf = addfile(outfn, 'c', dtype='arl')
#---- Set variable and level list
wvar2d = ['HGT','PSFC','PBLH','UST','SWDOWN','HFX','LH','T2','U10','V10','RAINNC']
wvar3d = ['P','T','U','V','W','QVAPOR']
avar2d = ['SHGT','PRSS','PBLH','USTR','DSWF','SHTF','LHTF','T02M','U10M','V10M','TPPA']
avar3d = ['PRES','TEMP','UWND','VWND','WWND','SPHU']
wv = inf['P']
nx = wv.dimlen(wv.ndim - 1)
ny = wv.dimlen(wv.ndim - 2)
levels = wv.dimvalue(wv.ndim - 3)
nz = len(levels)
arlf.setlevels(levels)
arlf.set2dvar(avar2d)
for l in levels:
    arlf.set3dvar(avar3d)
#---- Constant for poisson's equation
cp = 1004.0         # J/kg/K; specific heat
grav = 9.81         # m/s**2; gravity
rdry = 287.04       # J/kg/K; gas constant
rovcp = rdry / cp   # constant for poisson's equation
#---- Write ARL data file
arlf.setx(wv.dimvalue(wv.ndim - 1))
arlf.sety(wv.dimvalue(wv.ndim - 2))
tNum = inf.timenum()
fhour = 0
for t in range(0, tNum):
    print 'Time index: ' + str(t)
    atime = inf.gettime(t)   
    print atime.strftime('%Y-%m-%d %H:00')
    dhead = arlf.getdatahead(inf.proj, 'AWRF', 1, 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,wvname in zip(avar2d, wvar2d):        
        #print avname + ' ' + wvname
        gdata = inf[wvname][t,:,:]
        if avname == 'PRSS':
            gdata = gdata * 0.01
        elif avname == 'TPPA':
            gdata = gdata * 0.001
        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 = []
        #print lidx
        pp = inf['P'][t,lidx,:,:]
        pb = inf['PB'][t,lidx,:,:]
        pres = pp + pb        
        uwnd = inf['U'][t,lidx,:,:]               
        vwnd = inf['V'][t,lidx,:,:]        
        temp = inf['T'][t,lidx,:,:]
        #potential to ambient temperature
        temp = (temp + 300.) * (pres / 100000.) ** rovcp        
        sphu = inf['QVAPOR'][t,lidx,:,:]        
        wwnd = inf['W'][t,lidx+1,:,:]
        #convert vertical velocity from m/s to hPa/s using omega = -W g rho
        wwnd = -wwnd * grav * pres * 0.01 / (rdry * temp * (1.0 + 0.6077 * sphu))
        pres = pres * 0.01
        ksum = arlf.writedatarec(atime, lidx + 1, 'PRES', fhour, 99, pres)
        ksums.append(ksum)
        ksum = arlf.writedatarec(atime, lidx + 1, 'TEMP', fhour, 99, temp)
        ksums.append(ksum)
        ksum = arlf.writedatarec(atime, lidx + 1, 'UWND', fhour, 99, uwnd[:,:nx])
        ksums.append(ksum)
        ksum = arlf.writedatarec(atime, lidx + 1, 'VWND', fhour, 99, vwnd[:ny,:])
        ksums.append(ksum)
        ksum = arlf.writedatarec(atime, lidx + 1, 'WWND', fhour, 99, wwnd)
        ksums.append(ksum)      
        ksum = arlf.writedatarec(atime, lidx + 1, 'SPHU', fhour, 99, sphu)
        ksums.append(ksum)
        ksumlist.append(ksums)
    #Re-write index record with checksum
    arlf.writeindexrec(atime, dhead, ksumlist)
    fhour += 6
arlf.close()
print 'Finished!'

密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-1-12 08:59:21 | 显示全部楼层
MeteoInfo 发表于 2016-1-12 08:23
你是怎么把wrf数据转为arl的?

我怀疑是WRF数据的问题,但是meteoinfo打开没问题。因为之前另一个网上下的wrf测试数据,不仅meteoinfo可以转换格式,用arw2arl.exe也可以转换,但是这个WRF数据就不能用arw2arl.exe转换,您的程序能转换,但是转换了也打不开
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-1-12 09:33:09 | 显示全部楼层
【蓝】 发表于 2016-1-12 08:59
我怀疑是WRF数据的问题,但是meteoinfo打开没问题。因为之前另一个网上下的wrf测试数据,不仅meteoinfo可 ...

如果方便提供wrf数据文件,可以测试一下问题出在哪里
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-1-12 09:48:35 | 显示全部楼层
MeteoInfo 发表于 2016-1-12 09:33
如果方便提供wrf数据文件,可以测试一下问题出在哪里

我正在往网盘里上传,数据略大,请稍等,麻烦您了!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-1-12 11:44:01 | 显示全部楼层
MeteoInfo 发表于 2016-1-12 09:33
如果方便提供wrf数据文件,可以测试一下问题出在哪里

刚传好,数据有点大,麻烦您了。
链接: http://pan.baidu.com/s/1geesUOV 密码: iyq8
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-1-12 18:29:27 | 显示全部楼层
【蓝】 发表于 2016-1-12 11:44
刚传好,数据有点大,麻烦您了。
链接: http://pan.baidu.com/s/1geesUOV 密码: iyq8

fhour += 6
改为
fhour += 1

其实是有一个bug,如果fhour多于两位数就会有问题,这个参数实际也没什么用处,如果时次过多也可以设为一个常数(比如0)。
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表