- 积分
- 55950
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
数据来自此贴:http://bbs.06climate.com/forum.p ... &extra=page%3D2
这里示例用MeteoInfoLab脚本读取站点数据并匹配经纬度,绘制散点图,插值为格点数据并绘制等值线图的过程。
- #Set file name
- stfn = 'E:/Temp/station.txt'
- datafn = 'E:/Temp/201511_auto_hr.txt'
- tstr = '2015110101'
- #Read station id, lon, lat
- st_table = readtable(stfn, headerlines=-1, format='%s%2f')
- stids = st_table['Col_0']
- lons = st_table['Col_1']
- lats = st_table['Col_2']
- #Read station temperature data at a specific time
- stations = []
- temp = []
- lon = []
- lat = []
- dataf = open(datafn)
- for line in dataf:
- a = line.split()
- if a[1] == tstr:
- if a[0] in stids:
- idx = stids.index(a[0])
- stations.append(a[0])
- temp.append(float(a[3]))
- lon.append(lons[idx])
- lat.append(lats[idx])
- dataf.close()
- temp = array(temp)
- temp[temp==-9997] = nan
- #Plot
- axesm()
- ltaiwan = shaperead('D:/Temp/Map/taiwan.shp')
- geoshow(ltaiwan, edgecolor='k')
- layer = scatterm(lon, lat, temp, 10)
- colorbar(layer)
- xlim(119.8, 122.2)
- ylim(21.8, 25.5)
- #Set file name
- stfn = 'E:/Temp/station.txt'
- datafn = 'E:/Temp/201511_auto_hr.txt'
- tstr = '2015110101'
- #Read station id, lon, lat
- st_table = readtable(stfn, headerlines=-1, format='%s%2f')
- stids = st_table['Col_0']
- lons = st_table['Col_1']
- lats = st_table['Col_2']
- #Read station temperature data at a specific time
- stations = []
- temp = []
- lon = []
- lat = []
- dataf = open(datafn)
- for line in dataf:
- a = line.split()
- if a[1] == tstr:
- if a[0] in stids:
- idx = stids.index(a[0])
- stations.append(a[0])
- temp.append(float(a[3]))
- lon.append(lons[idx])
- lat.append(lats[idx])
- dataf.close()
- temp = array(temp)
- temp[temp==-9997] = nan
- #Interpolate to grid data
- lon = array(lon)
- lat = array(lat)
- x = arange(119.8, 122.2, 0.1)
- y = arange(21.8, 25.5, 0.1)
- gtemp,xx,yy = griddata([lon, lat], temp, xi=[x, y], method='idw')
- #Plot
- axesm()
- ltaiwan = shaperead('D:/Temp/Map/taiwan.shp')
- tw_city = shaperead('D:/Temp/Map/taiwan_city.shp')
- tw_xc = shaperead('D:/Temp/Map/taiwan_xc.shp')
- geoshow(ltaiwan, edgecolor='gray')
- geoshow(tw_xc, size=4, edgecolor='k', labelfield='NAME', \
- fontname=u'楷体', fontsize=14, yoffset=15)
- geoshow(tw_city, facecolor='b', edgecolor='k', size=6, labelfield='NAME', \
- fontname=u'楷体', fontsize=16, yoffset=15)
- tw_city.movelabel(u'台北', 0, -25)
- layer = contourfm(xx, yy, gtemp, 20)
- masklayer(ltaiwan, [layer])
- colorbar(layer)
- xlim(119.8, 122.2)
- ylim(21.8, 25.5)
|
|