Visualisation#

Standard plotting and mapping procedures.

plot

Plot Plan Position Indicator (PPI) or Range Height Indicator (RHI).

plot_ppi_crosshair

Plots a Crosshair for a Plan Position Indicator (PPI).

create_cg

Helper function to create curvelinear grid

plot_scan_strategy

Plot the vertical scanning strategy.

plot_plan_and_vert

Plot 2-D plan view of dataxy together with vertical sections dataxz and datazy

plot_max_plan_and_vert

Plot according to <plot_plan_and_vert> with the maximum values along the three axes of data

add_lines

Add lines (points in the form Nx2) to axes

add_patches

Add patches (points in the form Nx2) to axes

VisMethods

wradlib xarray SubAccessor methods for visualization.

wradlib.vis.plot(da, *, ax=111, fig=None, crs=None, func='pcolormesh', **kwargs)[source]#

Plot Plan Position Indicator (PPI) or Range Height Indicator (RHI).

The implementation of this plot routine is in cartesian axes and does all coordinate transforms using xarray machinery. This allows zooming into the data as well as making it easier to plot additional data (like gauge locations) without having to convert them to the radar’s polar coordinate system.

Using crs='cg' the plotting is done in a curvelinear grid axes.

Additional data can be plotted in polar coordinates or cartesian coordinates depending on which axes object is used.

**kwargs may be used to try to influence the matplotlib.pyplot.pcolormesh, matplotlib.pyplot.contour, matplotlib.pyplot.contourf and wradlib.georef.polar.spherical_to_proj routines under the hood.

Parameters
  • da (xarray.DataArray) – DataArray to plot

  • crs (cartopy.crs.CRS, dict or None) – cartopy CRS Coordinate Reference System describing projection If this parameter is not None, site must be set properly. Then the function will attempt to georeference the radar bins and display the PPI in the coordinate system defined by the projection string.

  • fig (matplotlib.figure.Figure) – If given, the PPI/RHI will be plotted into this figure object. Axes are created as needed. If None, a new figure object will be created or current figure will be used, depending on ax.

  • ax (matplotlib.axes.Axes or matplotlib.gridspec.SubplotSpec) – If matplotlib Axes object is given, the PPI will be plotted into this axes object. If matplotlib grid definition is given (nrows/ncols/plotnumber), axis are created in the specified place. Defaults to ‘111’, only one subplot/axis.

  • func (str) – Name of plotting function to be used under the hood. Defaults to ‘pcolormesh’. ‘contour’ and ‘contourf’ can be selected too.

Keyword Arguments
  • cmap (str, optional) – matplotlib colormap string. Defaults to wradlib default colormap, which is either Homeyer_Rainbow if cmweather is installed or turbo.

  • zorder (int, optional) – Lower zorder values are drawn first. Defaults to 0.

  • kwargs (dict, optional) – Further kwargs, which are propagated to xarray plotting functions.

Returns

pm (matplotlib.collections.QuadMesh or matplotlib.contour.QuadContourSet) – The result of the plotting function. Necessary, if you want to add a colorbar to the plot.

Note

If crs contains a curvelinear grid dict, the cgax - curvelinear Axes (r-theta-grid) is returned. caax - Cartesian Axes (x-y-grid) and paax - parasite axes object for plotting polar data can be derived like this:

caax = cgax.parasites[0]
paax = cgax.parasites[1]

The function create_cg uses the Matplotlib AXISARTIST namespace.

Here are some limitations to normal Matplotlib Axes (see AXES_GRID1).

Examples

See Quick-view a sweep in polar or cartesian reference systems, and Plot on curvelinear grid.

wradlib.vis.plot_ppi_crosshair(site, ranges, angles=None, crs=None, elev=0.0, ax=None, **kwargs)[source]#

Plots a Crosshair for a Plan Position Indicator (PPI).

Parameters
  • site (tuple) – Tuple of coordinates of the radar site. If crs is not used, this simply becomes the offset for the origin of the coordinate system. If crs is used, values must be given as (longitude, latitude, altitude) tuple of geographical coordinates.

  • ranges (list) – List of ranges, for which range circles should be drawn. If crs is None arbitrary units may be used (such that they fit with the underlying PPI plot). Otherwise the ranges must be given in meters.

  • angles (list, optional) – List of angles (in degrees) for which straight lines should be drawn. These lines will be drawn starting from the center and until the largest range. Defaults to [0, 90, 180, 270].

  • crs (osgeo.osr.SpatialReference) – GDAL OSR Spatial Reference Object describing projection The function will calculate lines and circles according to georeferenced coordinates taking beam propagation, earth’s curvature and scale effects due to projection into account. Depending on the projection, crosshair lines might not be straight and range circles might appear elliptical (also check if the aspect of the axes might not also be responsible for this).

  • elev (float or numpy.ndarray) – float or array of same shape as az Elevation angle of the scan or individual azimuths. May improve georeferencing coordinates for larger elevation angles. Defaults to 0.

  • ax (matplotlib.axes.Axes) – If given, the crosshair will be plotted into this axes object. If None matplotlib’s current axes (function gca()) concept will be used to determine the axes.

Keyword Arguments
  • line (dict) – dictionary, which will be passed to the crosshair line objects using the standard keyword inheritance mechanism. If not given defaults will be used.

  • circle (dict) – dictionary, which will be passed to the range circle line objects using the standard keyword inheritance mechanism. If not given defaults will be used.

See also

plot_ppi

Returns

ax (matplotlib.axes.Axes) – The axes object into which the PPI was plotted

Examples

See Quick-view a sweep in polar or cartesian reference systems.

wradlib.vis.create_cg(*, fig=None, subplot=111, rot=-450, scale=-1, angular_spacing=10, radial_spacing=10, latmin=0, lon_cycle=360)[source]#

Helper function to create curvelinear grid

The function makes use of the Matplotlib AXISARTIST toolkit.

Here are some limitations to normal Matplotlib Axes. While using the Matplotlib AxesGrid1 Toolkit most of the limitations can be overcome. See Overview of axes_grid1 toolkit.

Parameters
  • fig (matplotlib.figure.Figure) – If given, the PPI/RHI will be plotted into this figure object. Axes are created as needed. If None a new figure object will be created or current figure will be used, depending on “subplot”.

  • subplot (matplotlib.gridspec.SubplotSpec) – nrows/ncols/plotnumber, see examples section defaults to ‘111’, only one subplot

  • rot (float) – Rotation of the source data in degrees, defaults to -450 for PPI, use 0 for RHI

  • scale (float) – Scale of source data, defaults to -1. for PPI, use 1 for RHI

  • angular_spacing (float) – Spacing of the angular grid, defaults to 10.

  • radial_spacing (float) – Spacing of the radial grid, defaults to 10.

  • latmin (float) – Startvalue for radial grid, defaults to 0.

  • lon_cycle (float) – Angular cycle, defaults to 360.

Returns

wradlib.vis.plot_scan_strategy(ranges, elevs, site, *, beamwidth=1.0, vert_res=500.0, maxalt=10000.0, range_res=None, maxrange=None, units='m', terrain=None, az=0.0, cg=False, ax=111, cmap='tab10')[source]#

Plot the vertical scanning strategy.

Parameters
  • ranges (sequence of float or numpy.ndarray) – sequence or array of float ranges

  • elevs (sequence of float or numpy.ndarray) – elevation angles

  • site (sequence of tuple or numpy.ndarray) – radar site coordinates (longitude, latitude, altitude)

  • beamwidth (float) – 3dB width of the radar beam, defaults to 1.0 deg.

  • vert_res (float) – Vertical resolution in [m].

  • maxalt (float) – Maximum altitude in [m].

  • range_res (float) – Horizontal resolution in [m].

  • maxrange (float) – Maximum range in [m].

  • units (str) – Units to plot in, can be ‘m’ or ‘km’. Defaults to ‘m’.

  • terrain (bool or numpy.ndarray) – If True, downloads srtm data and add orography for given az.

  • az (float) – Used to specify azimuth for terrain plots.

  • cg (bool) – If True, plot in curvelinear grid, defaults to False (cartesian grid).

  • ax (matplotlib.axes.Axes or matplotlib.gridspec.SubplotSpec) – If matplotlib Axes object is given, the scan strategy will be plotted into this axes object. If matplotlib grid definition is given (nrows/ncols/plotnumber), axis are created in the specified place. Defaults to ‘111’, only one subplot/axis.

  • cmap (str) – matplotlib colormap string.

Returns

ax (matplotlib.axes.Axes) – matplotlib Axes or curvelinear Axes (matplotlib toolkit axisartist Axes object, r-theta-grid) depending on keyword argument cg.

wradlib.vis.plot_plan_and_vert(x, y, z, dataxy, datazx, datazy, *, unit='', title='', **kwargs)[source]#

Plot 2-D plan view of dataxy together with vertical sections dataxz and datazy

Parameters
Keyword Arguments

**kwargs (dict) – other kwargs which can be passed to matplotlib.pyplot.contourf

wradlib.vis.plot_max_plan_and_vert(x, y, z, data, *, unit='', title='', **kwargs)[source]#

Plot according to <plot_plan_and_vert> with the maximum values along the three axes of data

Examples

See Recipe #2: Reading and visualizing an ODIM_H5 polar volume.

wradlib.vis.add_lines(ax, lines, **kwargs)[source]#

Add lines (points in the form Nx2) to axes

Add lines (points in the form Nx2) to existing axes ax using matplotlib.collections.LineCollection.

Parameters

Examples

See Plot geodata.

wradlib.vis.add_patches(ax, patch_array, **kwargs)[source]#

Add patches (points in the form Nx2) to axes

Add patches (points in the form Nx2) to existing axes ax using matplotlib.collections.PolyCollection.

Parameters

Examples

See Plot geodata.

class wradlib.vis.VisMethods(obj)[source]#

Bases: XarrayMethods

wradlib xarray SubAccessor methods for visualization.

plot(*, ax=111, fig=None, crs=None, func='pcolormesh', **kwargs)[source]#

Plot Plan Position Indicator (PPI) or Range Height Indicator (RHI).

The implementation of this plot routine is in cartesian axes and does all coordinate transforms using xarray machinery. This allows zooming into the data as well as making it easier to plot additional data (like gauge locations) without having to convert them to the radar’s polar coordinate system.

Using crs='cg' the plotting is done in a curvelinear grid axes.

Additional data can be plotted in polar coordinates or cartesian coordinates depending on which axes object is used.

**kwargs may be used to try to influence the matplotlib.pyplot.pcolormesh, matplotlib.pyplot.contour, matplotlib.pyplot.contourf and wradlib.georef.polar.spherical_to_proj routines under the hood.

Parameters
  • da (xarray.DataArray) – DataArray to plot

  • crs (cartopy.crs.CRS, dict or None) – cartopy CRS Coordinate Reference System describing projection If this parameter is not None, site must be set properly. Then the function will attempt to georeference the radar bins and display the PPI in the coordinate system defined by the projection string.

  • fig (matplotlib.figure.Figure) – If given, the PPI/RHI will be plotted into this figure object. Axes are created as needed. If None, a new figure object will be created or current figure will be used, depending on ax.

  • ax (matplotlib.axes.Axes or matplotlib.gridspec.SubplotSpec) – If matplotlib Axes object is given, the PPI will be plotted into this axes object. If matplotlib grid definition is given (nrows/ncols/plotnumber), axis are created in the specified place. Defaults to ‘111’, only one subplot/axis.

  • func (str) – Name of plotting function to be used under the hood. Defaults to ‘pcolormesh’. ‘contour’ and ‘contourf’ can be selected too.

Keyword Arguments
  • cmap (str, optional) – matplotlib colormap string. Defaults to wradlib default colormap, which is either Homeyer_Rainbow if cmweather is installed or turbo.

  • zorder (int, optional) – Lower zorder values are drawn first. Defaults to 0.

  • kwargs (dict, optional) – Further kwargs, which are propagated to xarray plotting functions.

Returns

pm (matplotlib.collections.QuadMesh or matplotlib.contour.QuadContourSet) – The result of the plotting function. Necessary, if you want to add a colorbar to the plot.

Note

If crs contains a curvelinear grid dict, the cgax - curvelinear Axes (r-theta-grid) is returned. caax - Cartesian Axes (x-y-grid) and paax - parasite axes object for plotting polar data can be derived like this:

caax = cgax.parasites[0]
paax = cgax.parasites[1]

The function create_cg uses the Matplotlib AXISARTIST namespace.

Here are some limitations to normal Matplotlib Axes (see AXES_GRID1).

Examples

See Quick-view a sweep in polar or cartesian reference systems, and Plot on curvelinear grid.

pcolormesh(*, ax=111, fig=None, crs=None, func='pcolormesh', **kwargs)[source]#

Plot Plan Position Indicator (PPI) or Range Height Indicator (RHI).

The implementation of this plot routine is in cartesian axes and does all coordinate transforms using xarray machinery. This allows zooming into the data as well as making it easier to plot additional data (like gauge locations) without having to convert them to the radar’s polar coordinate system.

Using crs='cg' the plotting is done in a curvelinear grid axes.

Additional data can be plotted in polar coordinates or cartesian coordinates depending on which axes object is used.

**kwargs may be used to try to influence the matplotlib.pyplot.pcolormesh, matplotlib.pyplot.contour, matplotlib.pyplot.contourf and wradlib.georef.polar.spherical_to_proj routines under the hood.

Parameters
  • da (xarray.DataArray) – DataArray to plot

  • crs (cartopy.crs.CRS, dict or None) – cartopy CRS Coordinate Reference System describing projection If this parameter is not None, site must be set properly. Then the function will attempt to georeference the radar bins and display the PPI in the coordinate system defined by the projection string.

  • fig (matplotlib.figure.Figure) – If given, the PPI/RHI will be plotted into this figure object. Axes are created as needed. If None, a new figure object will be created or current figure will be used, depending on ax.

  • ax (matplotlib.axes.Axes or matplotlib.gridspec.SubplotSpec) – If matplotlib Axes object is given, the PPI will be plotted into this axes object. If matplotlib grid definition is given (nrows/ncols/plotnumber), axis are created in the specified place. Defaults to ‘111’, only one subplot/axis.

  • func (str) – Name of plotting function to be used under the hood. Defaults to ‘pcolormesh’. ‘contour’ and ‘contourf’ can be selected too.

Keyword Arguments
  • cmap (str, optional) – matplotlib colormap string. Defaults to wradlib default colormap, which is either Homeyer_Rainbow if cmweather is installed or turbo.

  • zorder (int, optional) – Lower zorder values are drawn first. Defaults to 0.

  • kwargs (dict, optional) – Further kwargs, which are propagated to xarray plotting functions.

Returns

pm (matplotlib.collections.QuadMesh or matplotlib.contour.QuadContourSet) – The result of the plotting function. Necessary, if you want to add a colorbar to the plot.

Note

If crs contains a curvelinear grid dict, the cgax - curvelinear Axes (r-theta-grid) is returned. caax - Cartesian Axes (x-y-grid) and paax - parasite axes object for plotting polar data can be derived like this:

caax = cgax.parasites[0]
paax = cgax.parasites[1]

The function create_cg uses the Matplotlib AXISARTIST namespace.

Here are some limitations to normal Matplotlib Axes (see AXES_GRID1).

Examples

See Quick-view a sweep in polar or cartesian reference systems, and Plot on curvelinear grid.

contour(*, ax=111, fig=None, crs=None, func='pcolormesh', **kwargs)[source]#

Plot Plan Position Indicator (PPI) or Range Height Indicator (RHI).

The implementation of this plot routine is in cartesian axes and does all coordinate transforms using xarray machinery. This allows zooming into the data as well as making it easier to plot additional data (like gauge locations) without having to convert them to the radar’s polar coordinate system.

Using crs='cg' the plotting is done in a curvelinear grid axes.

Additional data can be plotted in polar coordinates or cartesian coordinates depending on which axes object is used.

**kwargs may be used to try to influence the matplotlib.pyplot.pcolormesh, matplotlib.pyplot.contour, matplotlib.pyplot.contourf and wradlib.georef.polar.spherical_to_proj routines under the hood.

Parameters
  • da (xarray.DataArray) – DataArray to plot

  • crs (cartopy.crs.CRS, dict or None) – cartopy CRS Coordinate Reference System describing projection If this parameter is not None, site must be set properly. Then the function will attempt to georeference the radar bins and display the PPI in the coordinate system defined by the projection string.

  • fig (matplotlib.figure.Figure) – If given, the PPI/RHI will be plotted into this figure object. Axes are created as needed. If None, a new figure object will be created or current figure will be used, depending on ax.

  • ax (matplotlib.axes.Axes or matplotlib.gridspec.SubplotSpec) – If matplotlib Axes object is given, the PPI will be plotted into this axes object. If matplotlib grid definition is given (nrows/ncols/plotnumber), axis are created in the specified place. Defaults to ‘111’, only one subplot/axis.

  • func (str) – Name of plotting function to be used under the hood. Defaults to ‘pcolormesh’. ‘contour’ and ‘contourf’ can be selected too.

Keyword Arguments
  • cmap (str, optional) – matplotlib colormap string. Defaults to wradlib default colormap, which is either Homeyer_Rainbow if cmweather is installed or turbo.

  • zorder (int, optional) – Lower zorder values are drawn first. Defaults to 0.

  • kwargs (dict, optional) – Further kwargs, which are propagated to xarray plotting functions.

Returns

pm (matplotlib.collections.QuadMesh or matplotlib.contour.QuadContourSet) – The result of the plotting function. Necessary, if you want to add a colorbar to the plot.

Note

If crs contains a curvelinear grid dict, the cgax - curvelinear Axes (r-theta-grid) is returned. caax - Cartesian Axes (x-y-grid) and paax - parasite axes object for plotting polar data can be derived like this:

caax = cgax.parasites[0]
paax = cgax.parasites[1]

The function create_cg uses the Matplotlib AXISARTIST namespace.

Here are some limitations to normal Matplotlib Axes (see AXES_GRID1).

Examples

See Quick-view a sweep in polar or cartesian reference systems, and Plot on curvelinear grid.

contourf(*, ax=111, fig=None, crs=None, func='pcolormesh', **kwargs)[source]#

Plot Plan Position Indicator (PPI) or Range Height Indicator (RHI).

The implementation of this plot routine is in cartesian axes and does all coordinate transforms using xarray machinery. This allows zooming into the data as well as making it easier to plot additional data (like gauge locations) without having to convert them to the radar’s polar coordinate system.

Using crs='cg' the plotting is done in a curvelinear grid axes.

Additional data can be plotted in polar coordinates or cartesian coordinates depending on which axes object is used.

**kwargs may be used to try to influence the matplotlib.pyplot.pcolormesh, matplotlib.pyplot.contour, matplotlib.pyplot.contourf and wradlib.georef.polar.spherical_to_proj routines under the hood.

Parameters
  • da (xarray.DataArray) – DataArray to plot

  • crs (cartopy.crs.CRS, dict or None) – cartopy CRS Coordinate Reference System describing projection If this parameter is not None, site must be set properly. Then the function will attempt to georeference the radar bins and display the PPI in the coordinate system defined by the projection string.

  • fig (matplotlib.figure.Figure) – If given, the PPI/RHI will be plotted into this figure object. Axes are created as needed. If None, a new figure object will be created or current figure will be used, depending on ax.

  • ax (matplotlib.axes.Axes or matplotlib.gridspec.SubplotSpec) – If matplotlib Axes object is given, the PPI will be plotted into this axes object. If matplotlib grid definition is given (nrows/ncols/plotnumber), axis are created in the specified place. Defaults to ‘111’, only one subplot/axis.

  • func (str) – Name of plotting function to be used under the hood. Defaults to ‘pcolormesh’. ‘contour’ and ‘contourf’ can be selected too.

Keyword Arguments
  • cmap (str, optional) – matplotlib colormap string. Defaults to wradlib default colormap, which is either Homeyer_Rainbow if cmweather is installed or turbo.

  • zorder (int, optional) – Lower zorder values are drawn first. Defaults to 0.

  • kwargs (dict, optional) – Further kwargs, which are propagated to xarray plotting functions.

Returns

pm (matplotlib.collections.QuadMesh or matplotlib.contour.QuadContourSet) – The result of the plotting function. Necessary, if you want to add a colorbar to the plot.

Note

If crs contains a curvelinear grid dict, the cgax - curvelinear Axes (r-theta-grid) is returned. caax - Cartesian Axes (x-y-grid) and paax - parasite axes object for plotting polar data can be derived like this:

caax = cgax.parasites[0]
paax = cgax.parasites[1]

The function create_cg uses the Matplotlib AXISARTIST namespace.

Here are some limitations to normal Matplotlib Axes (see AXES_GRID1).

Examples

See Quick-view a sweep in polar or cartesian reference systems, and Plot on curvelinear grid.