Plotting just one sector

61 views
Skip to first unread message

Ariel

unread,
Mar 14, 2022, 12:19:40 PM3/14/22
to Py-ART Users

I'm using Wradlib and Pyart. Wradlib was use for dataProcessing and Pyart is using for plotting data. 

So, I need plot a reduced area from my data. In the docs are a code that use min_lat, min_lot, mas_lat, max_lon for plotting one sector, but I can't reproduce that

My code is 

def pruebas_multiplot():
radar_name= "/home/arielcg/Documentos/Tesis/src/data/radar/2017/qro_radar_acum.nc"
radar= pr.get_radar(radar_name)
radar_subplots= list( radar.fields.keys() )

display = pyart.graph.RadarMapDisplay( radar )
fig = plt.figure(figsize=(25,25))

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

n= 3
plot(radar,display,fig,n,radar_subplots,projection)
pr.plt.savefig("prueba")

def plot(radar,display,fig,n,radar_subplots,projection):
m= len(radar_subplots)/n
lat_max= 19.8; lat_min= 21.7
lon_max= -100.59; lon_min= -99.0
for i in range( len(radar_subplots) ):
try:
ax = fig.add_subplot(n,m, i, projection=projection)
lat_0= radar.latitude['data'][0]
lon_0= radar.longitude['data'][0]
lat, lon, _ = radar.get_gate_lat_lon_alt(0)
lat_lines=np.linspace(lat_min, lat_max, 10)
lon_lines=np.linspace(lon_min, lon_max, 10)

display.plot_ppi_map(radar_subplots[i],
max_lat=np.amax(lat), min_lat=lat.min(),
min_lon=np.amin(lon), max_lon=lon.max(),
#width=100, height=100,
lat_lines= lat_lines,
lon_lines= lon_lines,
lat_0=lat_0,
lon_0=lon_0,
resolution='10m',
vmin=0, vmax=200,
projection=projection,
fig=fig, ax=ax,
title=f"Acumulado del mes {radar_subplots[i]}",
cmap=cm.get_cmap('GnBu'))
display.plot_point(lon_0, lat_0,label_text='Radar')
ax.xaxis.set_tick_params(rotation=35)
middle_points= pr.get_middle_points( lon_lines,lat_lines )
i= 0
for point in middle_points:
display.plot_point(point[0], point[1] , 'o',label_text='', color='r')
i+= 1
except Exception as e:
print(radar_subplots[i])
print(f"Revisa {e}")
continue

if __name__ == '__main__':
pruebas_multiplot()


And I get the file adjunt, but I want only the sector where the grid are plotter.

How can reduce the plot area only for the region I want??

Note that qro_radar_acum.nc is a file that I create but the file base is a iris_base_radar

thnks a lot
prueba.png

sherma...@gmail.com

unread,
Mar 18, 2022, 12:18:23 PM3/18/22
to Py-ART Users
Is the region you want just the red dot section? For your max_lat and lon, and min_lat and long arguments, your setting them it looks like to the lat and lon max and mins from np.amax(lat) etc from radar.get_lat_lon_alt. I would try setting them to your:

lat_max= 19.8; lat_min= 21.7
lon_max= -100.59; lon_min= -99.0

Ariel

unread,
Mar 23, 2022, 7:53:18 PM3/23/22
to Py-ART Users
I checked my code several times and I didn't see those parameters. 

Thnks, that work for me

Reply all
Reply to author
Forward
0 new messages