If you are working with radar station data, it is almost ever only
available as polar data. This means you have a 2D-array, one dimension
holding the azimuth (PPI) or elevation (RHI) angle values and
the other holding the range values.

In \(\omega radlib\) it is assumed that the first dimension is over
the azimuth/elevation angles, while the second dimension is over the
range bins.

Other than most plotting functions you cannot give an axes object as
an argument. All necessary axes objects are created on the fly. You
may give an figure object and/or an subplot specification as
parameter. For further information on howto plot multiple cg plots in
one figure, have a look at the special section Plotting on
Grids.

Now we will make use of some of the capabilities of this curvelinear
axes.

You see, that for labeling x- and y-axis the cartesian axis is used. The
azimuth label is set via :func:text. Also a colorbar is easily
added. The plotting routine would be invoked like this, adding range and
azimuth arrays and using the autoext feature:

One more good thing about curvelinear axes is that you can plot polar as
well as cartesian data. However, you have to be careful, where to plot.
Polar data has to be plottet to the parasite axis (paax). Cartesian
data can be plottet to caax, although you can also plot cartesian
data to the main cgax.

Anyway, it is easy to overlay your polar data, with other station data
(e.g. gauges). Taking the former sector example, we can plot some
additional stations:

The use of FixedLocator and DictFormatter should be clear. The
use of _nbins and _steps is a bit of head-twisting. With
_steps you can set the possible divisions of the range. In
connection with the _nbins the range grid is created depending on
maximum range. In the above situation with _nbins set to 10 we get
an range grid resolution of 25 (divider 2.5). When setting steps to 20
we get a resolution of 15 (divider 1.5). Choosing 30 lead to resolution
of 10 (divider 1/10). So it may be good to play around a bit, for wanted
results.

As you might have noticed the cartesian grid remained the same and the
azimuth labels are bit overplottet. But matplotlib would be not
matplotlib if there would be no solution. First we take care of the
labeling. We push the title a bit higher to get space and toggle the
caax labels to right and top:

Then we toggle “left” and “right” and “top” and “bottom” axis
behaviour. We also have to put the colorbar a bit to the side and alter
the location of the azimuth label. And, not to forgot to adapt the
ticklabels of the cartesian axes. With little effort we got a better
(IMHO) representation.

In [9]:

fig=pl.figure(figsize=(10,8))cgax,pm=wrl.vis.plot_ppi(ma[200:250,40:80],r[40:81],az[200:251],autoext=False,fig=fig,refrac=False,cg=True)caax=cgax.parasites[0]t=pl.title('Very Special Sector CG PPI')t.set_y(1.1)cbar=pl.gcf().colorbar(pm,pad=0.1)caax.set_xlabel('x_range [km]')caax.set_ylabel('y_range [km]')caax.toggle_axisline()# make ticklabels of right and top axis visiblecaax.axis["top","right"].set_visible(True)caax.axis["top","right"].major_ticklabels.set_visible(True)caax.grid(True)frommatplotlib.tickerimportMaxNLocatorcaax.xaxis.set_major_locator(MaxNLocator(15))caax.yaxis.set_major_locator(MaxNLocator(15))# make ticklabels of left and bottom axis visible,cgax.axis["left"].major_ticklabels.set_visible(True)cgax.axis["bottom"].major_ticklabels.set_visible(True)cgax.axis["left"].get_helper().nth_coord_ticks=0cgax.axis["bottom"].get_helper().nth_coord_ticks=0# and also set tickmarklength to zero for better presentationcgax.axis["right"].major_ticks.set_ticksize(0)cgax.axis["top"].major_ticks.set_ticksize(0)# make ticklabels of right and top axis unvisible,cgax.axis["right"].major_ticklabels.set_visible(False)cgax.axis["top"].major_ticklabels.set_visible(False)# and also set tickmarklength to zero for better presentationcgax.axis["right"].major_ticks.set_ticksize(0)cgax.axis["top"].major_ticks.set_ticksize(0)pl.text(0.025,-0.065,'azimuth',transform=caax.transAxes,va='bottom',ha='left')cbar.set_label('reflectivity [dBZ]')gh=cgax.get_grid_helper()# set azimuth resolution to 5deglocs=[iforiinnp.arange(0.,359.,5.)]gh.grid_finder.grid_locator1=FixedLocator(locs)gh.grid_finder.tick_formatter1=DictFormatter(dict([(i,r"${0:.0f}^\circ$".format(i))foriinlocs]))#gh.grid_finder.grid_locator1 = FixedLocator([i for i in np.arange(0, 359, 5, dtype=np.int32)])#gh.grid_finder.grid_locator1 = LocatorDMS(15)gh.grid_finder.grid_locator2._nbins=30gh.grid_finder.grid_locator2._steps=[1,1.5,2,2.5,5,10]cgax.axis["lat"]=cgax.new_floating_axis(0,240)cgax.axis["lat"].set_ticklabel_direction('-')cgax.axis["lat"].label.set_text("range [km]")cgax.axis["lat"].label.set_rotation(180)cgax.axis["lat"].label.set_pad(10)

wradlib.vis.plot_rhi()
is used in this section. An CG RHI plot is a little different compared
to an CG PPI plot. I covers only one quadrant and the data is plottet
counterclockwise from “east” (3 o’clock) to “north” (12 o’clock).

Everything else is much the same and you can do whatever you want as
shown in the section Plot CG PPI.

So just a quick example of an cg rhi plot with some decorations. Note,
the grid_locator1 for the theta angles is overwritten and now the
grid is much finer.

Here the abilities of Matplotlib
GridSpec
are used. Now we can also plot on irregular grids. Just create your grid
and take the GridSpec object as an input to the parameter ax as
follows (some padding has to be adjusted to get a nice plot):

# angle of *cut* through ppi and scan elev.angle=0.0elev=0.0filename=wrl.util.get_wradlib_data_file('misc/polar_dBZ_tur.gz')data=np.loadtxt(filename)# we need to have meter here for the georef function inside mipd1=np.arange(data.shape[1],dtype=np.float)*1000d2=np.arange(data.shape[0],dtype=np.float)data=np.roll(data,(d2>=angle).nonzero()[0][0],axis=0)# calculate max intensity projxs,ys,mip1=wrl.util.maximum_intensity_projection(data,r=d1,az=d2,angle=angle,elev=elev)xs,ys,mip2=wrl.util.maximum_intensity_projection(data,r=d1,az=d2,angle=90+angle,elev=elev)