magneticalc.Metric.Metric

# ``magneticalc`.`Metric`.`Metric``

class documentation

`class Metric(Validatable):`

Constructor: `Metric()`

View In Hierarchy

Provides different metrics, used for mapping some field vector properties to some color and alpha range.

Static Method | `boost_colors` | "Boosts" an array of color values.
Method | `__init__` | Initializes an empty metric.
Method | `recalculate` | Recalculates color and alpha values for field.
Method | `set` | Sets the parameters.
Class Variable | `LengthScale` | Undocumented
Class Variable | `LogNormMin` | Undocumented
Instance Variable | `alpha_preset` | Undocumented
Instance Variable | `color_preset` | Undocumented
Property | `colors` | Returns calculated colors.
Property | `limits` | Returns calculated limits.
Static Method | `_divergence_worker` | Calculates the divergence values of a list of vectors.
Static Method | `_norm_worker` | Calculates the norm values of a list of vectors.
Static Method | `_normalize_worker` | Normalizes color and alpha norm values, populates final color values.
Instance Variable | `_colors` | Undocumented
Instance Variable | `_limits` | Undocumented

Inherited from `Validatable`:

Method | `valid.setter` | No summary
Property | `valid` | True if valid, False if invalid
Instance Variable | `_valid` | Undocumented

@staticmethod
@ConditionalDecorator(get_jit_enabled(), jit, nopython=True, parallel=True)
def boost_colors(boost: `float`, direction: `float`, colors: `np.ndarray`) -> `np.ndarray`:

"Boosts" an array of color values.

Parameters
boost: `float` | Boost value
direction: `float` | Boost direction
colors: `np.ndarray` | Colors (ordered list of 4-tuples)

Returns
`np.ndarray` | Colors (ordered list of 4-tuples)

def __init__(self):
overrides `magneticalc.Validatable.Validatable.__init__`

Initializes an empty metric.

This class holds a pair of metric presets. Using these metric presets, colors (including alpha channel) and field limits are calculated.

@validator
def recalculate(self, sampling_volume: `SamplingVolume`, field: `Field`, progress_callback: `Callable`) -> `bool`:

Recalculates color and alpha values for field.

Parameters
sampling_volume: `SamplingVolume` | SamplingVolume
field: `Field` | Field
progress_callback: `Callable` | Progress callback

Returns
`bool` | True (currently non-interruptable)

def set(self, color_preset: `dict`, alpha_preset: `dict`):

Sets the parameters.

Parameters
color_preset: `dict` | Color metric preset (dictionary)
alpha_preset: `dict` | Alpha metric preset (dictionary)

LengthScale: `float` =

Undocumented

LogNormMin: `float` =

Undocumented

alpha_preset =

Undocumented

color_preset =

Undocumented

@property
@require_valid
colors: `np.ndarray` =

Returns calculated colors.

@property
@require_valid
limits: `dict` =

Returns calculated limits.

@staticmethod
@ConditionalDecorator(get_jit_enabled(), jit, nopython=True, parallel=True)
def _divergence_worker(sampling_volume_neighborhood_indices: `list[np.ndarray]`, vectors: `np.ndarray`, dL: `int`, polarity: `int`) -> `np.ndarray`:

Calculates the divergence values of a list of vectors.

Parameters
sampling_volume_neighborhood_indices: `list[np.ndarray]` | Ordered list of sampling volume neighborhood indices
vectors: `np.ndarray` | Ordered list of 3D vectors
dL: `int` | Length element
polarity: `int` | Polarity filter (-1: Keep values <= 0; 0: Keep all values; +1: Keep values >= 0)

Returns
`np.ndarray` | Norm values

@staticmethod
@ConditionalDecorator(get_jit_enabled(), jit, nopython=True, parallel=True)
def _norm_worker(norm_type: `int`, vectors: `np.ndarray`) -> `np.ndarray`:

Calculates the norm values of a list of vectors.

Parameters
norm_type: `int` | Norm type
vectors: `np.ndarray` | Ordered list of 3D vectors

Returns
`np.ndarray` | Norm values

@staticmethod
@ConditionalDecorator(get_jit_enabled(), jit, nopython=True, parallel=True)
def _normalize_worker(color_map_id: `str`, color_is_log: `bool`, color_norm_values, color_norm_min: `float`, color_norm_max: `float`, alpha_is_log: `bool`, alpha_norm_values: `np.ndarray`, alpha_norm_min: `float`, alpha_norm_max: `float`, colors: `np.ndarray`) -> `np.ndarray`:

Normalizes color and alpha norm values, populates final color values.

Parameters
color_map_id: `str` | Color map ID
color_is_log: `bool` | Selects logarithmic normalizer for color
color_norm_values | Color norm values
color_norm_min: `float` | Minimum color norm value
color_norm_max: `float` | Maximum color norm value
alpha_is_log: `bool` | Selects logarithmic normalizer for alpha
alpha_norm_values: `np.ndarray` | Alpha norm values
alpha_norm_min: `float` | Minimum alpha norm value
alpha_norm_max: `float` | Maximum alpha norm value
colors: `np.ndarray` | Color value list to populate (list of 4D vectors)

Returns
`np.ndarray` | Color values (list of 4D vectors)

_colors: `np.ndarray` =

Undocumented

_limits: `dict` =

Undocumented