reemission.salib.wrappers

class reemission.salib.wrappers.MCModelWrapperProtocol(*args, **kwargs)[source]

Bases: Protocol

get_index(var_name: str, raise_error: bool = False) int | None[source]

Gets variable index by its name

run(inputs: ndarray[tuple[Any, ...], dtype[NumpyValue]] | Iterable[Numerical]) NumpyValue | Numerical[source]
class reemission.salib.wrappers.ReEmissionSALibWrapper(input: ~reemission.input.Input, ix_name_map: ~typing.Dict[int, str], variables: ~typing.List[~reemission.salib.distributions.Variable], emission: str, p_model: str = 'g-res', accessors: ~typing.Dict[str, ~reemission.salib.accessors.AccessProtocol] = <factory>)[source]

Bases: object

A simple wrapper for ReEmission model to be used with SALib analysis. This wrapper takes a model function and a list of variables, and evaluates the model for given parameters. .. attribute:: input

Input object used for model parameter access.

type:

reemission.input.Input

ix_name_map

Mapping between variable index and variable name.

Type:

Dict[int, str]

output_variable

The output variable to be computed (‘co2_net’, ‘ch4_net’, ‘total_net’).

accessors

A dictionary of accessors for model parameters.

Type:

Dict[str, reemission.salib.accessors.AccessProtocol]

Raises:

ValueError – If the number of inputs does not match the number of parameters.

accessors: Dict[str, AccessProtocol]
emission: str
classmethod from_variables(variables: List[Variable], input: Input, emission: str, accessors: Dict[str, int]) ReEmissionSALibWrapper[source]

Create a ReEmissionSALibWrapper from a list of variables and an Input object. :param variables: List of Variable objects representing model parameters. :param input: Input object used for model parameter access. :param emission: The emission type to be computed (‘co2_net’, ‘ch4_net’, ‘total_net’). :param accessors: A dictionary of accessors for model parameters.

Returns:

An instance of the wrapper with the specified parameters.

Return type:

ReEmissionSALibWrapper

get_index(var_name: str, raise_error: bool = False) int | None[source]

Return index of the paremeter in the sequence of input values from the parameter name.

static get_input_dimension(inputs: ndarray[tuple[Any, ...], dtype[NumpyValue]] | Iterable[Numerical]) int[source]

Returns the number of parameters (columns if 2D, length if 1D) in SALibModelInputs.

static get_input_ndim(inputs: ndarray[tuple[Any, ...], dtype[NumpyValue]] | Iterable[Numerical]) int[source]

Returns the number of dimensions of SALibModelInputs. Raises ValueError if dimensions are greater than 2.

get_name(ix: int) str[source]

Return the name of the parameter based on index

input: Input
ix_name_map: Dict[int, str]
p_model: str = 'g-res'
run(inputs: ndarray[tuple[Any, ...], dtype[NumpyValue]] | Iterable[Numerical]) NumpyValue | Numerical[source]

Run the ReEmission model with inputs provided as a NDArray or an Iterable.

variables: List[Variable]
class reemission.salib.wrappers.SALibModelWrapperProtocol(*args, **kwargs)[source]

Bases: Protocol

Protocol defining the interface for model execution in the SALib package for global sensitivity analysis

get_index(var_name: str, raise_error: bool = False) int | None[source]

Gets variable index by its name

run(inputs: ndarray[tuple[Any, ...], dtype[NumpyValue]] | Iterable[Numerical]) NumpyValue | Numerical[source]

Run the model with inputs provided as a NDArray or an Iterable

class reemission.salib.wrappers.TestModelSALibWrapper(ix_to_par: Dict[int, str])[source]

Bases: object

A simple test model wrapper for SALib analysis.

This model takes a numpy array of parameters and returns a numpy array of results.

TODO: Check if SALib also runs models with multidimensional dataset. If so, modify the code.

__post_init__()[source]

Initialize the wrapper with a mapping from indices to parameter names.

classmethod from_variables(variables: List[Variable]) TestModelSALibWrapper[source]
get_index(var_name: str, raise_error: bool = False) int | None[source]

Get the index of a variable by its name, with lazy reverse mapping.

ix_to_par: Dict[int, str]
required_vars: ClassVar[List[str]] = ['a', 'b', 'c', 'd0', 'd1', 'd2', 'e', 'cont1', 'cont2', 'cat1', 'cat2']
run(inputs: ndarray[tuple[Any, ...], dtype[NumpyValue]] | Iterable[Numerical]) NumpyValue | Numerical[source]

Run the model with inputs provided as a NDArray or an Iterable. Note: inputs can be a single row of parameters or a 2D array with multiple rows.

static simple_test_model(par: Dict[str, Numerical]) NumpyValue | Numerical[source]

Simple input output model for testing SA with Sobol Indices and SALib

property variable_order: List[str]

Classes

MCModelWrapperProtocol(*args, **kwargs)

ReEmissionSALibWrapper(input, ix_name_map, ...)

A simple wrapper for ReEmission model to be used with SALib analysis.

SALibModelWrapperProtocol(*args, **kwargs)

Protocol defining the interface for model execution in the SALib package for global sensitivity analysis

TestModelSALibWrapper(ix_to_par)

A simple test model wrapper for SALib analysis.