magneticalc.Metric

# ``magneticalc`.`Metric``

module documentation

Metric module.

Class | `Metric` | Provides different metrics, used for mapping some field vector properties to some color and alpha range.
Function | `color_map_cyclic` | Maps normalized value to color, cyclic.
Function | `color_map_divergent` | Maps normalized value to color, divergent.
Function | `metric_divergence` | Calculates the divergence of a sampling volume neighborhood.
Function | `metric_norm` | Calculates the selected norm of some vector.

@ConditionalDecorator(get_jit_enabled(), jit, nopython=True, parallel=False)
def color_map_cyclic(color_normalized: `float`) -> `np.ndarray`:

Maps normalized value to color, cyclic.

Note: For JIT to work, this must be declared at the top level.

Parameters
color_normalized: `float` | Normalized color value

Returns
`np.ndarray` | R, G, B

@ConditionalDecorator(get_jit_enabled(), jit, nopython=True, parallel=False)
def color_map_divergent(color_normalized: `float`) -> `np.ndarray`:

Maps normalized value to color, divergent.

Note: For JIT to work, this must be declared at the top level.

Parameters
color_normalized: `float` | Normalized color value

Returns
`np.ndarray` | R, G, B

@ConditionalDecorator(get_jit_enabled(), jit, nopython=True, parallel=False)
def metric_divergence(neighborhood_vectors: `np.ndarray`, dL: `float`, polarity: `int`) -> `float`:

Calculates the divergence of a sampling volume neighborhood.

Note: For JIT to work, this must be declared at the top level.

Parameters
neighborhood_vectors: `np.ndarray` | Sampling volume neighborhood vectors (six 3D vectors)
dL: `float` | Length element
polarity: `int` | Polarity filter (-1: Keep values <= 0; 0: Keep all values; +1: Keep values >= 0)

Returns
`float` | Undocumented

@ConditionalDecorator(get_jit_enabled(), jit, nopython=True, parallel=False)
def metric_norm(norm_type: `int`, vector: `np.ndarray`) -> `float`:

Calculates the selected norm of some vector.

Note: For JIT to work, this must be declared at the top level.

Parameters
norm_type: `int` | Norm type
vector: `np.ndarray` | 3D vector

Returns
`float` | Scalar if successful, np.inf on error