moniplot.lib package

Submodules

moniplot.lib.fig_draw_image module

This module holds fig_data_to_xarr and fig_qdata_to_xarr.

These functions are used by resp. draw_signal and draw_quality.

moniplot.lib.fig_draw_image.adjust_img_ticks(axx: Axes, xarr: xr.DataArray, dims: str | None = None) None[source]

Adjust ticks of the image axis.

Parameters:
  • axx (matplotlib.Axes) – Matplotlib Axes object for the central image panel

  • xarr (xarray.DataArray) – Object holding measurement data and attributes.

  • dims (str, optional) – Name of the plot dimension (X or Y).

moniplot.lib.fig_draw_image.fig_data_to_xarr(data: ndarray, zscale: str | None = None, vperc: list[int, int] | None = None, vrange: list[float, float] | None = None) DataArray[source]

Prepare image data for plotting.

Parameters:
  • data (array-like or xarray.DataArray) –

  • zscale (str, default='linear') – Scaling of the data values. Recognized values are: ‘linear’, ‘log’, ‘diff’ or ‘ratio’.

  • vperc (list, default=[1, 99]) – Range to normalize luminance data between percentiles min and max of array data.

  • vrange (list, default=None) – Range to normalize luminance data between vmin and vmax.

Returns:

image data and attributes ready for plotting

Return type:

xarray.DataArray

Notes

The input data should have two dimensions. If the input data is array-like, it will be converted into a xarray DataArray using the function data_to_xr.

The returned xarray DataArray has addition attributes to facilitate the plotting methods of MONplot with names ‘_cmap’ or start with ‘_z’.

The default values of vperc are used when both vrange and vperc are None. When vrange and vperc are provided, then vrange is used.

moniplot.lib.fig_draw_image.fig_draw_panels(axx_p: dict, xarr: DataArray, side_panels: str) None[source]

Draw two side-panels, one left and one under the main image panel.

Parameters:
  • axx_p (dict) – dictionary holding matplotlib Axes for panel X and Y

  • xarr (xarray.DataArray) – Object holding measurement data and attributes

  • side_panels (str) – Show row and column statistics in side plots.

moniplot.lib.fig_draw_image.fig_qdata_to_xarr(data: ndarray, ref_data: ndarray | None = None, data_sel: slice | None = None, thres_worst: float = 0.1, thres_bad: float = 0.8, qlabels: tuple[str] | None = None) DataArray[source]

Prepare pixel-quality data for plotting.

Parameters:
  • data (array-like or xarray.DataArray) – Object holding detector pixel-quality data and attributes.

  • ref_data (numpy.ndarray, default=None) – Numpy array holding reference data, for example pixel quality reference map taken from the CKD. Shown are the changes with respect to the reference data.

  • data_sel (slice, optional) – Select a region on the detector by fancy indexing (using a boolean/integer arrays), or using index tuples for arrays (generated with numpy.s_). Outside this region the pixels will be labeled: ‘unusable’.

  • thres_worst (float, default=0.1) – Threshold to reject only the worst of the bad pixels, intended for CKD derivation.

  • thres_bad (float, default=0.8) – Threshold for bad pixels.

  • qlabels (tuple of strings, optional) – Labels for the pixel-quality classes, see below

Returns:

image data and attributes ready for plotting

Return type:

xarray.DataArray

Notes

Without a reference dataset, the default quality ranking labels are:

'unusable' :  pixels outside the illuminated region
'worst'    :  0 <= value < thres_worst
'bad'      :  0 <= value < thres_bad
'good'     :  thres_bad <= value <= 1

Otherwise, the default quality ranking labels are:

'unusable'    :  pixels outside the illuminated region
'to worst'    :  from good or bad to worst
'good to bad' :  from good to bad
'to good'     :  from any rank to good
'unchanged'   :  no change in rank

moniplot.lib.fig_draw_lplot module

This module holds fig_draw_lplot and close_draw_lplot.

These functions are used by draw_lplot.

moniplot.lib.fig_draw_lplot.close_draw_lplot(axx: Axes, time_axis: bool, title: str | None, kwlegend: dict | None, **kwargs: int) None[source]

Close the figure created with MONplot::draw_lplot().

Parameters:
  • axx (matplotlib.Axes) – Matplotlib Axes object of plot window

  • time_axis (bool) – The xlabels represent date/time

  • title (str | None) – Title of the figure

  • kwlegend (dict | None) – Provide keywords for the function Axes.legend. Default: {‘fontsize’: ‘small’, ‘loc’: ‘best’}

  • **kwargs (keyword arguments) – Recognized are ‘xlabel’, ‘ylabel’, ‘xlim’, ‘ylim’, ‘xscale’, ‘yscale’

moniplot.lib.fig_draw_lplot.fig_draw_lplot(axx: Axes, xdata: np.ndarray, ydata: np.ndarray, use_steps: bool = False, **kwargs: int) None[source]

Add line plot to figure.

Parameters:
  • axx (matplotlib.Axes) – Matplotlib Axes object of plot window.

  • xdata (array_like) – X data.

  • ydata (array_like) – Y data.

  • use_steps (bool, default=False) – use plt.stairs() instead of plt.plot().

  • **kwargs (keyword arguments) – Keywords passed to matplotlib.pyplot.plot

See also

matplotlib.pyplot.plot, matplotlib.pyplot.stairs

moniplot.lib.fig_draw_multiplot module

This module holds draw_subplot which is used by draw_multiplot.

moniplot.lib.fig_draw_multiplot.draw_subplot(axx: Axes, xarr: xr.DataArray, xylabels: list[str, str]) None[source]

Draw a subplot figure.

Parameters:
  • axx (matplotlib.Axes) – Matplotlib Axes object of subplot

  • xarr (xarray.DataArray) – Data with attrubutes of subplot

  • xylabels (list[str]) – X,Y labels of subplot

moniplot.lib.fig_draw_multiplot.get_xylabels(gridspec: GridSpec, data_tuple: tuple) np.ndarray[source]

Define xlabel and ylabel for each subplot panel.

Parameters:
  • gridspec (matplotlib.gridspec.GridSpec) – Matplotlib gridspec object

  • data_tuple (tuple) – X,Y data for each panel

Returns:

X,Y labels for each panel

Return type:

numpy.ndarray

moniplot.lib.fig_draw_qhist module

This module holds fig_draw_qhist which are used by draw_qhist.

moniplot.lib.fig_draw_qhist.fig_draw_qhist(axx: Axes, qdata: np.ndarray, label: str, density: bool) None[source]

Add a subplot showing pixel-quality data as a histogram.

Parameters:
  • axx (matplotlib.Axes) – Matplotlib Axes object of plot window

  • qdata (numpy.ndarray) – Object holding pixel-quality data and attributes

  • label (str) – Name describing qdata, displayed in the upper left corner

  • density (bool) – See method MONplot::draw_qhist for a description

moniplot.lib.fig_draw_tracks module

This module contains fig_draw_tracks used by draw_tracks.

moniplot.lib.fig_draw_trend module

This module contains the functions: add_subplot and add_hk_subplot.

moniplot.lib.fig_draw_trend.add_hk_subplot(axx: Axes, xarr: xr.DataArray, vperc: list | None = None, vrange_last_orbits: int = -1) None[source]

Add a subplot for housekeeping data.

Parameters:
  • axx (matplotlib.Axes) – Matplotlib Axes object of the current panel

  • xarr (xarray.DataArray) – Object holding housekeeping data and attributes. Dimension must be ‘orbit’, ‘hours’ or ‘time’.

  • vperc (list | None, optional) – Reject outliers before determining vrange (neglected when vrange_last_orbits is used)

  • vrange_last_orbits (int) – Use the last N orbits to determine vrange (orbit coordinate only)

moniplot.lib.fig_draw_trend.add_subplot(axx: Axes, xarr: xr.DataArray) None[source]

Add a subplot for measurement data.

Parameters:
  • axx (matplotlib.Axes) – Matplotlib Axes object of the current panel

  • xarr (xarray.DataArray) – Object holding measurement data and attributes Dimension must be ‘orbit’, ‘hours’ or ‘time’.

moniplot.lib.fig_info module

This module contains the class FIGinfo.

class moniplot.lib.fig_info.FIGinfo(loc: str = 'above', info_dict: dict | None = None)[source]

Bases: object

Define figure information.

The figure information consists of [key, value] combinations which are to be displayed upper-right corner of the figure.

Parameters:
  • loc (str, default='above') – Location to draw the fig_info box: ‘above’ (default), ‘below’, ‘none’

  • info_dict (dict, optional) – Dictionary holding information to be displayed in the fig_info box

Notes

The figure-box can only hold a limited number of entries, because it will grow with the number of lines and overlap with the main image or its color bar. You may try loc=’below’, which is only available for image plots.

add(key: str, value: Any, fmt: str = '{}') None[source]

Extent fig_info by adding a new line.

Parameters:
  • key (str) – Name of the fig_info key

  • value (Any python variable) – Value of the fig_info key. A tuple will be formatted as *value

  • fmt (str, default='{}') – Convert value to a string, using the string format method

as_str() str[source]

Return figure information as one long string.

copy() FIGinfo[source]

Return a deep copy of the current object.

property location: str

Return location of the fig_info box.

set_location(loc: str) None[source]

Set the location of the fig_info box.

Parameters:

loc (str) – Location of the fig_info box

moniplot.lib.fig_legend module

This module contains blank_legend_handle.

moniplot.lib.fig_legend.blank_legend_handle() Rectangle[source]

Show only label in a legend entry, no handle.

See also

matplotlib.pyplot.legend

Place a legend on the Axes.

Module contents

Necessary but empty file.