本帖最后由 MeteoInfo 于 2014-3-26 09:50 编辑
做了一个示例脚本程序,可以参考。之前读取NetCDF文件的功能有一些bug,请下载、更新MeteoInfo最新文件(MeteoInfo最新文件
http://bbs.06climate.com/forum.p ... id=1126&fromuid=106
(出处: 气象家园)
)
- #-------------------------------------------------------- # Author: Yaqiang Wang
- # Date: 2014-3-25
- # Purpose: Calculate average grid data and plot
- # Note: Sample
- #-----------------------------------------------------------
- import clr
- from System.Collections.Generic import *
- clr.AddReference("MeteoInfoC.dll")
- from MeteoInfoC import *
- from MeteoInfoC.Data import *
- from MeteoInfoC.Data.MeteoData import *
- from MeteoInfoC.Legend import *
- from MeteoInfoC.Shape import *
- #---- Set directories
- dataDir = "D:\\Temp\\nc\\data1\\"
- #---- Open data file
- mdi = MeteoDataInfo()
- mdi.OpenNCData(dataDir + "d01")
- #---- Average grid data
- tnum = mdi.GetTimeNumber()
- print 'Time number: ' + str(tnum)
- sumData = GridData()
- mdi.LevelIndex = 15
- varName = 'T'
- for i in range(0, tnum):
- mdi.TimeIndex = i
- gdata = mdi.GetGridData(varName)
- if i == 0:
- sumData = gdata
- else:
- sumData = sumData + gdata
- aveData = sumData / tnum
-
- #---- Create shaded layer from the grid data
- print 'Create shaded layer'
- aLS = LegendManage.CreateLegendSchemeFromGridData(aveData, LegendType.GraduatedColor, ShapeTypes.Polygon)
- aLayer = DrawMeteoData.CreateShadedLayer(aveData, aLS, varName, "Value")
- aLayer.ProjInfo = mdi.ProjInfo
- mipy.MapDocument.ActiveMapFrame.AddLayer(aLayer)
- mipy.MapDocument.ActiveMapFrame.MoveLayer(aLayer, 0)
- print 'Finished!'
|