- 积分
- 55960
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
MICAPS第一类数据是地面全要素观测数据,每个文件一个时次,包含很多站点和要素。这个脚本程序是要解决从多个MICAPS第一类数据文件中提取某些站点、某些要素的数据,并保存为文本文件。应该对业务科研工作比较有用。
示例脚本程序如下(需要MeteoInfo Java最新版本1.1.9R3的支持):
- #--------------------------------------------------------
- # Author: Yaqiang Wang
- # Date: 2015-1-14
- # Purpose: Extract station data from micaps1 data
- # Note: Sample
- #-----------------------------------------------------------
- from org.meteoinfo.data.meteodata import MeteoDataInfo
- from org.meteoinfo.table import DataTable
- import os
- import datetime
- #---- Set data directories
- print 'Start script...'
- mdir = 'U:/data/micaps/2014/plot'
- outdir = 'D:/Temp/test'
- #---- Set stations
- stations = ['54511', '58362']
- #---- Set variables
- # Avialable variables in MICAPS 1 data:
- # "Altitude", "Grade", "CloudCover", "WindDirection", "WindSpeed", "Pressure",
- # "PressVar3h", "WeatherPast1", "WeatherPast2", "Precipitation6h", "LowCloudShape",
- # "LowCloudAmount", "LowCloudHeight", "DewPoint", "Visibility", "WeatherNow",
- # "Temperature", "MiddleCloudShape", "HighCloudShape"
- variables = ['WindDirection','WindSpeed']
- #---- Set start/end times
- stime = datetime.datetime.now()
- sdate = datetime.datetime(2014, 10, 1, 2)
- edate = datetime.datetime(2014, 10, 10, 3)
- #edate = datetime.datetime(2014, 12, 31, 24)
- #---- Extract data
- mdi = MeteoDataInfo()
- rTable = DataTable()
- n = 0
- while sdate < edate:
- mfn = os.path.join(mdir, sdate.strftime('%y%m%d%H') + '.000')
- if os.path.exists(mfn):
- print mfn
- mdi.openMICAPSData(mfn)
- stdata = mdi.getStationInfoData()
- t = mdi.getDataInfo().getTime(0)
- result = stdata.extractStationData(stations, variables, t)
- print result.toString()
- if n == 0:
- rTable = result
- else:
- for row in result.getRows():
- rTable.appendRow(row)
- n += 1
- sdate = sdate + datetime.timedelta(hours=3)
- #---- Output result
- print '**********************************'
- #print rTable.toString()
- #outfn = os.path.join(outdir, 'stdata_test.csv')
- #rTable.saveAsCSVFile(outfn)
- outfn = os.path.join(outdir, 'stdata_test.txt')
- rTable.saveAsASCIIFile(outfn)
- print 'Run time: %s'%(datetime.datetime.now() - stime)
- print 'Finished!'
|
|