wolfhece.PyPalette

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.wolfpalette(parent=None, title=_('Colormap'), w=100, h=500, nseg=1024)[source]

Bases: wx.Frame, matplotlib.colors.LinearSegmentedColormap

Inheritance diagram of wolfhece.PyPalette.wolfpalette

Color palette based on the “LinearSegmentedColormap” object from Matplotlib (Colormap objects based on lookup tables using linear segments)

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]
wx_exists[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, wx_permitted=True)[source]

Distribution of the palette values

Parameters:
  • minval – minimum value

  • maxval – maximum value

  • step – distribution step

If the step is provided, it 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

fillgrid(gridto: wolfhece.CpGrid.CpGrid)[source]

Fill a grid with the palette values

updatefromgrid(gridfrom: wolfhece.CpGrid.CpGrid)[source]

Update the palette based on a grid

updatefrompalette(srcpal)[source]

Update the palette based on another one

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

lookupcolor(x)[source]
lookupcolorflt(x)[source]
lookupcolorrgb(x)[source]
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]

Lecture de la palette sur base d’un fichier WOLF .pal

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