pylawr.plot.layer#
|
This can be used to plot a cartopy image tile on given axes. |
|
The BaseLayer is a class for all layer. |
|
The colorbar layer is used as additional colorbar to given radar field layer. |
|
A LawrHeaderLayer adds a header layer. |
|
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:
BaseLayerThis 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
- 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
- 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 withimg_tileas 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:
objectThe 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
- settings#
The settings for this layer. These settings can be accessed directly and via a dict like interface of this layer.
- Type
- 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
- 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.
pylawr.plot.layer.ColorbarLayer#
- class pylawr.plot.layer.ColorbarLayer(layer, zorder=0, **settings)[source]#
Bases:
BaseLayerThe 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_storeis 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 ofcolorbar()can used as keyword argument.
- layer#
The colorbar will be created for this radar field layer during plotting.
pylawr.plot.layer.radarfield.RadarFieldLayer.plot_storeis used to get the colormap from this layer.- Type
- zorder#
The drawing order of this layer. If not set, it will be automatically determined during plotting by subplot.
- Type
- 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 ofcolorbar()can set to this dictionary.- Type
- 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
- 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
- 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.Colorbaror None
- property layer#
- plot(ax)[source]#
Adds a colorbar to given axes. The colorbar is sized and moved so that it has
h_padandv_padas paddings. All other colorbar settings are set based onsettings. The setzorderis 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:
BaseLayerA 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.
leftandrightare 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 withtitle_settingsandinfo_settings.
- zorder#
The drawing order of this layer. If not set, it will be automatically determined during plotting by subplot.
- Type
- settings#
The settings for this layer. These settings can be accessed directly and via a dict like interface of this layer.
- Type
- 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.
- 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.
- 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
- 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.Line2Dexcept transform and zorder can be used.- Type
- 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 ofmatplotlib.text.Textexcept zorder can be used.- Type
- 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 ofmatplotlib.text.Textexcept zorder can be used.- Type
- 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:
BaseLayerGridded 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.DataArrayornumpy.ndarray) – This array is plotted with this layer. It has to be castable to a one- or two-dimensionalnumpy.ndarray. The array needs the same shape as the grid to be plottable. Missing values can be marked asnumpy.nanand are masked during plotting. If no grid is given, the radar field need to have a grid specified inradar_field.lawr.grid.grid (child of
pylawr.grid.base.BaseGridor None) – This grid is used to infer the boundaries for the radar field. For this the grid need to havepylawr.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
- 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 ofpcolormesh()can set to this dictionary.- Type
- field#
This array is plotted with this layer. It is castable to a one- or two-dimensional
numpy.ndarrayand has during plotting the same shape as the grid. Missing values are marked asnumpy.nanand are masked during plotting.- Type
- 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 fromradar_field.lawr.grid.- Type
child of
pylawr.grid.base.BaseGridor 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.QuadMeshor 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.