casys.visualization.parameters

Plot’s parameters related classes.

Functions

check_limits(*, limits)

Check provided limits values.

check_color_map(*, color_map)

Check provided color_map value.

check_transform_parameters(*, transform[, ...])

Check the transform and center parameters supplied to DataParams.

compute_limits(*, limits, data)

Compute the limits according to the limits_type and limits_values parameters.

compute_discretized_cmap(*, cmap, data)

Compute a discretized cmap by performing the extraction and discretization of an input colormap according to the input data.

compute_discretized_colorbar_boundaries(*, ...)

Compute the boundary values associated with unique ordered values.

compute_discretized_colorbar_params(*, data)

Compute the colorbar parameters for a given data input.

compute_discretized_colorbar_ticks(*, bounds)

Compute ticks values for a discretized colorbar from the colorbar boundaries.

compute_repr_transform_clip(*, clip)

String representation for transformation's clip.

compute_stat_bar_values(*, data)

Compute statistics bar values for the provided data.

discretize_cmap(*, cmap, data[, select_first])

Discretize a colormap parameter according to the input data.

extract_cmap(*, cmap)

Extract a Colormap object from the colormap input, normalizing and checking the colors.

normalize_transform(transform)

Normalize the center option value.

Classes

AxeParams([label, ticks, ticks_minor, ...])

Axe parameters for a plot.

DataParams([limits, properties, x_limits, ...])

Set of parameters related to plot's data.

FeatureParams([feature, feature_kwargs, ...])

Set of parameters relatives to the coastlines display in plot visualisation.

GridParams([line_properties, xlabel_style, ...])

Set of parameters for gridliner in a map.

WatermarkParams(image[, image_size, kwargs])

Parameters of a watermark.

PlotParams([fig_width, fig_height, ...])

Set of parameters related to plot's visualization.

TextParams([xlabel, ylabel, clabel, slabel, ...])

Set of text parameters for a plot.

PlotTemplate([title, x1, x2, y1, y2, ...])

Template containing all plot's elements properties.

TemplateManager()

Class managing the template objects.

TemplateRecords([templates])

Template records class.

class casys.visualization.parameters.AxeParams(label=None, ticks=None, ticks_minor=None, ticks_major=None, kwargs=None, properties=None, is_copy=None, values=None, position=None, enabled=None, level=PropertiesLevel.ALL)

Bases: object

Axe parameters for a plot.

Matplotlib underlying functions depend on the type of element this parameter is given to.

Parameters:
property axe_kwargs: dict[str, Any]
property axis: TargetAxisType
drop_auto()

Drop all auto properties from this element.

enable(level=PropertiesLevel.USER, only_missing=True)
Parameters:
has_label()
Return type:

bool

html_elem(style='')
Parameters:

style (str)

Return type:

str

static html_header()
property is_copy: bool
property label_params: dict[str, Any]
property label_text: str
classmethod normalize_color_bar(*, color_bar)

Normalize the colorbar parameter value.

Parameters:

color_bar (bool | str | AxeParams | None) – Colorbar parameter value.

Return type:

AxeParams

Returns:

Normalized colorbar parameter value.

static normalize_kwargs(values, level)
Parameters:
Return type:

Properties

property position: Position
set_axis(value, level)
Parameters:
set_axis_ticks(ax)
Parameters:

ax (Axis)

set_label(values, level=PropertiesLevel.USER)
Parameters:
set_position(position, level=PropertiesLevel.USER)
Parameters:
set_text_size(size, elements)
Parameters:
property show: bool
property ticks_major_params: dict[str, Any]
property ticks_minor_params: dict[str, Any]
property ticks_params: dict[str, Any]
property ticks_values: dict[str, Any] | Callable
to_level(level)

Convert all properties to the provided level.

Parameters:

level (PropertiesLevel) – Properties level to convert into.

update(params, mode=PropertiesLevel.ALL, replace=False, only_missing=False)

Update the current AxeParams with properties from the provided one.

Parameters:
  • params (AxeParams | None) – AxeParams to get values from.

  • mode (PropertiesLevel) – Update mode.

  • replace (bool) – Whether to replace existing properties or not.

  • only_missing (bool) – Whether to only add missing values or not.

update_kwargs(values, level)
Parameters:
property values: dict[str, Any] | Callable
class casys.visualization.parameters.DataParams(limits=None, properties=None, x_limits=None, y_limits=None, z_limits=None, time_limits=None, remove_nan=None, normalize=None, points_min_radius=None, transform=None, center=None, level=PropertiesLevel.ALL)

Bases: object

Set of parameters related to plot’s data.

Parameters:
  • x_limits (tuple[Any, Any]) – Crop the plot’s data to the provided limits [x_min, x_max]

  • y_limits (tuple[Any, Any]) – Crop the plot’s data to the provided limits [y_min, y_max]

  • z_limits (tuple[Any, Any]) – Crop the plot’s data to the provided limits [z_min, z_max]

  • time_limits (tuple[Any, Any]) – [Map’s raw plots only] Crop the plot’s data to the provided limits [time_min, time_max]

  • remove_nan (bool) – Whether NaN values should be removed before plotting or not.

  • normalize (bool) – Whether histograms should be normalized or not

  • points_min_radius (float) – Minimum radius allowed between two points when plotting raw data on maps. The radius is expressed in meters. Underlying function: https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.reduce_point_density.html

  • center (str | int | float | None) –

    Centering options for the data. Allowed input values are:

    • numerical values (int/float) -> data_ctr = data - center

    • statistic (“mean”, “min”, …) -> data_ctr = data - np.nanmean(data)

  • transform (Union[str, Callable, None]) –

    Transformation options for the data. Allowed input values (including center parameter ones) are:

    • a function returning an array shaped like data -> data_ctr = f(data)

    • a clip characters string containing the VALUE word (at least once), numerical values, arithmetic operations and statistic names: “3*VALUE - MEAN/2 + 10” -> data_ctr = 3*data - np.nanmean(data)/2 + 10

  • limits (Properties | dict[str, Any])

  • properties (Properties | dict[str, Any])

  • level (PropertiesLevel)

drop_auto()

Drop all auto properties from this element.

has_limits()
Return type:

bool

html_elem(style='')
Parameters:

style (str)

Return type:

str

static html_header()
property normalize: bool
property points_min_radius: float
reduce_density(data, longitude, latitude, index, proj)

Reduce data density using the points_min_radius parameter if any.

Parameters:
  • data (Dataset) – Data to reduce.

  • longitude (str) – Longitude field’s name.

  • latitude (str) – Latitude field’s name.

  • index (str) – Index field’s name.

  • proj (Projection) – Used projection.

Return type:

Dataset

Returns:

Reduced data.

property remove_nan: bool
property time_limits: tuple[Any, Any]
to_level(level)

Convert all properties to the provided level.

Parameters:

level (PropertiesLevel) – Properties level to convert into.

property transform: Clip | Callable | None
transform_data(data)

Transform the data using the transform parameter if any.

Parameters:

data (DataArray) – Data to transform.

Return type:

tuple[ndarray, dict[str, Any]]

Returns:

Transformed data.

property transform_str: str | None
update(params, mode=PropertiesLevel.ALL, replace=False, only_missing=False)

Update the current DataParams with properties from the provided one.

Parameters:
  • params (DataParams | None) – GridParams to get values from.

  • mode (PropertiesLevel) – Update mode.

  • replace (bool) – Whether to replace existing properties or not.

  • only_missing (bool) – Whether to only add missing values or not.

property x_limits: tuple[Any, Any]
property y_limits: tuple[Any, Any]
property z_limits: tuple[Any, Any]
class casys.visualization.parameters.FeatureParams(feature=None, feature_kwargs=None, enabled=None, level=PropertiesLevel.ALL, properties=None)

Bases: object

Set of parameters relatives to the coastlines display in plot visualisation.

Parameters:
cartopy_kwargs()

Generate cartopy compatible kwargs.

Return type:

dict[str, Any]

drop_auto()

Drop all auto properties from this element.

enable(level=PropertiesLevel.USER, only_missing=True)
Parameters:
property feature
html_elem(style='')
Parameters:

style (str)

Return type:

str

static html_header()
property kwargs: dict[str, Any]
classmethod normalize_coastlines(*, coastlines)

Normalize the coastlines parameter value.

Parameters:

coastlines (bool | dict | FeatureParams | None) – Coastlines parameter value.

Return type:

FeatureParams

Returns:

Normalized coastlines parameter value.

static normalize_feature_properties(properties)

Normalize provided properties which might be given as a single boolean or flatten feature_kwargs.

Parameters:

properties (bool | dict[str, Any]) – Properties to normalize.

Return type:

dict[str, Any]

Returns:

Normalized properties.

property show: bool
to_level(level)

Convert all properties to the provided level.

Parameters:

level (PropertiesLevel) – Properties level to convert into.

update(params, mode=PropertiesLevel.ALL, replace=False, only_missing=False)

Update the current CoastlinesParams with properties from the provided one.

Parameters:
  • params (FeatureParams | None) – CoastlinesParams to get values from.

  • mode (PropertiesLevel) – Update mode.

  • replace (bool) – Whether to replace existing properties or not.

  • only_missing (bool) – Whether to only add missing values or not.

class casys.visualization.parameters.GridParams(line_properties=None, xlabel_style=None, ylabel_style=None, properties=None, top_labels=None, bottom_labels=None, right_labels=None, left_labels=None, kwargs=None, enabled=None, level=PropertiesLevel.ALL)

Bases: object

Set of parameters for gridliner in a map.

Parameters:
  • line_properties (Properties | dict[str, Any]) – A dictionary passed through to collections.LineCollection for styling of the line of the grid

  • xlabel_style (Properties | dict[str, Any]) – A dictionary passed through to ax.text for styling of the x-axis text labels

  • ylabel_style (Properties | dict[str, Any]) – A dictionary passed through to ax.text for styling of the y-axis text labels

  • top_labels (InitVar) – Whether to draw labels on the top of the map (default to False)

  • bottom_labels (InitVar) – Whether to draw labels on the bottom of the map (default to True)

  • right_labels (InitVar) – Whether to draw labels on the right-hand side of the map (default to False)

  • left_labels (InitVar) – Whether to draw labels on the left-hand side of the map (default to True)

  • kwargs (InitVar) – Additional parameters passed to the underlying matplotlib grid or cartopy gridlines method.

  • enabled (InitVar) – Whether this GridParams is enabled or not (internally used by schemas).

  • properties (Properties | dict[str, Any])

  • level (InitVar)

property axe_kwargs: dict[str, Any]
bottom_labels: InitVar = None
drop_auto()

Drop all auto properties from this element.

enable(level=PropertiesLevel.USER, only_missing=True)
Parameters:
enabled: InitVar = None
kwargs: InitVar = None
left_labels: InitVar = None
level: InitVar = 1
line_properties: Properties | dict[str, Any] = None
classmethod normalize(*, grid)
Parameters:

grid (bool | GridParams | None)

Return type:

GridParams

properties: Properties | dict[str, Any] = None
right_labels: InitVar = None
set_text_size(size)
Parameters:

size (Any)

property show: bool
to_level(level)

Convert all properties to the provided level.

Parameters:

level (PropertiesLevel) – Properties level to convert into.

top_labels: InitVar = None
update(params, mode=PropertiesLevel.ALL, replace=False, only_missing=False)

Update the current GridParams with properties from the provided one.

Parameters:
  • params (GridParams | None) – GridParams to get values from.

  • mode (PropertiesLevel) – Update mode.

  • replace (bool) – Whether to replace existing properties or not.

  • only_missing (bool) – Whether to only add missing values or not.

xlabel_style: Properties | dict[str, Any] = None
ylabel_style: Properties | dict[str, Any] = None
class casys.visualization.parameters.PlotParams(fig_width=None, fig_height=None, x_limits=None, y_limits=None, color_limits=None, color_map=None, discretize_cmap=None, color_bar=None, grid=None, show_reg=None, show_legend=None, fill_land=None, fill_ocean=None, mask_land=None, mask_ocean=None, coastlines=None, projection=None, color=None, marker_style=None, marker_size=None, line_style=None, line_width=None, bars=None, kwargs_figure=None, kwargs_plot=None, level=PropertiesLevel.ALL, properties=None)

Bases: object

Set of parameters related to plot’s visualization.

Parameters:
  • fig_width (float) – Figure width (default to 10).

  • fig_height (float) – Figure height (default to 6).

  • x_limits (tuple[Any, Any] | str | LimitsType) – Limit the plot view to the provided extent [x_min, x_max]. Default to (min, max). The “auto” option allows to compute adapted color limits: (mean-3*std, mean+3*std). Use a tuple with the format (“p”, (p_min, p_max)) or (“p”, p_value) to fix limits according to the percentiles in the data. For p_value, the percentile limits (p_min, p_max) equivalence is: ( (100-value)/2, (100+value)/2 ).

  • y_limits (tuple[Any, Any] | str | LimitsType) – Limit the plot view to the provided extent [y_min, y_max]. Default to (min, max). The “auto” option allows to compute adapted color limits: (mean-3*std, mean+3*std). Use a tuple with the format (“p”, (p_min, p_max)) or (“p”, p_value) to fix limits according to the percentiles in the data. For p_value, the percentile limits (p_min, p_max) equivalence is: ( (100-value)/2, (100+value)/2 ).

  • color_limits (tuple[Any, Any] | str | LimitsType) – Color bar minimum and maximum values. Default to (min, max). The “auto” option allows to compute adapted color limits: (mean-3*std, mean+3*std). Use a tuple with the format (“p”, (p_min, p_max)) or (“p”, p_value) to fix limits according to the percentiles in the data. For p_value, the percentile limits (p_min, p_max) equivalence is: ( (100-value)/2, (100+value)/2 ).

  • color_map (str | Colormap | list | dict) –

    Color mapping (default to viridis): The following types and format are available, depending on the discretize_cmap flag value.

    When discretize_cmap is False:
    • Custom ColorMap object from matplotlib.cm

    • Name (as a string) of an existing colormap in matplotlib

    When discretize_cmap is True:
    • Custom ListedColorMap from matplotlib.cm

    • Name of an existing matplotlib colormap (needs to be a ListedColorMap)

    • List of: - strings representing either a known color name (“red” or “b”), or

      a hexadecimal value of a color (“#RRGGBBAA” or “#RRGGBB”)

      • tuple or list of ints in the 0-1 range, coding for an RGB/RGBA color ( (R, G, B, A) or (R, G, B) )

      • None, resulting in no display for the corresponding value

    • Dictionary specifying a correspondence value: color, respecting the color coding described above. More values than those actually present in the data can be provided in this dictionary.

  • discretize_cmap (bool) –

    Color mapping option (default to False):
    • True: Discretize the colormap according to the data to display

    • False: Keep current colormap

  • color_bar (AxeParams | str | bool) –

    Color bar specifications (default to True):
    • True/False: Whether to display a bottom color bar or not.

    • string: Label for a bottom color bar.

    • AxeParams: Full specification for a color bar.

  • grid (GridParams | bool) –

    Grid specification (default to True):
    • True/False: Whether to display a grid or not.

    • GridParam: Full specification of the grid.

  • show_reg (bool) – Display the regression curve (scatter).

  • show_legend (bool) – True: Force the legend to be displayed on single curve graphics. False: Force the legend to be hidden on multi curve graphics. None (default): Only display legend on multi curve graphics.

  • fill_land (bool) – Color continents (cartography).

  • fill_ocean (bool) – Color oceans (cartography).

  • mask_land (bool) – Hide continents data (cartography).

  • mask_ocean (bool) – Hide oceans data (cartography).

  • coastlines (bool | dict[str, Any] | FeatureParams) – Draw the coastlines with the provided parameters (cartography).

  • projection (Projection | str) – Change the map projection.

  • color (str) – Color of the plot.

  • marker_style (str) – Plot markers style.

  • marker_size (int | float) – Plot/scatter markers size.

  • line_style (str) – Plot line style.

  • line_width (float) – Plot line width.

  • bars (bool) – Display graphics as bars (Default: True for histograms, False otherwise).

  • kwargs_figure (dict[str, Any]) – Additional parameters passed to the underlying matplotlib Figure class.

  • kwargs_plot (dict[str, Any]) – Additional parameters passed to the underlying matplotlib plotting method.

  • level (PropertiesLevel) – Property level to use.

  • properties (Properties | dict[str, Any])

property bars: bool
property coastlines: FeatureParams
property color: str
property color_bar: AxeParams
property color_limits: tuple[Any, Any]
property color_map: Colormap | str | list | tuple
property discretize_cmap: bool
drop_auto()

Drop all auto properties from this element.

property fig_height: int
property fig_width: int
property fill_land: bool
property fill_ocean: bool
property grid: GridParams
has_bounds()

Test whether this parameter have x or y limits.

Return type:

bool

property has_coastlines: bool
property has_color_bar: bool
property has_grid: bool
property hide_legend: bool
html_elem(style='')
Parameters:

style (str)

Return type:

str

static html_header()
property kwargs_figure: dict[str, Any]
property kwargs_plot: dict[str, Any]
property line_style: str
property line_width: float
property marker_size: int
property marker_style: str
property mask_land: bool
property mask_ocean: bool
property projection: Projection
property show_legend: bool
property show_reg: bool
to_level(level)

Convert all properties to the provided level.

Parameters:

level (PropertiesLevel) – Properties level to convert into.

update(params, mode=PropertiesLevel.ALL, replace=False, only_missing=False)

Update the current PlotParams with properties from the provided one.

Parameters:
  • params (PlotParams | None) – PlotParams to get values from.

  • mode (PropertiesLevel) – Update mode.

  • replace (bool) – Whether to replace existing properties or not.

  • only_missing (bool) – Whether to only add missing values or not.

property x_limits: tuple[Any, Any]
property y_limits: tuple[Any, Any]
class casys.visualization.parameters.PlotTemplate(title=None, x1=None, x2=None, y1=None, y2=None, stat_bar=None, color_bar=None, hist_bar_x=None, hist_bar_y=None, hist_bar_z=None, stat_graph_x=None, stat_graph_y=None, legend=None, plot=None, grid=None, coastlines=None, data=None, ticks_spaces=<factory>, watermarks=<factory>, description=None, text=None)

Bases: object

Template containing all plot’s elements properties.

Parameters:
  • title (AxeParams | None) – Properties of the title (AxeParams).

  • legend (AxeParams | None) – Properties of the legend (AxeParams).

  • x1 (AxeParams | None) – Properties of the main x-axis (AxeParams).

  • x2 (AxeParams | None) – Properties of the second x-axis (AxeParams).

  • y1 (AxeParams | None) – Properties of the main y-axis (AxeParams).

  • y2 (AxeParams | None) – Properties of the second y-axis (AxeParams).

  • stat_bar (AxeParams | None) – Properties of the statistics bar (AxeParams).

  • color_bar (AxeParams | None) – Properties of the color bar (AxeParams).

  • hist_bar_x (AxeParams | None) – Properties of the x-axis histogram (AxeParams).

  • hist_bar_y (AxeParams | None) – Properties of the y-axis histogram (AxeParams).

  • hist_bar_z (AxeParams | None) – Properties of the z-axis histogram (AxeParams).

  • stat_graph_x (AxeParams | None) – Properties of the x-axis statistics graphic (AxeParams).

  • stat_graph_y (AxeParams | None) – Properties of the y-axis statistics graphic (AxeParams).

  • plot (PlotParams | None) – Properties of the plot (PlotParams).

  • data (DataParams | None) – Properties of the data (DataParams).

  • grid (GridParams | None) – Properties of the grid (GridParams).

  • coastlines (FeatureParams | None) – Properties of the coastlines (FeatureParams).

  • ticks_spaces (list[tuple[Position, float]]) – Ticks spaces to apply to each position.

  • watermarks (list[WatermarkParams]) – List of watermarks.

  • description (str | None) – Description of the template.

  • text (InitVar) – Textual elements properties to apply to other elements (TextParams).

axe_elements: list[ElementType]
axes_params()

Get a list of all enabled axes parameters.

Return type:

list[tuple[AxisType, AxeParams]]

Returns:

List of enabled axes parameters.

coastlines: FeatureParams | None = None
color_bar: AxeParams | None = None
compute_plot_params(*, x, y, z=None)

Return updated PlotTemplate regarding colormap and colorbar discretization.

Parameters:
Return type:

PlotParams

Returns:

Updated PlotTemplate object.

computed_color_bar(*, data)

Compute the color bar (required for discretized color maps).

Parameters:

data (ndarray) – Plot’s data.

Return type:

AxeParams

Returns:

Computed color bar.

data: DataParams | None = None
description: str | None = None
drop_auto()

Drop all auto properties from this template.

get_element(element)

Get an element referenced by its type.

Parameters:

element (ElementType | AxisType) – Type of the element.

Return type:

AxeParams

Returns:

Element.

grid: GridParams | None = None
hist_bar_x: AxeParams | None = None
hist_bar_y: AxeParams | None = None
hist_bar_z: AxeParams | None = None
hist_bars()

Get a list of all enabled hist_bars.

Return type:

list[AxeParams]

Returns:

List of enabled hist_bars.

legend: AxeParams | None = None
static load(name, path=None, reload=False)

Get a registered or stored template.

Templates from the provided path will be added to the template registry.

Parameters:
  • name (str) – Name of the template.

  • path (str) – Optional custom path to use.

  • reload (bool) – Whether to force the reloading of an already loaded path or not.

Return type:

PlotTemplate

Returns:

Registered template.

classmethod normalize(template)
Parameters:

template (str | PlotTemplate | None)

Return type:

PlotTemplate

plot: PlotParams | None = None
register(name)

Register a template, so it can be used by its name.

Parameters:

name (str) – Name given to the template.

resize_text(size, elements)

Resize the text of the provided elements.

Parameters:
set_element(axt, params)

Set an element referenced by its type.

Parameters:
set_hist_bar(params)
Parameters:

params (AxeParams)

set_stat_graph(params)
Parameters:

params (AxeParams)

classmethod set_template(template=None, data_params=None, plot_params=None, text_params=None, level=PropertiesLevel.ALL)

Create a new template using provided parameters.

Provided template’s auto level properties are ignored.

Parameters:
Return type:

PlotTemplate

Returns:

New updated template.

stat_bar: AxeParams | None = None
stat_graph_x: AxeParams | None = None
stat_graph_y: AxeParams | None = None
stat_graphs()

Get a list of all enabled stat_graphs.

Return type:

list[AxeParams]

Returns:

List of enabled stat_graphs.

store(name, path, overwrite=False)

Store this template to a file.

Parameters:
  • name (str) – name of the template

  • path (str) – path of the file

  • overwrite (bool) – Whether to overwrite any existing file or not.

text: InitVar = None
ticks_spaces: list[tuple[Position, float]]
title: AxeParams | None = None
to_level(level)

Convert all properties to the provided level.

Parameters:

level (PropertiesLevel) – Properties level to convert into.

update(params, mode=PropertiesLevel.ALL, only_missing=False)

Update template.

Parameters:
  • params (PlotTemplate) – Template parameters.

  • mode (PropertiesLevel) – Update mode.

  • only_missing (bool) – Whether to only add missing values or not.

update_coastlines(params, mode=PropertiesLevel.ALL)

Update coastlines parameters.

Parameters:
update_data(params, mode=PropertiesLevel.ALL, replace=False)

Update data parameters.

Parameters:
  • params (DataParams) – Data parameters.

  • mode (PropertiesLevel) – Update mode.

  • replace (bool) – Whether to replace existing properties or not.

update_grid(params, mode=PropertiesLevel.ALL)

Update grid parameters.

Parameters:
update_plot(params, mode=PropertiesLevel.ALL, replace=False)

Update plot, color_bar, grid and coastlines properties using provided PlotParams.

Parameters:
  • params (PlotParams) – Plot parameters.

  • mode (PropertiesLevel) – Update mode.

  • replace (bool) – Whether to replace existing properties or not.

update_text(params, mode=PropertiesLevel.ALL)

Update text properties for all elements using the provided parameters.

Parameters:
watermarks: list[WatermarkParams]
x1: AxeParams | None = None
x2: AxeParams | None = None
y1: AxeParams | None = None
y2: AxeParams | None = None
class casys.visualization.parameters.TemplateManager

Bases: object

Class managing the template objects.

PATH_LOADED: ClassVar[list[str | None]] = []
TEMPLATES: ClassVar[dict[str, PlotTemplate]] = {}
classmethod add_template(name, template)
Parameters:
classmethod get_template(name, path=None, reload=False)

Get a registered template.

Parameters:
  • name (str) – Name of the template.

  • path (str) – Optional custom path to use.

  • reload (bool) – Whether to force the reloading of an already loaded path or not.

Return type:

PlotTemplate

Returns:

Registered template.

classmethod load_path(path=None, reload=False)

Load templates from the provided path. Loaded template will be added to currently loaded ones and made available through their name.

Parameters:
  • path (str) – Path to load.

  • reload (bool) – Whether to force the reloading of an already loaded path or not.

classmethod store(name, path, template, overwrite=False)

Store this template into a file.

Existing templates from the provided path will be added to the current registry.

Parameters:
  • name (str) – Name of the template.

  • template (PlotTemplate) – Template to store.

  • path (str) – Path of the file

  • overwrite (bool) – Whether to overwrite any existing file or not.

class casys.visualization.parameters.TemplateRecords(templates=<factory>)

Bases: object

Template records class.

Parameters:

templates (dict[str, PlotTemplate])

templates: dict[str, PlotTemplate]
class casys.visualization.parameters.TextParams(xlabel=<factory>, ylabel=<factory>, clabel=<factory>, slabel=<factory>, legend=<factory>, title=<factory>, level=PropertiesLevel.ALL)

Bases: object

Set of text parameters for a plot.

Each parameter can be provided as a string (used as title for the parameter) or a dictionary passed to the underlying matplotlib function.

Parameters:
clabel: Properties | dict[str, Any] | str
html_elem(style='')
Parameters:

style (str)

Return type:

str

static html_header()
legend: Properties | dict[str, Any] | str
level: InitVar = 1
slabel: Properties | dict[str, Any] | str
title: Properties | dict[str, Any] | str
update(params, level=PropertiesLevel.ALL, only_missing=False)

Update this TextParams with values from another one.

Parameters:
  • params (TextParams | None) – TextParams to get values from.

  • level (PropertiesLevel) – Update level.

  • only_missing (bool) – Whether to only add missing values or not.

xlabel: Properties | dict[str, Any] | str
ylabel: Properties | dict[str, Any] | str
class casys.visualization.parameters.WatermarkParams(image, image_size=None, kwargs=None)

Bases: object

Parameters of a watermark.

Parameters:
has_image_size()
image: str | ndarray
image_size: tuple[int, int] | int | None = None
kwargs: dict[str, Any] | None = None
casys.visualization.parameters.check_color_map(*, color_map)

Check provided color_map value.

Parameters:

color_map (str | Colormap | list | dict | None) – Colormap value to check.

casys.visualization.parameters.check_limits(*, limits)

Check provided limits values.

Parameters:

limits (tuple[Any, Any] | str | LimitsType | None) – Limits values to check.

casys.visualization.parameters.check_transform_parameters(*, transform, center=None)

Check the transform and center parameters supplied to DataParams.

Parameters:
casys.visualization.parameters.compute_discretized_cmap(*, cmap, data)

Compute a discretized cmap by performing the extraction and discretization of an input colormap according to the input data.

Parameters:
Return type:

ListedColormap

Returns:

Normalized and discretized output colormap.

casys.visualization.parameters.compute_discretized_colorbar_boundaries(*, values)

Compute the boundary values associated with unique ordered values.

Parameters:

values (ndarray) – Ordered unique values to create boundaries from.

Return type:

ndarray

Returns:

boundary values.

casys.visualization.parameters.compute_discretized_colorbar_params(*, data, cmap=None)

Compute the colorbar parameters for a given data input.

Parameters:
Return type:

tuple[BoundaryNorm, list[str], ndarray]

Returns:

norm

Normalization object to be applied to the colorbar.

ticks_labels

Labels of the colorbar ticks.

ticks_values

Position of the colorbar ticks.

casys.visualization.parameters.compute_discretized_colorbar_ticks(*, bounds)

Compute ticks values for a discretized colorbar from the colorbar boundaries.

Parameters:

bounds (ndarray) – boundary values of the discretized colorbar.

Return type:

ndarray

Returns:

ticks values.

casys.visualization.parameters.compute_limits(*, limits, data)

Compute the limits according to the limits_type and limits_values parameters.

Parameters:
Return type:

tuple[float, float]

Returns:

Limits values

casys.visualization.parameters.compute_repr_transform_clip(*, clip)

String representation for transformation’s clip.

Parameters:

clip (Clip)

casys.visualization.parameters.compute_stat_bar_values(*, data)

Compute statistics bar values for the provided data.

Parameters:

data (DataArray) – Data for which to compute statistics.

Returns:

Data’s statistics.

casys.visualization.parameters.discretize_cmap(*, cmap, data, select_first=False)

Discretize a colormap parameter according to the input data.

Parameters:
  • cmap (str | list | dict | tuple | Colormap) – Input colormap parameter.

  • data (ndarray) – Data to plot with the colormap.

  • select_first (bool) – Selecting method for colors list colormap input. True: select in order, False: select evenly.

Return type:

ListedColormap

Returns:

Discretized output colormap.

casys.visualization.parameters.extract_cmap(*, cmap)

Extract a Colormap object from the colormap input, normalizing and checking the colors.

Parameters:

cmap (str | list | dict | tuple | Colormap) – Input colormap.

Return type:

Colormap | ListedColormap

Returns:

Normalized output colormap.

casys.visualization.parameters.normalize_transform(transform)

Normalize the center option value.

Parameters:

transform (Union[str, int, float, Callable, None]) – Transform operation value to normalize.

Return type:

Union[Clip, Callable, None]

Returns:

Normalized transform operation value.