用MeteoInfoLab脚本读取数据会更加灵活方便,比如读取定点某个时间范围多个变量的值。可以参考下面的脚本程序:
- fn = 'C:/Temp/nww3.t00z.grib.grib2'
- f = addfile(fn)
- lon = 160.63
- lat = 50.62
- lonlim = str(lon)
- latlim = str(lat)
- tn = f.timenum()
- hline = 'Time,Lon,Lat,dwws,shcwwss'
- print hline
- for i in range(tn):
- t = f.gettime(i)
- dwws = f['Direction_of_wind_waves_surface'][i,latlim,lonlim]
- shcwwss = f['Significant_height_of_combined_wind_waves_and_swell_surface'][i,latlim,lonlim]
- data = t.strftime('%Y%m%d') + ',%.2f,%.2f,%.2f,%.2f' % (lon,lat,dwws,shcwwss)
- print data
运行后输出:
Time,Lon,Lat,dwws,shcwwss
2017080100,160.63,50.62,150.12,1.64
2017080103,160.63,50.62,149.96,1.67
2017080106,160.63,50.62,149.77,1.70
2017080109,160.63,50.62,149.48,1.78
2017080112,160.63,50.62,148.91,1.88
2017080115,160.63,50.62,148.06,1.95
2017080118,160.63,50.62,147.03,1.97
2017080121,160.63,50.62,145.68,1.99
2017080200,160.63,50.62,143.92,2.09
2017080203,160.63,50.62,142.59,2.20
2017080206,160.63,50.62,142.03,2.22
2017080209,160.63,50.62,141.88,2.15
2017080212,160.63,50.62,141.85,2.05
2017080215,160.63,50.62,141.70,1.94
2017080218,160.63,50.62,141.43,1.83
2017080221,160.63,50.62,141.25,1.72
2017080300,160.63,50.62,141.64,1.64
2017080303,160.63,50.62,142.98,1.58
2017080306,160.63,50.62,146.00,1.54
2017080309,160.63,50.62,150.28,1.52
2017080312,160.63,50.62,154.97,1.50
2017080315,160.63,50.62,160.59,1.50
2017080318,160.63,50.62,164.16,1.48
2017080321,160.63,50.62,165.68,1.45
2017080400,160.63,50.62,166.99,1.42
2017080403,160.63,50.62,167.75,1.39
2017080406,160.63,50.62,168.23,1.35
2017080409,160.63,50.62,168.44,1.33
2017080412,160.63,50.62,168.51,1.31
2017080415,160.63,50.62,168.44,1.30
2017080418,160.63,50.62,168.50,1.29
2017080421,160.63,50.62,168.61,1.30
2017080500,160.63,50.62,169.09,1.33
2017080503,160.63,50.62,170.05,1.37
2017080506,160.63,50.62,171.23,1.44
2017080509,160.63,50.62,172.36,1.53
2017080512,160.63,50.62,173.39,1.65
2017080515,160.63,50.62,174.43,1.78
2017080518,160.63,50.62,175.25,1.88
2017080521,160.63,50.62,175.78,1.96
2017080600,160.63,50.62,176.04,2.01
2017080603,160.63,50.62,176.27,2.03
2017080606,160.63,50.62,176.57,2.05
2017080609,160.63,50.62,176.46,2.06
2017080612,160.63,50.62,176.21,2.15
2017080615,160.63,50.62,175.80,2.41
2017080618,160.63,50.62,175.20,2.76
2017080621,160.63,50.62,174.49,2.99
2017080700,160.63,50.62,173.66,3.04
2017080703,160.63,50.62,172.85,2.95
2017080706,160.63,50.62,171.86,2.82
2017080709,160.63,50.62,170.91,2.70
2017080712,160.63,50.62,169.97,2.59
2017080715,160.63,50.62,169.11,2.48
2017080718,160.63,50.62,168.61,2.39
2017080721,160.63,50.62,168.80,2.32
2017080800,160.63,50.62,169.70,2.26
2017080803,160.63,50.62,170.77,2.23
2017080806,160.63,50.62,171.13,2.20
2017080809,160.63,50.62,170.60,2.14
2017080812,160.63,50.62,169.60,2.07
|