- 积分
- 1461
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-1-30
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
王老师您好,利用您给的脚本,希望添加上如其中一张图所示的站号,结果位置错乱了,要怎样改才能实现呢,谢谢!
#Get file names
datafn = 'D:/zhd/ascii/t1601.txt'
stfn = 'D:/zhd/ascii/st_160.csv'
#Get years
years = []
for i in range(1951, 2017):
years.append(i)
yearn = len(years)
stn = 160
#Read temperature data of 160 stations from data file
temp = asciiread(datafn, shape=(yearn,stn))
temp = temp * 0.1
#Get temperature data of 2015
year = 2015
yearidx = years.index(year)
temp = temp[yearidx,:]
#Read station name and lon/lat
table = readtable(stfn, delimiter=',', format='%i%2s%2f')
stnames = table['Name']
lat = table['LAT']
lon = table['LON']
#To grid data
x = arange(70, 140, 0.5)
y = arange(15, 58, 0.5)
gtemp,gx,gy = griddata((lon, lat), temp, xi=(x, y), method='idw', pointnum=4)
#Plot
axesm()
bou2_layer = shaperead('D:/zhd/map/bou2_4p.shp')
bou1_layer = shaperead('D:/zhd/map/bou1_4l.shp')
china_layer = shaperead('D:/zhd/map/china.shp')
geoshow(bou2_layer, edgecolor='lightgray')
geoshow(bou1_layer, facecolor=(0,0,255))
geoshow(china_layer, visible=False)
layer = contourfm(x, y, gtemp, 20)
slayer = scatterm(lon, lat, temp, colors=['k'], size=4)
layer.addfield('Name', 'string', stnames)
layer.addlabels('Name', fontname=u'楷体', fontsize=14, yoffset=15)
masklayer(china_layer, [layer])
title('Temperature (' + str(year) + '-01)')
colorbar(layer)
xlim(72, 136)
ylim(16, 55)
#Add south China Sea
sc_layer = bou1_layer.clone()
axesm(position=[0.14,0.18,0.15,0.2], axison=False)
geoshow(sc_layer, facecolor=(0,0,255))
xlim(106, 123)
ylim(2, 23)
|
-
-
|