格点插值为站点数据批量处理

可以利用脚本程序(MeteoInfoLab环境下)来批量处理格点数据插值为站点数据。示例脚本程序如下,已经注释得很清楚了,这里就不多说了。

 

脚本程序:

#Open station file as table data
stdata = readtable('D:/Temp/China_Prec_2010101420.csv', delimiter=',', format='%s%f%f')
x = stdata['Longitude']
y = stdata['Latitude']
#Add data file
f = addfile('D:/Temp/GrADS/model.ctl')
#Get data variable
psv = f['PS']
#Get time dimension length
tn = psv.dimlen(0)
#Loop
for i in range(0, tn):
    #Get dimension array
    ps = psv[i,(10,60),(60,140)]
    #Interpolate to stations
    ps_st = ps.tostation(x, y)
    #Add column to table data
    colname = 'PS' + str(i)
    stdata.addcol(colname, '%d', ps_st)

#Save table data to a file
fn = 'D:/Temp/test_st.csv'
stdata.savefile(fn)
print 'Finish...'

 

posted on 2015-05-11 14:36  yaqiang  阅读(1746)  评论(0编辑  收藏  举报

导航