爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 7661|回复: 13

MeteoInfoLab脚本示例:站点数据读取插值

[复制链接]

新浪微博达人勋

发表于 2016-3-22 15:54:08 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
数据来自此贴:http://bbs.06climate.com/forum.p ... &extra=page%3D2

这里示例用MeteoInfoLab脚本读取站点数据并匹配经纬度,绘制散点图,插值为格点数据并绘制等值线图的过程。
  1. #Set file name
  2. stfn = 'E:/Temp/station.txt'
  3. datafn = 'E:/Temp/201511_auto_hr.txt'
  4. tstr = '2015110101'
  5. #Read station id, lon, lat
  6. st_table = readtable(stfn, headerlines=-1, format='%s%2f')
  7. stids = st_table['Col_0']
  8. lons = st_table['Col_1']
  9. lats = st_table['Col_2']
  10. #Read station temperature data at a specific time
  11. stations = []
  12. temp = []
  13. lon = []
  14. lat = []
  15. dataf = open(datafn)
  16. for line in dataf:
  17.     a = line.split()
  18.     if a[1] == tstr:
  19.         if a[0] in stids:
  20.             idx = stids.index(a[0])
  21.             stations.append(a[0])
  22.             temp.append(float(a[3]))
  23.             lon.append(lons[idx])
  24.             lat.append(lats[idx])
  25. dataf.close()

  26. temp = array(temp)
  27. temp[temp==-9997] = nan
  28. #Plot
  29. axesm()
  30. ltaiwan = shaperead('D:/Temp/Map/taiwan.shp')
  31. geoshow(ltaiwan, edgecolor='k')
  32. layer = scatterm(lon, lat, temp, 10)
  33. colorbar(layer)
  34. xlim(119.8, 122.2)
  35. ylim(21.8, 25.5)

station_taiwan-1.png

  1. #Set file name
  2. stfn = 'E:/Temp/station.txt'
  3. datafn = 'E:/Temp/201511_auto_hr.txt'
  4. tstr = '2015110101'
  5. #Read station id, lon, lat
  6. st_table = readtable(stfn, headerlines=-1, format='%s%2f')
  7. stids = st_table['Col_0']
  8. lons = st_table['Col_1']
  9. lats = st_table['Col_2']
  10. #Read station temperature data at a specific time
  11. stations = []
  12. temp = []
  13. lon = []
  14. lat = []
  15. dataf = open(datafn)
  16. for line in dataf:
  17.     a = line.split()
  18.     if a[1] == tstr:
  19.         if a[0] in stids:
  20.             idx = stids.index(a[0])
  21.             stations.append(a[0])
  22.             temp.append(float(a[3]))
  23.             lon.append(lons[idx])
  24.             lat.append(lats[idx])
  25. dataf.close()

  26. temp = array(temp)
  27. temp[temp==-9997] = nan
  28. #Interpolate to grid data
  29. lon = array(lon)
  30. lat = array(lat)
  31. x = arange(119.8, 122.2, 0.1)
  32. y = arange(21.8, 25.5, 0.1)
  33. gtemp,xx,yy = griddata([lon, lat], temp, xi=[x, y], method='idw')
  34. #Plot
  35. axesm()
  36. ltaiwan = shaperead('D:/Temp/Map/taiwan.shp')
  37. tw_city = shaperead('D:/Temp/Map/taiwan_city.shp')
  38. tw_xc = shaperead('D:/Temp/Map/taiwan_xc.shp')
  39. geoshow(ltaiwan, edgecolor='gray')
  40. geoshow(tw_xc, size=4, edgecolor='k', labelfield='NAME', \
  41.     fontname=u'楷体', fontsize=14, yoffset=15)
  42. geoshow(tw_city, facecolor='b', edgecolor='k', size=6, labelfield='NAME', \
  43.     fontname=u'楷体', fontsize=16, yoffset=15)
  44. tw_city.movelabel(u'台北', 0, -25)
  45. layer = contourfm(xx, yy, gtemp, 20)
  46. masklayer(ltaiwan, [layer])
  47. colorbar(layer)
  48. xlim(119.8, 122.2)
  49. ylim(21.8, 25.5)

station_taiwan.png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-3-22 16:34:05 | 显示全部楼层
{:eb502:}{:eb502:}
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2016-3-23 10:42:37 | 显示全部楼层
哇,看起來好漂亮喔!
可是我沒有MeteoInfo這個程式。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-3-23 10:43:20 | 显示全部楼层
哇,看起來好漂亮喔!
可是我沒有MeteoInfo這個程式。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-3-23 10:52:06 | 显示全部楼层
addname 发表于 2016-3-23 10:43
哇,看起來好漂亮喔!
可是我沒有MeteoInfo這個程式。

可以在这里免费下载使用:http://www.meteothinker.com/
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-3-23 11:11:37 | 显示全部楼层
MeteoInfo 发表于 2016-3-23 10:52
可以在这里免费下载使用:http://www.meteothinker.com/

好的,謝謝您,來下載用看看!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-3-24 11:06:27 | 显示全部楼层
腻害!!!请教王老师,taiwan_xc.shp文件是怎么制作的?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-3-24 11:16:56 | 显示全部楼层
clare 发表于 2016-3-24 11:06
腻害!!!请教王老师,taiwan_xc.shp文件是怎么制作的?

从全国县城shape文件选择性输出的
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-1-11 10:43:55 | 显示全部楼层
{:eb502:}
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2017-3-17 09:04:37 | 显示全部楼层
{:eb502:}{:eb502:}正在学习画散点图
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表