- 积分
- 55955
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 MeteoInfo 于 2016-10-18 10:05 编辑
这个脚本示例读取文本格式的闪电数据,读出每条闪电记录的经纬度和强度,在地图上绘制出每个闪电的位置,并用符号和颜色区分强度正负。
数据格式如下:
0 2009-06-06 00:01:16.6195722 纬度=35.0297 经度=114.8923 强度=23.4 陡度=9.1 误差=71.9 定位方式:四站算法
1 2009-06-06 01:34:58.5911760 纬度=34.4243 经度=115.6057 强度=-1.3 陡度=-0.4 误差=0.0 定位方式:二站振幅
2 2009-06-06 01:36:59.6324818 纬度=35.9314 经度=114.9388 强度=-35.2 陡度=-6.1 误差=0.0 定位方式:三站混合
3 2009-06-06 01:54:25.2727088 纬度=34.4163 经度=115.6121 强度=-1.9 陡度=-0.3 误差=0.0 定位方式:二站振幅
4 2009-06-06 01:58:35.1179896 纬度=35.3270 经度=106.5536 强度=-384.1 陡度=-80.6 误差=0.0 定位方式:二站振幅
5 2009-06-06 01:59:15.9764295 纬度=34.5339 经度=114.4466 强度=58.4 陡度=26.7 误差=0.0 定位方式:三站混合
7 2009-06-06 02:00:35.0869527 纬度=34.3934 经度=115.5976 强度=-3.3 陡度=-1.0 误差=0.0 定位方式:二站振幅
8 2009-06-06 02:00:43.0728269 纬度=34.4124 经度=115.7238 强度=-5.3 陡度=-3.1 误差=0.0 定位方式:二站混合
9 2009-06-06 02:00:43.2227403 纬度=34.4131 经度=115.7171 强度=-8.4 陡度=-4.1 误差=0.0 定位方式:二站混合
10 2009-06-06 02:02:21.5951061 纬度=34.3817 经度=115.6268 强度=-7.2 陡度=-1.6 误差=0.0 定位方式:二站振幅
脚本程序:
- fn = 'D:/Temp/ascii/lighting/2009_06_06.txt'
- tf = open(fn)
- lats = []
- lons = []
- vs = []
- for aline in tf:
- datalist = aline.split()
- lat = float(datalist[3].split('=')[1])
- lon = float(datalist[4].split('=')[1])
- v = float(datalist[5].split('=')[1])
- lats.append(lat)
- lons.append(lon)
- vs.append(v)
- lon = array(lons)
- lat = array(lats)
- v = array(vs)
- axesm()
- mlayer = shaperead('D:/Temp/map/bou2_4p.shp')
- geoshow(mlayer)
- ss = makesymbolspec('point', {'value':(-10000,0), 'color':'b', 'marker':'m', 'size':6}, \
- {'value':(0,10000), 'color':'r', 'marker':'+', 'size':6})
- layer = scatterm(lon, lat, v, symbolspec=ss)
- xlim(90, 130)
- ylim(20, 50)
- title(u'闪电位置图', fontname=u'黑体', fontsize=18)
计算1*1度格点闪电次数并绘图:
- #Read lighting data
- fn = 'D:/Temp/ascii/lighting/2009_06_06.txt'
- tf = open(fn)
- lats = []
- lons = []
- vs = []
- for aline in tf:
- datalist = aline.split()
- lat = float(datalist[3].split('=')[1])
- lon = float(datalist[4].split('=')[1])
- v = float(datalist[5].split('=')[1])
- lats.append(lat)
- lons.append(lon)
- vs.append(v)
- lon = array(lons)
- lat = array(lats)
- v = array(vs)
- #Get grid lighting number
- glon = arange(90, 131, 1)
- glat = arange(20, 51, 1)
- gv = griddata((lon, lat), v, xi=(glon, glat), method='inside_count')[0]
- #Plot
- axesm()
- mlayer = shaperead('D:/Temp/map/bou2_4p.shp')
- geoshow(mlayer)
- levs = [1,2,5,10,20,50,100,200,300,400,500,600,700,800,900,1000]
- #layer = contourfm(glon, glat, gv, levs, cmap='WhBlGrYeRe')
- layer = imshowm(glon, glat, gv, levs, cmap='WhBlGrYeRe')
- colorbar(layer)
- title('Lighting number')
统计一日内每小时闪电次数并绘制逐时变化图:
- #Read lighting data
- fn = 'D:/Temp/ascii/lighting/2009_06_06.txt'
- tf = open(fn)
- times = []
- nums = []
- for h in range(0, 24):
- times.append(datetime.datetime(2009,6,6,h))
- nums.append(0)
- for aline in tf:
- datalist = aline.split()
- h = int(datalist[2].split(':')[0])
- nums[h] = nums[h] + 1
- #Plot
- plot(times, nums, '-ro')
- xaxis(axistype='time')
- ylabel('Lighting number')
- xlim(times[0], times[-1])
- title('Lighting number hourly variation in ' + times[0].strftime('%Y/%m/%d'))
|
|