plots.styles.levels

Classes

Levels

Class defining levels to use with a mapping style.

Functions

auto_range(data[, divergence_point, n_levels])

Generate a suitable range of levels for arbitrary input data.

categorical_range(values)

Generate a range of levels for categorical data.

step_range(data, step[, reference])

Generate a range of levels for some data based on a level step and multiple.

Module Contents

class plots.styles.levels.Levels(levels=None, step=None, reference=None, divergence_point=None, categorical=False)

Class defining levels to use with a mapping style.

Parameters:
  • levels (list, optional) – A static list of levels to always use, no matter the input data.

  • step (float, optional) – The step/difference between each level in the desired level range.

  • reference (float, optional) – The reference point around which to calibrate the level range. For example, if a step of 4 is used and a reference of 2 is used, then the generated levels will be generated as steps of 4 above and below the number 2.

  • divergence_point (float, optional) – If provided, force the levels to be centred on this point. This is mostly useful for parameters which use diverging colors in their style, such as anomalies.

apply(data)

Generate levels specific to some data.

Parameters:

data (numpy.ndarray or xarray.DataArray or earthkit.data.core.Base) – The data for which to generate a list of levels.

Return type:

list

classmethod from_config(config)
plots.styles.levels.auto_range(data, divergence_point=None, n_levels=schema.default_style_levels)

Generate a suitable range of levels for arbitrary input data.

Parameters:
  • data (numpy.ndarray or xarray.DataArray or earthkit.data.core.Base) – The data for which to generate a list of levels.

  • divergence_point (float, optional) – If provided, force the levels to be centered on this point. Useful for parameters that use diverging colors in their style, such as anomalies.

  • n_levels (int, optional) – The target number of levels to generate (default is 10).

Returns:

A list of levels spaced across the data range with easy-to-interpret intervals.

Return type:

list

plots.styles.levels.categorical_range(values)

Generate a range of levels for categorical data.

This can be necessary to make sure that categorical data falls inside the correct bins, as values at the edge of a bin may not be included in the bin.

Parameters:

values (numpy.ndarray or xarray.DataArray or earthkit.data.core.Base) – The data for which to generate a list of levels.

Return type:

list

plots.styles.levels.step_range(data, step, reference=None)

Generate a range of levels for some data based on a level step and multiple.

Parameters:
  • data (numpy.ndarray or xarray.DataArray or earthkit.data.core.Base) – The data for which to generate a list of levels.

  • step (float) – The step/difference between each level in the desired level range.

  • reference (float, optional) – The reference point around which to calibrate the level range. For example, if a step of 4 is used and a reference of 2 is used, then the generated levels will be generated as steps of 4 above and below the number 2.

Return type:

list