- 积分
- 93
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-11-15
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2014-4-25 15:29:12
|
显示全部楼层
多谢王老师的细心指导。4个NC文件时次 一样。我把tidx改小错误还是一样。如果注释掉那两行,错误变成如下
全部代码如下:
#---- 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 = "F:\\meteoInfo\\"
MapDir = BaseDir + "Map\\"
DataDir = "F:\\97111109\\nc\\"
#---- 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
DataAir = MeteoDataInfo()
DataUwnd = MeteoDataInfo()
DataVwnd = MeteoDataInfo()
DataRhum = MeteoDataInfo()
DataAir.OpenNCData(DataDir + "air.2011.nc")
DataUwnd.OpenNCData(DataDir + "uwnd.2011.nc")
DataVwnd.OpenNCData(DataDir + "vwnd.2011.nc")
DataRhum.OpenNCData(DataDir + "rhum.2011.nc")
#---- Calculation
#---- Set date to June 23
tIdx = 872
DataAir.TimeIndex = tIdx;
DataUwnd.TimeIndex = tIdx;
DataVwnd.TimeIndex = tIdx;
DataRhum.TimeIndex = tIdx;
#---- Set level to 700hPa
lIdx = 2
DataAir.LevelIndex = lIdx;
DataUwnd.LevelIndex = lIdx;
DataVwnd.LevelIndex = lIdx;
DataRhum.LevelIndex = lIdx;
#---- Get grid data
air = DataAir.GetGridData("air")
uwnd = DataUwnd.GetGridData("uwnd")
vwnd = DataVwnd.GetGridData("vwnd")
rhum = DataRhum.GetGridData("rhum")
#---- Calculate
prs = 850
g = 9.8
es = 6.112*DataMath.Exp(17.67*(air-273.16)/(air-29.65))
qs = 0.62197*es/(prs-0.378*es)
q = qs*rhum/100
qhdivg = DataMath.Hdivg(q*uwnd/g,q*vwnd/g)
qv = rhum*es/100
uv = DataMath.Magnitude(uwnd, vwnd)
uvq = uv*qv/(9.8*1000)
#---- Plot data
myApp.SetDrawType("shaded")
myApp.Display(qhdivg)
myApp.MoveLayerToTop("country1.shp")
myApp.ZoomLonLatEx(0,360,-90.1,90.1)
#aTime = DataAir.GetTime()
#myApp.SetTitle("Water Vapor Flux Divergence - " + aTime.ToString("yyyy-MM-dd"))
myApp.MapLayout.PaintGraphics()
Application.Run(myApp) |
|