wolfhece.PyPalette._model ========================= .. py:module:: wolfhece.PyPalette._model .. autoapi-nested-parse:: 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 --------------- .. py:class:: wolfpaletteModel(parent=None, title='', w=100, h=500, nseg=1024) Bases: :py:obj:`matplotlib.colors.LinearSegmentedColormap` .. autoapi-inheritance-diagram:: wolfhece.PyPalette._model.wolfpaletteModel :parts: 1 :private-bases: 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 :class:`wolfpalette` subclass. .. py:attribute:: filename :type: str .. py:attribute:: nb :type: int .. py:attribute:: colors :type: numpy.array .. py:attribute:: colorsflt :type: numpy.array .. py:attribute:: colorsuint8 :type: numpy.array .. py:attribute:: values :value: None .. py:attribute:: colormin .. py:attribute:: colormax .. py:attribute:: nseg :value: 1024 .. py:attribute:: automatic :value: True .. py:attribute:: interval_cst :value: False .. py:property:: colormin_uint8 .. py:property:: colormax_uint8 .. py:method:: get_colors_f32() .. py:method:: get_colors_uint8() .. py:method:: set_bounds() .. py:method:: get_rgba(x: numpy.ndarray) Retrieve the color based on the value x :param x: array of values .. py:method:: get_rgba_oneval(x: float) Retrieve the color based on the value x .. py:method:: export_palette_matplotlib(name) .. py:method:: distribute_values(minval: float = -99999, maxval: float = -99999, step=0, **kwargs) Distribution of the palette values (data-only, no GUI dialogs). :param minval: minimum value (ignored if -99999) :param maxval: maximum value (ignored if -99999) :param step: distribution step; if provided, takes precedence over the maximum value .. py:method:: get_ScalarMappable_mpl() Retrieve the ScalarMappable object via Matplotlib .. py:method:: export_image(fn='', h_or_v: Literal['h', 'v', ''] = '', figax=None) Export image from colormap :param : fn : filepath or io.BytesIO() :param : h_or_v : configuration to save 'h' = horizontal, 'v' = vertical, '' = both .. py:method:: plot(fig: matplotlib.figure.Figure, ax: matplotlib.pyplot.Axes) Display the color palette .. py:property:: cmap Retrieve the color palette .. py:property:: _cmap_discrete Retrieve the discrete color palette .. py:property:: scalarmappable Retrieve the ScalarMappable object .. py:property:: vmin Retrieve the minimum value .. py:property:: vmax Retrieve the maximum value .. py:property:: norm Retrieve the normalization .. py:method:: updatefrompalette(srcpal) Update the palette based on another one We copy the values, we do not point to the object .. py:method:: lookupcolor_rgba(x) Lookup interpolated color for value x. :returns: (r, g, b, a) tuple with int values 0-255 .. py:method:: lookupcolorflt(x) Lookup interpolated color for value x. :returns: [r, g, b, a] list with float values 0.0-1.0 .. py:method:: lookupcolorrgb(x) Lookup interpolated color for value x. :returns: (r, g, b, a) tuple with int values 0-255 .. py:method:: default16() Default 16 color palette in WOLF .. py:method:: default_difference3() Default 3 color palette for differences in WOLF .. py:method:: set_values_colors(values: Union[list[float], numpy.ndarray], colors: Union[list[tuple[int]], numpy.ndarray, list[tuple[str]]]) Update the values and colors of the palette :param values: list or array of values :param colors: list or array of colors (RGB or RGBA) .. py:method:: set_discrete_values_colors(values: Union[list[float], numpy.ndarray], colors: Union[list[tuple[int]], numpy.ndarray, list[tuple[str]]]) Update the values and colors of the palette in discrete mode :param values: list or array of values :param colors: list or array of colors (RGB or RGBA) .. py:method:: set_linear_values_colors(values: Union[list[float], numpy.ndarray], colors: Union[list[tuple[int]], numpy.ndarray, list[tuple[str]]]) Update the values and colors of the palette in linear mode :param values: list or array of values :param colors: list or array of colors (RGB or RGBA) .. py:method:: set_values(values: Union[list[float], numpy.ndarray]) Update the values of the palette .. py:method:: defaultgray() Default gray palette in WOLF .. py:method:: fill_segmentdata() Update the color palette .. py:method:: readfile(*args) Read the palette from a WOLF .pal file .. py:method:: is_valid() Check the validity of the palette .. py:method:: is_discrete() Vérification si la palette est en mode discret .. py:method:: set_discrete(is_discrete: bool = True) Définition du mode discret de la palette .. py:method:: savefile(*args) Save the palette to a WOLF .pal file .. py:method:: isopop(array: numpy.ma.masked_array, nbnotnull: int = 99999) Remplissage des valeurs de palette sur base d'une équirépartition de valeurs .. py:method:: defaultgray_minmax(array: numpy.ma.masked_array, nbnotnull=99999) Remplissage des valeurs de palette sur base d'une équirépartition de valeurs .. py:method:: defaultblue_minmax(array: numpy.ma.masked_array, nbnotnull=99999) Remplissage des valeurs de palette sur base d'une équirépartition de valeurs .. py:method:: defaultred_minmax(array: numpy.ma.masked_array, nbnotnull=99999) Remplissage des valeurs de palette sur base d'une équirépartition de valeurs .. py:method:: defaultblue() Remplissage des valeurs de palette sur base d'une équirépartition de valeurs .. py:method:: defaultblue3() Remplissage des valeurs de palette sur base d'une équirépartition de valeurs