iris.palette#

Color map pallettes management.

Load, configure and register color map palettes and initialise color map meta-data mappings.

class iris.palette.SymmetricNormalize(pivot, *args, **kwargs)[source]#

Bases: Normalize

Provides a symmetric normalization class around a given pivot point.

Parameters:
  • vmin (float or None) – Values within the range [vmin, vmax] from the input data will be linearly mapped to [0, 1]. If either vmin or vmax is not provided, they default to the minimum and maximum values of the input, respectively.

  • vmax (float or None) – Values within the range [vmin, vmax] from the input data will be linearly mapped to [0, 1]. If either vmin or vmax is not provided, they default to the minimum and maximum values of the input, respectively.

  • clip (bool, default: False) –

    Determines the behavior for mapping values outside the range [vmin, vmax].

    If clipping is off, values outside the range [vmin, vmax] are also transformed, resulting in values outside [0, 1]. This behavior is usually desirable, as colormaps can mark these under and over values with specific colors.

    If clipping is on, values below vmin are mapped to 0 and values above vmax are mapped to 1. Such values become indistinguishable from regular boundary values, which may cause misinterpretation of the data.

Notes

If vmin == vmax, input data will be mapped to 0.

__call__(value, clip=None)#

Normalize the data and return the normalized data.

Parameters:
  • value – Data to normalize.

  • clip (bool, optional) –

    See the description of the parameter clip in .Normalize.

    If None, defaults to self.clip (which defaults to False).

Notes

If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).

autoscale(A)#

Set vmin, vmax to min, max of A.

autoscale_None(A)#

If vmin or vmax are not set, use the min/max of A to set them.

property clip#
inverse(value)#

Maps the normalized value (i.e., index in the colormap) back to image data value.

Parameters:

value – Normalized value.

static process_value(value)#

Homogenize the input value for easy and efficient normalization.

value can be a scalar or sequence.

Parameters:

value – Data to normalize.

Returns:

  • result (masked array) – Masked array with the same shape as value.

  • is_scalar (bool) – Whether value is a scalar.

Notes

Float dtypes are preserved; integer types with two bytes or smaller are converted to np.float32, and larger types are converted to np.float64. Preserving float32 when possible, and using in-place operations, greatly improves speed for large arrays.

scaled()#

Return whether vmin and vmax are both set.

property vmax#
property vmin#
iris.palette.auto_palette(func)[source]#

Auto palette decorator wrapper function to control the default behaviour.

Decorator wrapper function to control the default behaviour of the matplotlib cmap and norm keyword arguments.

Parameters:

func (callable) – Callable function to be wrapped by the decorator.

Return type:

Closure wrapper function.

iris.palette.cmap_norm(cube)[source]#

Determine the default.

Determine the default matplotlib.colors.LinearSegmentedColormap and iris.palette.SymmetricNormalize instances associated with the cube.

Parameters:

cube (iris.cube.Cube) – Source cube to generate default palette from.

Returns:

Tuple of matplotlib.colors.LinearSegmentedColormap and iris.palette.SymmetricNormalize.

Return type:

tuple

Notes

This function maintains laziness when called; it does not realise data. See more at Real and Lazy Data.

iris.palette.is_brewer(cmap)[source]#

Determine whether the color map is a Cynthia Brewer color map.

Parameters:

cmap – The color map instance.

Return type:

bool