爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 3136|回复: 6

运行meteoinfo出现error

[复制链接]

新浪微博达人勋

发表于 2015-12-24 14:20:46 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 天边的那边 于 2015-12-24 15:48 编辑

Traceback (most recent call last):
  File "<iostream>", line 49, in <module>
TypeError: getDataHead(): expected 5 args; got 3
软件为java版本

#--------------------------------------------------------        
# Author: Yaqiang Wang                                          
# Date: 2014-10-24                                               
# Purpose: Convert GRIB data to ARL data  
# Note: Sample                                                   
#-----------------------------------------------------------
from org.meteoinfo.data.meteodata import MeteoDataInfo
from org.meteoinfo.data.meteodata.arl import ARLDataInfo
from org.meteoinfo.data.meteodata.arl import DataLabel
import os
#---- Set directories
dataDir = "D:/Temp/"
#---- Set output data file
outFile = os.path.join(dataDir, 'arl/test.arl')
#---- Read a GRIB data file
mydata = MeteoDataInfo()
infile = os.path.join(dataDir, 'grib/grib2010071600')
print infile
mydata.openNetCDFData(infile)
print 'GRIB file has been opened...'
#---- Set output ARL data info
arlDI = ARLDataInfo()
#---- Set variable and level list
#gvars = ['Pressure@surface','Temperature@height_above_ground',\
#   'U-component_of_wind@height_above_ground','V-component_of_wind@height_above_ground',\
#  'Total_precipitation@surface','Geopotential_height@pressure','Temperature@pressure',\
#    'U-component_of_wind@pressure','V-component_of_wind@pressure','Vertical_velocity@pressure',\
#    'Relative_humidity@pressure']
gvars = ['PRESsfc','TMP2m','UGRD10m','VGRD10m','HGTprs','TMPprs','UGRDprs','UGRDprs','VVELprs','RHprs']
avars = ['PRSS','T02M','U10M','V10M','HGTS','TEMP','UWND','VWND','WWND','RELH']
levels = [0,200,300,400,500,600,700,800,\
    850,900,925,950,975,1000]
for l in levels:
    arlDI.levels.add(l)
    if l == 0:
        arlDI.LevelVarList.add(['PRSS','T02M','U10M','V10M'])
    else:
        arlDI.LevelVarList.add(['HGTS','TEMP','UWND','VWND','WWND','RELH'])
#---- Write ARL data file
dataInfo = mydata.getDataInfo()
arlDI.createDataFile(outFile)
arlDI.X = dataInfo.getXDimension().getValues()
arlDI.Y = dataInfo.getYDimension().getValues()
variables = dataInfo.getVariables()
tNum = dataInfo.getTimeNum()
for t in range(0, tNum):
    mydata.setTimeIndex(t)
    atime = dataInfo.getTimes().get(t)
    aDH = arlDI.getDataHead(mydata.getProjectionInfo(), 'FNL1', 2)
    arlDI.writeIndexRecord(atime, aDH)
    lidx = 0
    for l in arlDI.levels:
        print l
        for v in arlDI.LevelVarList[lidx]:
            vName = gvars[avars.index(v)]
            print vName
            if lidx == 0:
                mydata.setLevelIndex(lidx)
            else:
                variable = dataInfo.getVariable(vName)
                nlidx = variable.getZDimension().getDimValue().indexOf(l*1.0)
                mydata.setLevelIndex(nlidx)
            gData = mydata.getGridData(vName)
            if v == 'PRSS' or v == 'WWND':
                gData = gData.div(100)      
            aDL = DataLabel(atime)
            aDL.setLevel(lidx)
            aDL.setVarName(v)
            aDL.setGrid(99)
            aDL.setForecast(0)
            arlDI.writeGridData(aDL, gData)
        lidx += 1
arlDI.closeDataFile()
print 'Finished!'
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-12-24 14:50:32 | 显示全部楼层
本帖最后由 天边的那边 于 2015-12-24 16:06 编辑

c版本和java版本有问题,问题类型不同
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-12-24 14:58:13 | 显示全部楼层
Traceback (most recent call last):
  File "<string>", line 48, in <module>
AttributeError: 'ARLDataInfo' object has no attribute 'CreateDataFile'
又出现新的问题??
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-12-24 19:50:09 | 显示全部楼层
什么情况。。。。
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2015-12-25 08:38:38 | 显示全部楼层
天边的那边 发表于 2015-12-24 14:58
Traceback (most recent call last):
  File "", line 48, in
AttributeError: 'ARLDataInfo' object ha ...

MeteoInfo有C#和Java两个版本,脚本程序的写法是有区别的。建议用Java版,脚本程序在MeteoInfoLab里运行。转ARL格式的脚本参考这个帖子:MeteoInfoLab脚本示例:wrfout转arl
http://bbs.06climate.com/forum.p ... 264&fromuid=106
(出处: 气象家园)
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-12-25 09:10:29 | 显示全部楼层
MeteoInfo 发表于 2015-12-25 08:38
MeteoInfo有C#和Java两个版本,脚本程序的写法是有区别的。建议用Java版,脚本程序在MeteoInfoLab里运行 ...


王老师,两个版本我都试了,都有问题

Traceback (most recent call last):
  File "<iostream>", line 49, in <module>
TypeError: getDataHead(): expected 5 args; got 3
软件为java版本
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-12-25 15:11:12 | 显示全部楼层
天边的那边 发表于 2015-12-25 09:10
王老师,两个版本我都试了,都有问题

Traceback (most recent call last):

后来有更新getDataHead函数需要5个参数(投影信息,模式名,高度层标志,预报时次,分钟),将下面
aDH = arlDI.getDataHead(mydata.getProjectionInfo(), 'FNL1', 2)
改为:
aDH = arlDI.getDataHead(mydata.getProjectionInfo(), 'FNL1', 2, 0, 0)
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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