pylawr.plot.layer#

pylawr.plot.layer.BackgroundLayer([zorder, ...])

This can be used to plot a cartopy image tile on given axes.

pylawr.plot.layer.BaseLayer([zorder])

The BaseLayer is a class for all layer.

pylawr.plot.layer.ColorbarLayer(layer[, zorder])

The colorbar layer is used as additional colorbar to given radar field layer.

pylawr.plot.layer.LawrHeaderLayer([zorder])

A LawrHeaderLayer adds a header layer.

pylawr.plot.layer.RadarFieldLayer(radar_field)

Gridded data, like radar data, can be plotted with this layer.

pylawr.plot.layer.BackgroundLayer#

class pylawr.plot.layer.BackgroundLayer(zorder=0, resolution=10, **settings)[source]#

Bases: BaseLayer

This can be used to plot a cartopy image tile on given axes. As default open street map data is used but it is possible to change the image tile.

Parameters
  • zorder (int) – The z-order defines the drawing order of the layers. If no z-order is set, the z-order will be set during plotting based on layer order in subplot. Default is 0.

  • resolution (int) – The zoom level for given image tile. Default is 10.

  • **settings – Variable keyword arguments dict, which is passed during plotting to the plotting logic and which sets the plotting behaviour of this layer.

zorder#

The drawing order of this layer. If not set, it will be automatically determined during plotting by subplot.

Type

int

resolution#

The zoom level for given image tile.

Type

int

settings#

The settings for this layer. It is passed to cartopy.mpl.geoaxes.GeoAxes.add_image(). These settings can be accessed directly and via a dict like interface of this layer.

Type

dict

img_tile#

This image tile is plotted to given axes during plot(). An :py:class`~cartopy.io.img_tiles.OSM` object is already initialized as default.

plot(ax)[source]#

The background image is plotted on this GeoAxes with set zorder. cartopy.mpl.geoaxes.GeoAxes.add_image() is called with img_tile as factory for plotting.

Parameters

ax (cartopy.mpl.geoaxes.GeoAxes) – Used to determine the axis to plot on.

pylawr.plot.layer.BaseLayer#

class pylawr.plot.layer.BaseLayer(zorder=0, **settings)[source]#

Bases: object

The BaseLayer is a class for all layer. It contains the most basic layer functions and parameter.

Parameters
  • zorder (int) – The z-order defines the drawing order of the layers. If no z-order is set, the z-order will be set during plotting based on layer order in subplot. Default is 0.

  • **settings – Variable keyword arguments dict, which is passed during plotting to the plotting logic and which sets the plotting behaviour of this layer.

zorder#

The drawing order of this layer. If not set, it will be automatically determined during plotting by subplot.

Type

int

settings#

The settings for this layer. These settings can be accessed directly and via a dict like interface of this layer.

Type

dict

property collection#

Get all elements which are plotted on given axes. This collection is populated after plot was called once. It is used by pylawr.plot.layer.base.BaseLayer.remove() to remove this layer from axes.

Returns

collection – A list with all elements which are plotted. If the list is empty, plot was not called yet.

Return type

list

abstract plot(ax)[source]#

” This method contains the main plot logic of this layer. For plot layer prototyping this plot method has to be overwritten.

Parameters

ax (matplotlib.axes.Axes) – This layer will be plotted on this given axes.

remove()[source]#

All plotted elements of this layer are removed. Further, the plot collection is emptied to an empty list.

update(*args, **kwargs)[source]#

pylawr.plot.layer.ColorbarLayer#

class pylawr.plot.layer.ColorbarLayer(layer, zorder=0, **settings)[source]#

Bases: BaseLayer

The colorbar layer is used as additional colorbar to given radar field layer. This colorbar is plotted on given axes and can there be on another axes than the radar field.

Parameters
  • layer (RadarFieldLayer) – The colorbar will be created for this radar field layer. pylawr.plot.layer.radarfield.RadarFieldLayer.plot_store is used to get the colormap from this layer.

  • zorder (int) – The z-order defines the drawing order of the layers. If no z-order is set, the z-order will be set during plotting based on layer order in subplot. Default is 0.

  • **settings – Variable keyword arguments dict, which is passed during plotting of colorbar(). All possible kwargs of colorbar() can used as keyword argument.

layer#

The colorbar will be created for this radar field layer during plotting. pylawr.plot.layer.radarfield.RadarFieldLayer.plot_store is used to get the colormap from this layer.

Type

RadarFieldLayer

zorder#

The drawing order of this layer. If not set, it will be automatically determined during plotting by subplot.

Type

int

settings#

The settings for this layer. It is passed to colorbar(). These settings can be accessed directly and via a dict like interface of this layer. All possible kwargs of colorbar() can set to this dictionary.

Type

dict

h_pad#

The horizontal padding of the colorbar to given axes in percentage [0, 1] of the axes width. The horizontal padding is the distance to the left and right border of the axes and the colorbar width therefore depends on this padding. Default is 0.35.

Type

float

v_pad#

The vertical padding of the colorbar to given axes in percentage [0, 1] of the axes height. The vertical padding is the distance to the top and and border of the axes and the colorbar height therefore depends on this padding. Default is 0.05

Type

float

colorbar#

The plotted colorbar accessible with this attribute. This attribute can be used to manipulate the colorbar directly. This layer is not plotted yet, if this attribute is None.

Type

matplotlib.colorbar.Colorbar or None

property layer#
plot(ax)[source]#

Adds a colorbar to given axes. The colorbar is sized and moved so that it has h_pad and v_pad as paddings. All other colorbar settings are set based on settings. The set zorder is used as zorder for the colorbar axes.

Parameters

ax (matplotlib.axes.Axes) – Parent axes for the colorbar. The colorbar will be plotted on this axes but will have its own colorbar axes. The position and zorder of this axes is not changed during plotting.

pylawr.plot.layer.LawrHeaderLayer#

class pylawr.plot.layer.LawrHeaderLayer(zorder=0, **settings)[source]#

Bases: BaseLayer

A LawrHeaderLayer adds a header layer. This header layer has three specific area, which can be used (title, left, right):

---------------------------------
------------- TITLE -------------
---------------------------------
+++++++++++++++++++++++++++++++++
----------------+----------------
---- LEFT ------+---- RIGHT -----
----------------+----------------

The different areas are splitted by lines. left and right are a dictionary where the entries are display as key: value. The title can be set as str.

Parameters
  • zorder (int) – The z-order defines the drawing order of the layers. If no z-order is set, the z-order will be set during plotting based on layer order in subplot. Default is 0.

  • **settings – Variable keyword arguments dict, which is passed during plotting to every text() call. Title and info box specific settings can be set with title_settings and info_settings.

zorder#

The drawing order of this layer. If not set, it will be automatically determined during plotting by subplot.

Type

int

settings#

The settings for this layer. These settings can be accessed directly and via a dict like interface of this layer.

Type

dict

title#

This title is used as title for this header layer.

Type

str

left#

This dictionary is plotted to the left information box within this header. If the order should be preserved, you can also pass an OrderedDict.

Type

dict(str, str)

right#

This dictionary is plotted to the right information box within this header. If the order should be preserved, you can also pass an OrderedDict.

Type

dict(str, str)

text_padding#

This padding is used to generate space to the left position of the text. This is only applied to the information box texts. A positive value will move the text to the right, while a negative value to the left.

Type

float

line_settings#

These specific settings are passed to the creation of the lines to create the three different visually separated boxes. All valid kwargs of matplotlib.lines.Line2D except transform and zorder can be used.

Type

dict

title_settings#

These specific settings are used during creation of the title and is passed to text(). This settings dict has a higher priority than the normal settings dict and is used to update the normal settings dict for the title. All valid kwargs of matplotlib.text.Text except zorder can be used.

Type

dict

info_settings#

These specific settings are used during creation of the left and right information box and is passed to text(). These settings have a higher priority than the normal settings dict and is used to update the normal settings dict for the title. All valid kwargs of matplotlib.text.Text except zorder can be used.

Type

dict

_plot_info_box_on_ax(ax, info_dict, x_pos)[source]#
_plot_lines_on_ax(ax)[source]#
_plot_text_on_ax(ax, x, y, text, **specific_settings)[source]#
_plot_title_on_ax(ax)[source]#
plot(ax)[source]#

This header layer is plotted on given axes. The lines are plotted firstly, while texts are plotted afterwards. All are plotted with set zorder on axes.

Parameters

ax (matplotlib.axes.Axes) – The header is plotted with set zorder on this subplot.

pylawr.plot.layer.RadarFieldLayer#

class pylawr.plot.layer.RadarFieldLayer(radar_field, grid=None, zorder=0, **settings)[source]#

Bases: BaseLayer

Gridded data, like radar data, can be plotted with this layer. The given radar field is plotted on a subplot, which can be specified during plotting. A given grid is used to specify the boundaries for the radar field.

Parameters
  • radar_field (xarray.DataArray or numpy.ndarray) – This array is plotted with this layer. It has to be castable to a one- or two-dimensional numpy.ndarray. The array needs the same shape as the grid to be plottable. Missing values can be marked as numpy.nan and are masked during plotting. If no grid is given, the radar field need to have a grid specified in radar_field.lawr.grid.

  • grid (child of pylawr.grid.base.BaseGrid or None) – This grid is used to infer the boundaries for the radar field. For this the grid need to have pylawr.grid.base.BaseGrid.lat_lon_bounds. If no grid is given, the grid will be inferred from radar field. The grid need to have the same shape as the squeezed radar field. Default is None.

  • zorder (int) – The z-order defines the drawing order of the layers. If no z-order is set, the z-order will be set during plotting based on layer order in subplot. Default is 0.

  • **settings – Variable keyword arguments dict, which is passed during plotting to pcolormesh() and which sets the plotting behaviour of this layer. All keyword arguments except transform can be used.

zorder#

The z-order defines the drawing order of the layers. If no z-order is set, the z-order will be set during plotting based on layer order in subplot.

Type

int

settings#

The settings for this layer. It is passed to pcolormesh(). These settings can be accessed directly and via a dict like interface of this layer. All possible kwargs of pcolormesh() can set to this dictionary.

Type

dict

field#

This array is plotted with this layer. It is castable to a one- or two-dimensional numpy.ndarray and has during plotting the same shape as the grid. Missing values are marked as numpy.nan and are masked during plotting.

Type

xarray.DataArray or numpy.ndarray

grid#

This grid is used to infer the boundaries for the radar field with pylawr.grid.base.BaseGrid.lat_lon_bounds. The grid has the same shape as the radar_field. If the grid is None, then the grid will be inferred during plotting from radar_field.lawr.grid.

Type

child of pylawr.grid.base.BaseGrid or None

plot_store#

The plotted element of this layer. This is the storage for the returned element of pcolormesh(). If this storage is None, this layer was not plotted yet.

Type

matplotlib.collections.QuadMesh or None

_get_checked_grid()[source]#

Get the grid for plotting purpose. If grid is not set, the grid will be inferred from radar field. The grid is checked against the radar field if the shapes match.

Returns

grid – The inferred and checked grid. This grid has the same shape as the radar field.

Return type

child of pylawr.grid.base.BaseGrid

property field#
property grid#
plot(ax)[source]#

This method plots the radar field onto given axes with set zorder. For plotting pcolormesh() is called based on given radar field and inferred grid. All nan-values of the given radar field are masked.

Parameters

ax (matplotlib.axes.Axes) – This layer is plotted with set zorder on this subplot.