- 积分
- 55949
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 MeteoInfo 于 2020-11-11 17:20 编辑
演示MeteoInfoLab读取中央台下发的台风最佳路径文件并绘图。数据文件可以在这里下载:http://tcdata.typhoon.gov.cn/zjljsjj_zlhq.html
- # Read typhoon data file
- fn = 'D:/Temp/ascii/CH2015BST.txt'
- tf = open(fn)
- lons = []
- lats = []
- prss = []
- for line in tf:
- print line
- data = line.split()
- pn = int(data[2])
- for i in range(pn):
- line = tf.readline()
- data = line.split()
- lat = float(data[2])
- lats.append(lat * 0.1)
- lon = float(data[3])
- lons.append(lon * 0.1)
- t = data[0]
- prs = float(data[4])
- prss.append(prs)
- lons.append(nan)
- lats.append(nan)
- prss.append(nan)
- # Plot
- axesm()
- lworld = shaperead('D:/Temp/map/country1.shp')
- geoshow(lworld, facecolor=[200,200,200])
- plotm(lons, lats, linewidth=2)
- #geoshow(lats, lons, color='r')
- layer = scatterm(lons, lats, prss)
- colorbar(layer, shrink=0.8)
- xlim(100, 210)
- ylim(0, 60)
- title('Typhoon pathway')
台风路径线条不同颜色表示风速:
- #Create typhoon layer
- layer = maplayer(shapetype='line')
- # Read typhoon data file
- fn = 'D:/Temp/ascii/CH2015BST.txt'
- tf = open(fn)
- lons = []
- lats = []
- prss = []
- wss = []
- for line in tf:
- print line
- data = line.split()
- pn = int(data[2])
- for i in range(pn):
- line = tf.readline()
- data = line.split()
- lat = float(data[2])
- lats.append(lat * 0.1)
- lon = float(data[3])
- lons.append(lon * 0.1)
- t = data[0]
- prs = float(data[4])
- prss.append(prs)
- ws = float(data[5])
- wss.append(ws)
- layer.addshape(lons, lats, z=prss, m=wss)
- lons = []
- lats = []
- prss = []
- wss = []
- #Set typhoon layer legend
- levs = arange(5, 61, 5)
- cols = makecolors(len(levs) + 1)
- ls = makesymbolspec('line', levels=levs, colors=cols, field='Geometry_M', size=2)
- # Plot
- axesm()
- geoshow('country', facecolor=[200,200,200])
- geoshow(layer, symbolspec=ls)
- colorbar(layer, shrink=0.8, label='Wind speed (m/s)')
- xlim(100, 210)
- ylim(0, 60)
- title('Typhoon pathway with wind speed')
|
|