- 积分
- 55965
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
MICAPS第1类数据中有温度和露点,但没有相对湿度,需要计算获得。我不是学气象的,在网上查了一些资料,对这三者的关系有了简单的认识。在MeteoInfo类库的org.meteoinfo.data.analysis包中增加了一个MeteoMath类,希望能将气象相关算法陆续加入进去,目前实现了计算饱和水汽压(cal_Es(double tc)方法)、计算相对湿度(cal_RH(double t, double tdc)方法)、计算露点(cal_Tdc(double t, double rh)方法)。主要参考了“西风江南”提供的算法(http://bbs.06climate.com/forum.php?mod=viewthread&tid=15263&highlight=%C2%B6%B5%E3%2B%CF%E0%B6%D4%CA%AA%B6%C8),另外此网页有更简洁的算法(http://www.gorhamschaffler.com/humidity_formulas.htm),如果能有高手对这些算法进行一些讲解就更好了。和在线计算器的结果(http://go.vaisala.com/humiditycalculator/vaisala_humidity_calculator.html)进行了对比,结果很接近。需要用到最新的MeteoInfo Java 1.1.9R4版(http://www.meteothinker.com/Downloads.html)。
这是一个示例脚本:
- from org.meteoinfo.data.analysis import MeteoMath
- t = 20
- #dt = 10
- rh = 50
- #rh = MeteoMath.cal_RH(t, dt)
- dt = MeteoMath.cal_Tdc(t, rh)
- print 'RH: ' + str(rh)
- print 'Dewpoint: ' + str(dt)
从MICAPS第1类数据中提取温度和露点,然后计算相对湿度的脚本:
- #--------------------------------------------------------
- # Author: Yaqiang Wang
- # Date: 2015-1-14
- # Purpose: Extract station data from micaps1 data and calculate
- # relative humidity from temperature and dewpoint
- # Note: Sample
- #-----------------------------------------------------------
- from org.meteoinfo.data.meteodata import MeteoDataInfo
- from org.meteoinfo.table import DataTable, DataTypes
- from org.meteoinfo.data.analysis import MeteoMath
- 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 = ['Temperature','DewPoint']
- #---- Set start/end times
- stime = datetime.datetime.now()
- sdate = datetime.datetime(2014, 10, 1, 2)
- edate = datetime.datetime(2014, 10, 2, 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)
- result.addColumn('RH', DataTypes.String)
- for row in result.getRows():
- temp = float(row.getValue('Temperature'))
- dp = float(row.getValue('DewPoint'))
- rh = MeteoMath.cal_RH(temp, dp)
- row.setValue('RH', '%.2f'%rh)
- 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!'
|
评分
-
查看全部评分
|