wolfhece.PyPalette._model

Author: HECE - University of Liege, Pierre Archambeau Date: 2024

Copyright (c) 2024 University of Liege. All rights reserved.

This script and its content are protected by copyright law. Unauthorized copying or distribution of this file, via any medium, is strictly prohibited.

Module Contents

class wolfhece.PyPalette._model.wolfpaletteModel(parent=None, title='', w=100, h=500, nseg=1024)[source]

Bases: matplotlib.colors.LinearSegmentedColormap

Inheritance diagram of wolfhece.PyPalette._model.wolfpaletteModel

Color palette data model based on LinearSegmentedColormap from Matplotlib (Colormap objects based on lookup tables using linear segments).

This class contains all data and computation logic without any wxPython dependency. For GUI functionality (dialogs, wx.Frame), use the wolfpalette subclass.

filename: str[source]
nb: int[source]
colors: numpy.array[source]
colorsflt: numpy.array[source]
colorsuint8: numpy.array[source]
values = None[source]
colormin[source]
colormax[source]
nseg = 1024[source]
automatic = True[source]
interval_cst = False[source]
property colormin_uint8[source]
property colormax_uint8[source]
get_colors_f32()[source]
get_colors_uint8()[source]
set_bounds()[source]
get_rgba(x: numpy.ndarray)[source]

Retrieve the color based on the value x

Parameters:

x – array of values

get_rgba_oneval(x: float)[source]

Retrieve the color based on the value x

export_palette_matplotlib(name)[source]
distribute_values(minval: float = -99999, maxval: float = -99999, step=0, **kwargs)[source]

Distribution of the palette values (data-only, no GUI dialogs).

Parameters:
  • minval – minimum value (ignored if -99999)

  • maxval – maximum value (ignored if -99999)

  • step – distribution step; if provided, takes precedence over the maximum value

get_ScalarMappable_mpl()[source]

Retrieve the ScalarMappable object via Matplotlib

export_image(fn='', h_or_v: Literal['h', 'v', ''] = '', figax=None)[source]

Export image from colormap

:param : fn : filepath or io.BytesIO() :param : h_or_v : configuration to save ‘h’ = horizontal, ‘v’ = vertical, ‘’ = both

plot(fig: matplotlib.figure.Figure, ax: matplotlib.pyplot.Axes)[source]

Display the color palette

property cmap[source]

Retrieve the color palette

property _cmap_discrete[source]

Retrieve the discrete color palette

property scalarmappable[source]

Retrieve the ScalarMappable object

property vmin[source]

Retrieve the minimum value

property vmax[source]

Retrieve the maximum value

property norm[source]

Retrieve the normalization

updatefrompalette(srcpal)[source]

Update the palette based on another one

We copy the values, we do not point to the object

lookupcolor_rgba(x)[source]

Lookup interpolated color for value x.

Returns:

(r, g, b, a) tuple with int values 0-255

lookupcolorflt(x)[source]

Lookup interpolated color for value x.

Returns:

[r, g, b, a] list with float values 0.0-1.0

lookupcolorrgb(x)[source]

Lookup interpolated color for value x.

Returns:

(r, g, b, a) tuple with int values 0-255

default16()[source]

Default 16 color palette in WOLF

default_difference3()[source]

Default 3 color palette for differences in WOLF

set_values_colors(values: list[float] | numpy.ndarray, colors: list[tuple[int]] | numpy.ndarray | list[tuple[str]])[source]

Update the values and colors of the palette

Parameters:
  • values – list or array of values

  • colors – list or array of colors (RGB or RGBA)

set_discrete_values_colors(values: list[float] | numpy.ndarray, colors: list[tuple[int]] | numpy.ndarray | list[tuple[str]])[source]

Update the values and colors of the palette in discrete mode

Parameters:
  • values – list or array of values

  • colors – list or array of colors (RGB or RGBA)

set_linear_values_colors(values: list[float] | numpy.ndarray, colors: list[tuple[int]] | numpy.ndarray | list[tuple[str]])[source]

Update the values and colors of the palette in linear mode

Parameters:
  • values – list or array of values

  • colors – list or array of colors (RGB or RGBA)

set_values(values: list[float] | numpy.ndarray)[source]

Update the values of the palette

defaultgray()[source]

Default gray palette in WOLF

fill_segmentdata()[source]

Update the color palette

readfile(*args)[source]

Read the palette from a WOLF .pal file

is_valid()[source]

Check the validity of the palette

is_discrete()[source]

Vérification si la palette est en mode discret

set_discrete(is_discrete: bool = True)[source]

Définition du mode discret de la palette

savefile(*args)[source]

Save the palette to a WOLF .pal file

isopop(array: numpy.ma.masked_array, nbnotnull: int = 99999)[source]

Remplissage des valeurs de palette sur base d’une équirépartition de valeurs

defaultgray_minmax(array: numpy.ma.masked_array, nbnotnull=99999)[source]

Remplissage des valeurs de palette sur base d’une équirépartition de valeurs

defaultblue_minmax(array: numpy.ma.masked_array, nbnotnull=99999)[source]

Remplissage des valeurs de palette sur base d’une équirépartition de valeurs

defaultred_minmax(array: numpy.ma.masked_array, nbnotnull=99999)[source]

Remplissage des valeurs de palette sur base d’une équirépartition de valeurs

defaultblue()[source]

Remplissage des valeurs de palette sur base d’une équirépartition de valeurs

defaultblue3()[source]

Remplissage des valeurs de palette sur base d’une équirépartition de valeurs