matplotlib中PPI反射率数据的交互式显示

2024-05-16 12:04:46 发布

您现在位置:Python中文网/ 问答频道 /正文

作为我们项目的一部分,我们需要在平面位置指示器(PPI)图像中显示雷达反射率数据以及纬度和经度。我正在使用plot_ppi_map功能在地理地图上绘制ppi体积扫描。下面给出了我的程序的示例输出

Sample output of the Program

我可以在状态栏的左下角获得纬度和经度值,但无法显示雷达反射率的值。根据以下代码生成雷达反射率值

display = pyart.graph.RadarMapDisplay(radar)

rfdata = display._get_data(field = 'reflectivity', sweep = 0,mask_tuple = None,filter_transitions = True,gatefilter=None)

尝试使用上面提到的Example,并尝试使用ax.format_coord()处理从display派生的反射率数据。_获取_数据并获取大小为(3611000)的反射率数据。但获取索引错误如下所述(附上屏幕截图)

索引器:索引176327超出大小为361的轴0的界限

Error message

我使用以下代码片段在地图上绘制反射率数据。 我在这里使用的投影是方位向的

    class Formatter(object):
        def __init__(self, im):
            self.im = im
        def __call__(self, x, y):
            z = self.im.get_array()[int(y), int(x)]
            return 'x={:.01f}, y={:.01f}, z={:.01f}'.format(x, y, z)  

    projection = ccrs.AzimuthalEquidistant(central_latitude=radar.latitude['data'][0],central_longitude=radar.longitude['data'][0])

    display.plot_ppi_map('reflectivity', 0, vmin=-31.5, vmax=95.5,
                             min_lon=min_longitude, max_lon=max_longitude, min_lat=min_latitude, max_lat=max_latitude,
                             lon_lines=np.arange(77, 85, 1), resolution='110m',shapefile = shapefile_path,ax=ax,
                             shapefile_kwargs = {'linewidth':1, 'edgecolor':'black', 'facecolor':"#00000000"},
                             cmap = dwrmpt,norm=norm, embelish = False,
                             lat_lines=np.arange(12, 20, 1), projection=projection,
                             fig=fig, lat_0=radar.latitude['data'][0],
                             lon_0=radar.longitude['data'][0])
im = ax.imshow(rfdata, interpolation='none')
ax.format_coord = Formatter(im)
plt.show()

只要数据可用,我就应该显示反射率数据

我需要显示反射率值以及纬度和经度。请告知


Tags: 数据selfdatadisplayaxminmaxlon