- 积分
- 55960
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 MeteoInfo 于 2012-8-6 17:22 编辑
参照传说中的谁写的K指数计算方法的帖子(K指数计算方法
http://bbs.06climate.com/forum.php?mod=viewthread&tid=1854&fromuid=106
),写了一个MeteoInfo的脚本程序来实现同样的功能,对比了结果还不错。
脚本程序如下:
- #---- Import class libraries
- import clr
- clr.AddReferenceByPartialName("System.Windows.Forms")
- clr.AddReferenceByPartialName("System.Drawing")
- from System.Windows.Forms import *
- from System.Drawing import *
- clr.AddReference("MeteoInfoC.dll")
- from MeteoInfoC import *
- from MeteoInfoC.Data import *
- from MeteoInfoC.Data.MeteoData import *
- #---- Define variables
- BaseDir = "C:\\Program Files (x86)\\MeteoInfo\"
- MapDir = BaseDir + "Map\"
- DataDir = "F:\\Temp\\grib\"
- #---- Create MIApp object
- myApp = MIApp()
- #---- Open layers
- myApp.OpenLayer(MapDir + "country1.shp")
- myApp.SetLegendBreak("country1.shp",0,Color.Yellow,Color.Black,1,True,False,True)
- #---- Open data
- dataInfo = MeteoDataInfo()
- dataInfo.OpenGRIBData(DataDir + "fnl_20110416_00_00")
- #---- Get temperature grid data - 850 hPa
- dataInfo.LevelIndex = 20
- T850 = dataInfo.GetGridData("Temperature@pressure") - 273.16
- #---- Get relative humidity grid data - 850 hPa
- dataInfo.LevelIndex = 15
- rh = dataInfo.GetGridData("Relative_humidity@pressure")
- #---- Calculate Td
- Td850 = T850-((14.55+0.114*T850)*(1-0.01*rh)+DataMath.Pow((2.5+0.007*T850)*(1-0.01*rh),3)+ \
- (15.9+0.117*T850)*DataMath.Pow((1-0.01*rh),14))
- #---- Get temperature grid data - 700 hPa
- dataInfo.LevelIndex = 17
- T700 = dataInfo.GetGridData("Temperature@pressure") - 273.16
- #---- Get relative humidity grid data - 700 hPa
- dataInfo.LevelIndex = 12
- rh = dataInfo.GetGridData("Relative_humidity@pressure")
- #---- Calculate Td
- Td700 = T700-((14.55+0.114*T700)*(1-0.01*rh) + DataMath.Pow((2.5+0.007*T700)*(1-0.01*rh),3) + \
- (15.9+0.117*T700)*DataMath.Pow((1-0.01*rh),14))
- #---- Get temperature grid data - 500 hPa
- dataInfo.LevelIndex = 13
- T500 = dataInfo.GetGridData("Temperature@pressure") - 273.16
- #---- Calculate K
- K = T850-T500+Td850-(T700-Td700)
- #K.SaveAsSurferASCIIFile(DataDir + "K_test.dat")
- #---- Plot data
- myApp.MeteoDataInfo = dataInfo
- myApp.SetLegendScheme(DataDir + "k1.lgs")
- myApp.SetDrawType("contour")
- myApp.Display(K)
- myApp.MoveLayerToTop("country1.shp")
- myApp.ZoomLonLatEx(90,125,10,35)
- #myApp.ZoomLonLatEx(0,360,-90.1,90.1)
- aTime = dataInfo.GetTime()
- text = "K Index - " + aTime.ToString("yyyy-MM-dd")
- myApp.MapLayout.AddText(text, 320, 20)
- myApp.MapLayout.ActiveLayoutMap.GridXDelt = 5
- myApp.MapLayout.ActiveLayoutMap.GridYDelt = 5
- myApp.MapLayout.ActiveLayoutMap.DrawGridLine = False
- #myApp.ProjectLayers("+proj=moll+lon_0=105")
- myApp.MapLayout.PaintGraphics()
- Application.Run(myApp)
复制代码
|
|