本帖最后由 MeteoInfo 于 2013-1-16 14:03 编辑
dolces 发表于 2013-1-16 10:30
太谢谢了王老师
下了个0.5度的数据试了试,现在应该可以了,需要MeteoInfo最新文件(见置顶帖子,或者在www.meteothinker.com上下载更新文件)。示例脚本程序如下,脚本中读取0.5度ARL数据,挑出一些高度层数据输出。
- #-----------------------------------------------------------
- # Author: Yaqiang Wang
- # Date: 2013-1-16
- # Purpose: Read and write ARL data
- # Note: Sample
- #-----------------------------------------------------------
- import clr
- from System import *
- from System.Collections.Generic import *
- clr.AddReference("MeteoInfoC.dll")
- from MeteoInfoC import *
- from MeteoInfoC.Data import *
- from MeteoInfoC.Data.MeteoData import *
- #---- Set directories
- dataDir = "D:\\SampleData"
- #---- Set output data file
- outFile = dataDir + '\\test.arl'
- #---- Read a GRIB data file
- mydata = MeteoDataInfo()
- infile = dataDir + '\\20130113_gdas0p5'
- mydata.OpenARLData(infile)
- inarlDI = mydata.DataInfo
- #---- Set output ARL data info
- arlDI = ARLDataInfo()
- #---- Set variable and level list
- arlDI.X = mydata.GetX()
- arlDI.Y = mydata.GetY()
- arlDI.levels.Add(inarlDI.levels[0])
- arlDI.LevelVarList.Add(inarlDI.LevelVarList[0])
- for lidx in range(1, inarlDI.levels.Count, 2):
- arlDI.levels.Add(inarlDI.levels[lidx])
- arlDI.LevelVarList.Add(inarlDI.LevelVarList[lidx])
- #---- Write ARL data file
- arlDI.CreateDataFile(outFile)
- tNum = mydata.GetTimeNumber()
- for t in range(0, tNum):
- mydata.TimeIndex = t
- atime = mydata.GetTime(t)
- print atime.ToString("yyyy-MM-dd HH")
- aDH = arlDI.GetDataHead(mydata.ProjInfo, 'GDAS', 4)
- arlDI.WriteIndexRecord(atime, aDH)
- lidx = 0
- for l in arlDI.levels:
- print l
- nlidx = inarlDI.levels.IndexOf(l)
- if nlidx > 0:
- nlidx -= 1
- print nlidx
- mydata.LevelIndex = nlidx
- for v in arlDI.LevelVarList[lidx]:
- print v
- gData = mydata.GetGridData(v)
- aDL = DataLabel(atime)
- aDL.Level = lidx
- aDL.Variable = v
- aDL.Grid = 99
- aDL.Forecast = 0
- arlDI.WriteGridData(aDL, gData)
- lidx += 1
- arlDI.CloseDataFile()
- print 'Finished!'
|