pyvale.validation.validtypes module

Named physical and uncertainty axes for validation data.

class EEpisOffset(*values)[source]

Bases: IntEnum

Select nominal observations or a coherent lower or upper shift.

NOMINAL = 0
LOWER = 1
UPPER = 2
class EValidAxis(*values)[source]

Bases: Enum

Name physical and uncertainty dimensions of observation arrays.

POINT = 1
COMPONENT = 2
TIME = 3
EPISTEMIC_TRANS = 4
EPISTEMIC = 4
EPISTEMIC_NUIS = 5
ALEATORY = 6
class EValidGeometry(*values)[source]

Bases: Enum

Identify how an observable is placed on physical support.

POINT = 1
LINE = 2
SURFACE = 3
VOLUME = 4
GLOBAL = 5
class ValidObservable(components, geometry, coords=None, connect=None, times=None, phys_units='', coord_units='', coord_frame='', time_units='')[source]

Bases: object

Describe the physical support, components and units of an observable.

Variables:
  • components (tuple[str, ]) – Unique names in component-axis order.

  • geometry (EValidGeometry) – Global or spatial geometry of the observable.

  • coords (ndarray or None) – Finite sampling coordinates of shape (n_points, 3), with xyz columns in coord_units and coord_frame. Omit for global data.

  • connect (dict[str, ndarray] or None) – Optional mesh connectivity keyed by element type. Each array has shape (n_elements, n_nodes_per_element) and indexes the coordinate rows.

  • times (ndarray or None) – Strictly increasing evaluation times of shape (n_times,), in time_units. None denotes steady data.

  • phys_units (str) – Units of observations and physical metric outputs.

  • coord_units (str) – Units of xyz coordinates.

  • coord_frame (str) – Coordinate frame of the sampling positions.

  • time_units (str) – Units of evaluation times.

components
geometry
coords
connect
times
phys_units
coord_units
coord_frame
time_units
__init__(components, geometry, coords=None, connect=None, times=None, phys_units='', coord_units='', coord_frame='', time_units='')
class EpistemicOffsets(lower, upper, axes=())[source]

Bases: object

Nonnegative magnitudes for coherent lower/upper value shifts.

Variables:
  • lower (ndarray or float) – Nonnegative magnitude subtracted from the samples. Shape follows axes, or scalar if axes is empty.

  • upper (ndarray or float) – Nonnegative magnitude added to the samples. Shape follows axes, or scalar if axes is empty.

  • axes (tuple[EValidAxis, ]) – Subset of (point, component, time) in canonical order. Magnitudes use observation units and do not vary across aleatory or sampled epistemic dimensions.

lower
upper
axes
__init__(lower, upper, axes=())
class ValidArray(data, axes, offsets=None)[source]

Bases: object

Borrow data with explicit axes; nominal selections share its memory.

Observation dtype and finiteness are checked when assembling a ValidCase. Other arrays may carry nonnumeric run identifiers. Borrowed observations and metadata must remain unchanged for the lifetime of a case.

Variables:
  • data (ndarray) – Array with one dimension per entry in axes. Observation arrays store real values and may use NaN for missing observations.

  • axes (tuple[EValidAxis, ]) – Present dimensions in canonical order (point, component, time, transferable, nuisance, aleatory). Absent dimensions are treated as singletons.

  • offsets (EpistemicOffsets or None) – Optional coherent shifts in the same units as the observations.

data
axes
offsets
select_aleatory(point_idx, component_idx, time_idx, *, epis_trans_idx=0, epis_nuis_idx=0, offset=EEpisOffset.NOMINAL)[source]

Select one conditional 1D sample, applying a coherent value shift.

Parameters:
  • point_idx (int) – Zero-based physical sampling point index.

  • component_idx (int) – Zero-based observable component index.

  • time_idx (int) – Zero-based evaluation time index.

  • epis_trans_idx (int, optional) – Zero-based transferable epistemic case index.

  • epis_nuis_idx (int, optional) – Zero-based nuisance epistemic case index.

  • offset (EEpisOffset, optional) – Coherent offset to apply to the selected aleatory observations.

Returns:

ndarray – A single conditional sample of shape (n_aleatory,). If the aleatory axis is absent, the shape is (1,). Nominal values can share the input memory.

__init__(data, axes, offsets=None)
class ValidSampleInputs(input_params=None, run_ids=None)[source]

Bases: object

Record provenance aligned with the uncertainty axes of observations.

Variables:
  • input_params (dict[str, ValidArray] or None) – Input parameter arrays keyed by name, indexed by named uncertainty dimensions.

  • run_ids (ValidArray or None) – Optional run identifiers on a matching subset of uncertainty dimensions.

input_params
run_ids
__init__(input_params=None, run_ids=None)
class ValidCase(observables, sim, exp, *, sim_inputs=None, exp_inputs=None)[source]

Bases: object

Validate and borrow observations and metadata without copying large arrays.

Variables:
  • observables (dict[str, ValidObservable]) – Observable metadata keyed by the shared observable tags.

  • sim (dict[str, ValidArray]) – Simulation arrays keyed by observable tag. Physical dimensions match the metadata; uncertainty dimensions can differ from exp.

  • exp (dict[str, ValidArray]) – Experimental arrays keyed by observable tag in the corresponding physical coordinates and units.

  • sim_inputs (ValidSampleInputs or None) – Optional input parameter arrays and run IDs aligned with simulation uncertainty axes.

  • exp_inputs (ValidSampleInputs or None) – Optional input parameter arrays and run IDs aligned with experiment uncertainty axes.

observables
sim
exp
sim_inputs
exp_inputs
__init__(observables, sim, exp, *, sim_inputs=None, exp_inputs=None)
class EMAVMDupes(*values)[source]

Bases: Enum

Selects the MAVM empirical-CDF integration algorithm.

REJECT = 'reject'

Full field compatible loop for unique floating point observations.

INCLUDE = 'include'

Probability weighted loop that supports repeated observations.

class MAVMBoundPairs(lower, upper, comparisons, lower_exp_idx, upper_exp_idx)[source]

Bases: object

Results defining the lower/upper support shifts and four endpoint comparisons.

Comparison order is model-lower/exp-lower, model-upper/exp-lower, model-lower/exp-upper, model-upper/exp-upper. lower/upper retain the selected MAVMResult objects. Lower is anchored to model-lower; upper to model-upper.

Variables:
  • lower (MAVMResult) – Comparison supplying the lower shift of the lower simulation curve.

  • upper (MAVMResult) – Comparison supplying the upper shift of the upper simulation curve.

  • comparisons (tuple[MAVMResult, MAVMResult, MAVMResult, MAVMResult]) – Four ordered endpoint comparisons, with simulation bound varying first inside each experimental bound.

  • lower_exp_idx (int) – Experimental endpoint index (0 for lower, 1 for upper) controlling the lower correction.

  • upper_exp_idx (int) – Experimental endpoint index controlling the upper correction.

lower
upper
comparisons
lower_exp_idx
upper_exp_idx
__init__(lower, upper, comparisons, lower_exp_idx, upper_exp_idx)
class EValidResAxis(*values)[source]

Bases: StrEnum

Name dimensions of metric results, distinguishing simulation and experiment cases.

POINT = 'point'
COMPONENT = 'component'
TIME = 'time'
SIM_TRANS = 'sim_trans'
SIM_NUIS = 'sim_nuis'
EXP_TRANS = 'exp_trans'
EXP_NUIS = 'exp_nuis'
SIM_OFFSET = 'sim_offset'
EXP_OFFSET = 'exp_offset'
class MetricField(axes, metric_vals, epis_offsets=None)[source]

Bases: object

Metric arrays in canonical result-axis order.

Axes are point, component, time, simulation transferable/nuisance epistemic, experiment transferable/nuisance epistemic, simulation offset, experiment offset. Physical axes are always present; singleton uncertainty axes are omitted. All output arrays share the same shape. A steady scalar observable commonly has shape (n_points, 1, 1); a transient vector has shape (n_points, n_components, n_times) before epistemic and offset axes.

Variables:
  • axes (tuple[EValidResAxis, ]) – Canonical names of the stored result dimensions.

  • metric_vals (dict[EMetricOut, ndarray]) – One array per metric output, all with the same shape in axes order. A cell represents one conditional simulation–experiment comparison.

  • epis_offsets (dict[EValidResAxis, tuple[EEpisOffset, ]] or None) – Ordered offset labels for any retained simulation and experiment offset axes.

axes
metric_vals
epis_offsets
__init__(axes, metric_vals, epis_offsets=None)
class ValidMetricExtrema(axes, reduced_axes, minimum, maximum, minimum_indices, maximum_indices, selectors)[source]

Bases: object

Extrema over reduced axes; index arrays append one column per reduced axis.

All-missing cells contain NaN and index -1. Ties choose the first original index in canonical result-axis order. Selected singleton axes are omitted.

Variables:
  • axes (tuple[EValidResAxis, ]) – Retained result axes, in array dimension order.

  • reduced_axes (tuple[EValidResAxis, ]) – Reduced dimensions represented by the final index-array axis.

  • minimum (dict[EMetricOut, ndarray]) – Minimum metric values by output, each of shape retained_shape.

  • maximum (dict[EMetricOut, ndarray]) – Maximum metric values by output, each of shape retained_shape.

  • minimum_indices (dict[EMetricOut, ndarray]) – Controlling indices by output, of shape (*retained_shape, n_reduced_axes).

  • maximum_indices (dict[EMetricOut, ndarray]) – Controlling indices for the maxima, with the same shape as minimum_indices.

  • selectors (dict[EValidResAxis, int]) – Fixed axis indices applied before reducing the fields.

axes
reduced_axes
minimum
maximum
minimum_indices
maximum_indices
selectors
__init__(axes, reduced_axes, minimum, maximum, minimum_indices, maximum_indices, selectors)
class ValidResult(observables, metrics, metric_configs)[source]

Bases: object

Borrow observables/field arrays and snapshot metric configurations.

Variables:
  • observables (dict[str, ValidObservable]) – Observable metadata keyed by tag.

  • metrics (dict[str, dict[EMetricType, MetricField]]) – Metric fields keyed first by observable tag, then by metric type.

  • metric_configs (dict[EMetricType, IValidMetric]) – Snapshot of the metric strategies and settings used to calculate the fields.

observables
metrics
metric_configs
__init__(observables, metrics, metric_configs)
find_extreme(observable, metric, *, output=None, maximum=True)[source]

Locate a finite extreme without reducing the stored result field.

Parameters:
  • observable (str) – Observable tag identifying matching metadata and observations.

  • metric (EMetricType) – Metric to select or evaluate.

  • output (EMetricOut or None, optional) – Metric output to select. Use None to infer a single available output.

  • maximum (bool, optional) – If True select the maximum; otherwise select the minimum. Nonfinite values are omitted.

Returns:

tuple[float, dict[EValidResAxis, int]] – Extreme value and its zero-based indices keyed by every stored result axis.