- 积分
- 55946
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 MeteoInfo 于 2019-5-16 14:22 编辑
CINRAD SA雷达数据读取和绘图,程序里有具体标注。
- def degree_1km(lon, lat):
- '''
- Get degree per kilometer at a location.
- '''
- dis_km = distance([lon,lon+1], [lat,lat], islonlat=True) / 1000
- return 1 / dis_km
- #Location of radar (Longitude/Latitude)
- lon = 120.9586
- lat = 31.0747
- #Get degree per kilometer at the location
- deg_1km = degree_1km(lon, lat)
- #Read data
- fn = 'D:/Temp/binary/Z_RADR_I_Z9002_20180304192700_O_DOR_SA_CAP.bin'
- f = addfile(fn)
- scan = 1
- rf = f['Reflectivity'][scan,:,:]
- azi = f['azimuthR'][scan,:]
- dis = f['distanceR'][:]/1000.0
- ele = f['elevationR'][scan,:]
- #Get x/y (kilometers) coordinates of data
- e = radians(ele)
- azi = 90 - azi
- a = radians(azi)
- nr = rf.shape[0]
- nd = rf.shape[1]
- x = zeros((nr + 1, nd))
- y = zeros((nr + 1, nd))
- for j in xrange (len(e)):
- x[j,:] = dis * cos(e[j]) * cos(a[j])
- y[j,:] = dis * cos(e[j]) * sin(a[j])
- x[nr,:] = x[0,:]
- y[nr,:] = y[0,:]
- rf1 = zeros((nr + 1, nd))
- rf1[:nr,:nd] = rf
- rf1[nr,:] = rf[0,:]
- #km to degree
- x = x * deg_1km + lon
- y = y * deg_1km + lat
- #Plot
- ax = axesm(bgcolor='b')
- #Add map layers
- geoshow('cn_province', edgecolor=None, facecolor=[230,230,230])
- geoshow('cn_province', edgecolor=[80,80,80])
- city = geoshow('cn_cities', facecolor='r', size=8)
- city.addlabels('NAME', fontname=u'黑体', fontsize=16, yoffset=18)
- #Plot radar reflectivity
- levs=[5,10,15,20,25,30,35,40,45,50,55,60,65,70]
- cols=[(255,255,255,0),(102,255,255),(0,162,232),(86,225,250),(3,207,14),\
- (26,152,7),(255,242,0),(217,172,113),(255,147,74),(255,0,0),\
- (204,0,0),(155,0,0),(236,21,236),(130,11,130),(184,108,208)]
- layer=pcolorm(x, y, rf1, levs, colors=cols, zorder=1)
- colorbar(layer, shrink=0.8, label='dBZ', labelloc='top')
- #Plot circles
- rr = array([50, 100, 150, 200])
- for r in rr:
- rd = r * deg_1km
- ax.add_circle((lon, lat), rd, edgecolor='r')
- geoshow([lat,lat], [lon-rd,lon+rd], color='r')
- geoshow([lat+rd,lat-rd], [lon,lon], color='r')
- #Set plot
- xlim(lon - rd, lon + rd)
- ylim(lat - rd, lat + rd)
- xaxis(tickin=False)
- xaxis(tickvisible=False, location='top')
- yaxis(tickin=False)
- yaxis(tickvisible=False, location='right')
- yticks(arange(29, 34, 1))
- title('Radar reflectivity')
上述脚本中x, y坐标都是2维数组,形成的是非矩形网格,用pcolor/pcolorm函数形成的是多边形图集,也就是说每个非矩形网格是一个多边形(Polygon),这样做虽然无需进行数据插值,但网格太多的话会影响绘图速度。另一种数据处理方式是先将非矩形网格点(当作散点对待)插值为矩形网格,然后再用imshow/imshowm函数生成图像进行显示。插值会需要一些时间,但图像的显示会快很多。数据插值处理的脚本:
- def degree_1km(lon, lat):
- '''
- Get degree per kilometer at a location.
- '''
- dis_km = distance([lon,lon+1], [lat,lat], islonlat=True) / 1000
- return 1 / dis_km
- #Location of radar (Longitude/Latitude)
- lon = 120.9586
- lat = 31.0747
- #Get degree per kilometer at the location
- deg_1km = degree_1km(lon, lat)
- #Read data
- fn = 'D:/Temp/binary/Z_RADR_I_Z9002_20180304192700_O_DOR_SA_CAP.bin'
- f=addfile(fn)
- scan = 1
- rf=f['Reflectivity'][scan,:,:]
- azi=f['azimuthR'][scan,:]
- dis=f['distanceR'][:]/1000.0
- ele=f['elevationR'][scan,:]
- #Get x/y (kilometers) coordinates of data
- e=radians(ele)
- azi = 90 - azi
- a=radians(azi)
- nr = rf.shape[0]
- nd = rf.shape[1]
- x=zeros(rf.shape)
- y=zeros(rf.shape)
- for j in xrange (len(e)):
- x[j,:] = dis * cos(e[j]) * cos(a[j])
- y[j,:] = dis * cos(e[j]) * sin(a[j])
- #km to degree
- x = x * deg_1km + lon
- y = y * deg_1km + lat
- #Interpolate to griddata
- rf,x,y = griddata((x,y), rf, method='nearest')
- #rf,x,y = griddata((x, y), rf, method='idw', pointnum=20)
- #rf,x,y = griddata((x, y), rf, method='idw', radius=0.1)
- #Plot
- ax = axesm(bgcolor='b')
- #Add map layers
- geoshow('cn_province', edgecolor=None, facecolor=[230,230,230])
- geoshow('cn_province', edgecolor=[80,80,80])
- city = geoshow('cn_cities', facecolor='r', size=8)
- city.addlabels('NAME', fontname=u'黑体', fontsize=16, yoffset=18)
- #Plot radar reflectivity
- levs=[5,10,15,20,25,30,35,40,45,50,55,60,65,70]
- cols=[(255,255,255,0),(102,255,255),(0,162,232),(86,225,250),(3,207,14),\
- (26,152,7),(255,242,0),(217,172,113),(255,147,74),(255,0,0),\
- (204,0,0),(155,0,0),(236,21,236),(130,11,130),(184,108,208)]
- layer = imshowm(x, y, rf, levs, colors=cols, zorder=1)
- colorbar(layer, shrink=0.8, label='dBZ', labelloc='top')
- #Plot circles
- rr = array([50, 100, 150, 200])
- for r in rr:
- rd = r * deg_1km
- ax.add_circle((lon, lat), rd, edgecolor='r')
- geoshow([lat,lat], [lon-rd,lon+rd], color='r')
- geoshow([lat+rd,lat-rd], [lon,lon], color='r')
- #Set plot
- xlim(lon - rd, lon + rd)
- ylim(lat - rd, lat + rd)
- xaxis(tickin=False)
- xaxis(tickvisible=False, location='top')
- yaxis(tickin=False)
- yaxis(tickvisible=False, location='right')
- yticks(arange(29, 34, 1))
- title('Radar reflectivity')
|
|