Skip to content

process_variable_values API Reference

geoloop.utils.helpers.process_variable_values

process_variable_values(
    results: Any,
    var_names: list[str],
    sample_da_shape: ndarray,
) -> np.ndarray

Process variable values from Monte Carlo simulation results into a structured sample array.

This function extracts variables from a results object and constructs a NumPy array that conforms to a given sample shape. Each variable's values are expanded and stacked to ensure consistent dimensionality.

Parameters:

Name Type Description Default
results object

Results from a Monte Carlo simulation run, containing attributes corresponding to variable names.

required
var_names list of str

List of variable names to extract from the results object. These will form one dimension of the output array.

required
sample_da_shape ndarray

Template array specifying the desired shape of the sample. Used to ensure consistency in the output array dimensions.

required

Returns:

Type Description
ndarray

Array containing variable values stacked according to the template shape. Missing variables are filled with None entries.

Notes
  • Each variable is expanded along new axes if needed to match the sample array's dimensionality.
  • Variables are stacked along the first axis in the order of var_names.