reemission.salib.accessors
Collection of classes and functions for accessing and modifying parameters and inputs in ReEmission with SALib. This module provides protocols and dataclasses for accessing model parameters and inputs, required for allowing Re-Emission to interact with the SALib library for global sensitivity analysis. It includes: - get_input_value: Function to retrieve input values by group and name. - AccessProtocol: Protocol for accessing model parameters. - ConfigParameterAccess: Dataclass for accessing and modifying emission parameters in configurations. - InputAccess: Dataclass for accessing and modifying inputs. - ReadOnlyParameterError: Exception raised when attempting to modify a read-only parameter. - ReadOnlyInputError: Exception raised when attempting to modify a read-only input.
- class reemission.salib.accessors.AccessProtocol(*args, **kwargs)[source]
Bases:
Protocol
Protocol for accessing model parameters.
- get_value() Any | None [source]
Get the value of a parameter by its name.
- set_value(value: Any) None [source]
Set the value of a parameter by its name.
- class reemission.salib.accessors.ConfigParameterAccess(config_name: str, key_path: str | ~typing.Tuple[str, ...], config: ~reemission.config_loader.ConfigLoader = <reemission.config_loader.ConfigLoader object>, read_only: bool = False, verbose: bool = False)[source]
Bases:
AccessProtocol
Protocol for accessing emission parameters. .. attribute:: config_name
Name of the configuration to access.
- type:
str
- key_path
Path to the parameter in the configuration.
- Type:
str | Tuple[str, …]
- config
ConfigLoader instance to access configurations.
- Type:
reemission.config_loader.ConfigLoader
- read_only
If True, prevents modification of parameters.
- Type:
bool
- verbose
If True, enables verbose output.
- Type:
bool
- Raises:
ValueError – If key_path is empty or not a tuple.
- __post_init__()[source]
Initialize the ConfigParameterAccess.
- config: ConfigLoader = <reemission.config_loader.ConfigLoader object>
- config_name: str
- get_value() Any | None [source]
Get the value of an emission parameter by its name.
- key_path: str | Tuple[str, ...]
- property param_name: str
Get parameter name from key path.
- read_only: bool = False
- property root_path: Tuple[str, ...]
Get the root path of the input.
- set_value(value: Any) None [source]
Set the value of an emission parameter by its name.
- Raises:
ReadOnlyParameterError – If the parameter is read-only.
- verbose: bool = False
- class reemission.salib.accessors.InputAccess(input: Input, key_path: str | Tuple[str, ...], read_only: bool = False, verbose: bool = False)[source]
Bases:
AccessProtocol
Protocol for accessing inputs. .. attribute:: input
Input object used for model parameter access.
- type:
reemission.input.Input
- key_path
Path to the input data.
- Type:
str | Tuple[str, …]
- read_only
If True, prevents modification of parameters.
- Type:
bool
- verbose
If True, enables verbose output.
- Type:
bool
- Raises:
ValueError – If key_path is empty or not a tuple.
- __post_init__()[source]
Initialize the InputAccess.
- get_value() Any | None [source]
Get the value of an input by its name.
- input: Input
- key_path: str | Tuple[str, ...]
- property param_name: str
Get parameter name from key path.
- read_only: bool = False
- property root_path: Tuple[str, ...]
Get the root path of the input.
- set_value(value: Any) None [source]
Set the value of an input by its name.
- verbose: bool = False
- exception reemission.salib.accessors.ReadOnlyInputError[source]
Bases:
Exception
Raised when attempting to modify a read-only input.
- exception reemission.salib.accessors.ReadOnlyParameterError[source]
Bases:
Exception
Raised when attempting to modify a read-only parameter.
- reemission.salib.accessors.get_input_value(input_data: Input, group: Literal['reservoir', 'catchment'], input_name: str) Any [source]
Get inputs by group. :param input_data: Input object containing the data. :param group: Group of the input, either ‘reservoir’ or ‘catchment’. :param input_name: Name of the input variable to retrieve.
- reemission.salib.accessors.rprint(*args, **kwargs)[source]
Fallback print function if rich is not used.
Functions
|
Get inputs by group. |
|
Fallback print function if rich is not used. |
Classes
|
Protocol for accessing model parameters. |
|
Protocol for accessing emission parameters. |
|
Protocol for accessing inputs. |
Exceptions
Raised when attempting to modify a read-only input. |
|
Raised when attempting to modify a read-only parameter. |