- 积分
- 1461
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-1-30
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2016-6-16 13:59:47
|
显示全部楼层
是您给的脚本示例代码,我只是改了路径和文件名
#Get file names
datafn = 'D:/Temp/r1605.txt'
stfn = 'D:/Temp/st_1602.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:/Temp/map/bou2_4p.shp')
bou1_layer = shaperead('D:/Temp/map/bou1_4l.shp')
china_layer = shaperead('D:/Temp/map/hdqyt.wmp')
geoshow(bou2_layer, edgecolor='lightgray')
geoshow(bou1_layer, facecolor=(0,0,255))
geoshow(china_layer, visible=True)
layer = contourfm(x, y, gtemp, 20)
slayer = scatterm(lon, lat, temp, colors=['k'], size=4)
slayer.addfield('Name', 'string', stnames)
slayer.addlabels('Name', fontname=u'楷体', fontsize=14, yoffset=15,avoidcoll=False)
masklayer(china_layer, [layer])
#title('Temperature (' + str(year) + '-01)')
ylabel(u'Y轴', fontname=u'宋体', fontsize=16)
xlabel(u'X轴', fontname=u'宋体', fontsize=16)
#axis([0,5,0,20])
title(u'平均温度分布图', fontname=u'黑体', fontsize=18, bold=False, color='red')
text(5, 12, u'标注', fontname=u'楷体', fontsize=18)
colorbar(layer)
#xlim(113, 125)
#ylim(21, 35)
#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) |
|