reemission.salib.specloaders
- class reemission.salib.specloaders.ReEmissionSALibSpecLoader(spec_file: str | Path, input: Input, missing_input_dist_handler: Callable[[Numerical], Distribution] | None = None, set_access_to_read_only: bool = False)[source]
Bases:
object
Parses a YAML specification file for ReEmission sensitivity analysis with SALib.
- spec_file
Path to YAML file.
- Type:
str | pathlib.Path
- input
Input object used for model parameter access.
- Type:
- data
Immutable parsed specification.
- Type:
Dict[str, Any]
- missing_input_dist_handler
Function to handle missing input distributions.
- Type:
Callable[[reemission.salib.specloaders.Numerical], reemission.salib.distributions.Distribution] | None
- set_access_to_read_only
If True, prevents modification of parameters in accessors.
- Type:
bool
- Raises:
FileNotFoundError – If the spec_file does not exist.
ValueError – If the spec_file is not a YAML file or if required fields are missing
- property accessors: Dict[str, AccessProtocol]
Create a map of accessors for the parameters defined in the config file. :returns: A dictionary mapping parameter names to their accessors. :rtype: Dict[str, AccessProtocol]
- Raises:
ValueError – If ‘key_path’ or ‘par_type’ is missing in the variable definition.
- data: Dict[str, Any]
- input: Input
- property list_of_variables: List[Variable]
Create a list of variables from the spec_file. :returns: A list of Variable objects created from the spec_file. :rtype: List[Variable]
- Raises:
ValueError – If a variable does not have a distribution defined and is not an input type
- missing_input_dist_handler: Callable[[Numerical], Distribution] | None = None
- set_access_to_read_only: bool = False
- spec_file: str | Path
- property var_name_map: Dict[str, str]
A mapping between variable ‘symbol’ name and its full name for presentation and reporting
- class reemission.salib.specloaders.TestModelSALibSpecLoader(spec_file: str | Path)[source]
Bases:
object
Parses a YAML specification file for a test model with SALib. This loader is used to create a list of variables from the spec_file. .. attribute:: spec_file
Path to YAML file.
- type:
str | pathlib.Path
- data
Immutable parsed specification.
- Type:
Dict[str, Any]
- Raises:
FileNotFoundError – If the spec_file does not exist.
ValueError – If the spec_file is not a YAML file or if required fields are missing
- data: Dict[str, Any]
- property list_of_variables: List[Variable]
Create a list of variables from the spec_file. :returns: A list of Variable objects created from the spec_file. :rtype: List[Variable]
- Raises:
ValueError – If a variable dasoes not have a distribution defined and is not an input type
- spec_file: str | Path
- reemission.salib.specloaders.fix_distribution(distribution: Distribution, inplace: bool = False) Distribution [source]
Fix a distribution to a nominal value. :param distribution: The distribution to fix.
- Returns:
A fixed distribution with bounds set to the nominal value.
- Return type:
- reemission.salib.specloaders.freeze(obj: Any) Any [source]
Recursively freeze a data structure to make it immutable.
- reemission.salib.specloaders.set_unit_input_distribution_using_rel_diffrence(value: Numerical, rel_difference: float) Distribution [source]
Create a distribution for a proportional unit input. :param value: The base value for the distribution. :param rel_difference: The relative difference to apply to the value.
- Returns:
A distribution object with bounds set to the value ± relative difference.
- Return type:
- Raises:
ValueError – If the value is not positive or if the relative difference is not in (0, 1).
Functions
|
Fix a distribution to a nominal value. |
|
Recursively freeze a data structure to make it immutable. |
Create a distribution for a proportional unit input. |
Classes
|
Parses a YAML specification file for ReEmission sensitivity analysis with SALib. |
|
Parses a YAML specification file for a test model with SALib. |