- 积分
- 55945
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 MeteoInfo 于 2022-11-24 11:18 编辑
站点数据绘制等值线需要首先将站点数据插值为格点数据,MeteoInfo中提供了反距离权法(IDW)和cressman两个方法,其中IDW方法可以有插值半径的选项。这里示例读取一个MICAPS第一类数据(地面全要素观测),获取6小时累积降水数据(Precipitation6h),然后用站点数据的griddata函数将站点数据插值为格点数据,再利用contourfm函数创建等值线填色图层(等值线间隔和颜色可以自定义)。
脚本程序(经纬度投影):
- #Read station data
- fn = os.path.join(migl.get_sample_folder(), 'MICAPS', '10101414.000')
- f = addfile_micaps(fn)
- pr = f['Precipitation6h'][:]
- lon = f['Longitude'][:]
- lat = f['Latitude'][:]
- #griddata function - interpolate
- x = arange(75, 135, 0.5)
- y = arange(18, 55, 0.5)
- prg, gx, gy = griddata((lon, lat), pr, xi=(x, y), method='cressman', radius=[7,4,2,1])
- #Plot
- figure(figsize=[700, 400], newfig=False)
- axesm()
- geoshow('cn_province', edgecolor='lightgray')
- bou1_layer = geoshow('cn_border', facecolor=(0,0,255))
- city_layer = geoshow('cn_cities', facecolor='r', size=4)
- city_layer.addlabels('NAME', fontname=u'楷体', fontsize=16, yoffset=15, avoidcoll=False)
- china_layer = geoshow('china', visible=False)
- city_layer.movelabel(u'西宁', -15)
- levs = [0.1, 1, 2, 5, 10, 20, 25, 50, 100]
- cols = [(255,255,255),(170,240,255),(120,230,240),(200,220,50),(240,220,20),(255,120,10),(255,90,10), \
- (240,40,0),(180,10,0),(120,10,0)]
- layer = contourf(x, y, prg, levs, colors=cols)
- masklayer(china_layer, [layer])
- colorbar(layer)
- xlim(72, 136)
- ylim(16, 55)
- text(95, 52, u'全国降水量实况图', fontname=u'黑体', fontsize=16)
- text(95, 50, u'(2010-10-14 08:00 至 2010-10-14 14:00)', fontname=u'黑体', fontsize=14)
- #Add south China Sea
- sc_layer = bou1_layer.clone()
- axesm(position=[0.14,0.18,0.15,0.2], axison=False, frameon=True)
- geoshow(sc_layer, facecolor=(0,0,255))
- xlim(106, 123)
- ylim(2, 23)
- #savefig('D:/Temp/test/test_pre.png')
脚本程序(Lambert投影):
- #Set data folders
- basedir = 'D:/MyProgram/Distribution/java/MeteoInfo/MeteoInfo'
- datadir = os.path.join(basedir, 'sample/MICAPS')
- #Read station data
- f = addfile_micaps(os.path.join(datadir, '10101414.000'))
- lon = f['Longitude'][:]
- lat = f['Latitude'][:]
- pr = f['Precipitation6h'][:]
- #griddata function - interpolate
- x = arange(75, 135, 0.5)
- y = arange(18, 55, 0.5)
- #prg = griddata((lon, lat), pr, xi=(x, y), method='idw', radius=3)[0]
- prg = griddata((lon, lat), pr, xi=(x, y), method='cressman', radius=[10,8,6,4])[0]
- #Plot
- proj = projinfo(proj='lcc', lon_0=105, lat_1=25, lat_2=47)
- axesm(projinfo=proj, position=[0, 0, 0.9, 1], axison=False, gridlabel=False, frameon=False)
- geoshow('cn_province', edgecolor='lightgray')
- bou1_layer = geoshow('cn_border', facecolor=(0,0,255))
- geoshow('cn_cities', facecolor='r', size=4, labelfield='NAME', fontname=u'楷体', fontsize=16, yoffset=15)
- china_layer = geoshow('china', visible=False)
- levs = [0.1, 1, 2, 5, 10, 20, 25, 50, 100]
- cols = [(255,255,255),(170,240,255),(120,230,240),(200,220,50),(240,220,20),(255,120,10),(255,90,10), \
- (240,40,0),(180,10,0),(120,10,0)]
- layer = contourfm(x, y, prg, levs, colors=cols)
- masklayer(china_layer, [layer])
- colorbar(layer, shrink=0.5, aspect=15)
- axism([78, 130, 14, 53])
- text(95, 53, u'全国降水量实况图', fontname=u'黑体', fontsize=18)
- text(95, 51, u'(2010-10-14 08:00 至 2010-10-14 14:00)', fontname=u'黑体', fontsize=16)
- #Add south China Sea
- sc_layer = bou1_layer.clone()
- axesm(position=[0.1,0.05,0.15,0.2], axison=False, frameon=True)
- geoshow(sc_layer, facecolor=(0,0,255))
- xlim(106, 123)
- ylim(2, 23)
- #savefig('D:/Temp/test/rain_test.png', 800, 800)
运行结果:
|
|