Input Model
This module contains classes and methods for managing input data used in the calculation of greenhouse gas (GHG) emissions from reservoirs. The module supports the loading and processing of input data from JSON files, providing a structured way to handle emission data for different reservoirs.
- Classes:
Input: Represents input data for emission calculations for a single reservoir.
Inputs: Manages a collection of Input instances, representing multiple reservoirs.
- The module supports:
Loading emission data from JSON files.
Providing default values for optional fields.
Retrieving specific data subsets (e.g., reservoir data, catchment data, emission gases, year vectors).
Adding new input data to the collection.
Typical usage example:
input_file = 'path/to/input.json'
reservoir_name = 'example_reservoir'
# Load input data for a specific reservoir from a JSON file
input_data = Input.fromfile(file=input_file, reservoir_name=reservoir_name)
# Access specific data
reservoir_data = input_data.reservoir_data
catchment_data = input_data.catchment_data
gasses = input_data.gasses
year_vector = input_data.year_vector
monthly_temps = input_data.monthly_temps
# Manage multiple inputs
inputs_collection = Inputs.fromfile(file=input_file)
new_input_dict = {'new_reservoir': {'data_key': 'data_value'}}
inputs_collection.add_input(new_input_dict)
- class reemission.input.Input(name: str, data: Dict, enum_load_method: Literal['name', 'value'] = 'value')[source]
Bases:
object
Input data wrapper for emission calculations in a single reservoir.
- name
Reservoir name.
- Type:
str
- data
Emission data dictionary.
- Type:
Dict
- enum_load_method
Method to load enum values, default is “value”.
- Type:
EnumLoadMethods
- __post_init__() None [source]
Instantiate optional input fields with default values.
E.g., reservoir type, as it is not required in the model, the input data may not include the ‘type’ field.
- property catchment_data: Dict | None
Retrieve input data for catchment-scale process calculations.
- Returns:
Data dictionary for catchment calculations.
- Return type:
Optional[Dict]
- data: Dict
- enum_load_method: Literal['name', 'value'] = 'value'
- classmethod fromfile(file: str, reservoir_name: str) InputType [source]
Load inputs dictionary from file.
- Parameters:
cls (Type[InputType]) – The class type.
file (str) – Path to JSON file.
reservoir_name (str) – Reservoir name.
- Returns:
An instance of the Input class.
- Return type:
InputType
- property gasses: List[str] | None
Retrieve a list of emission factors/gases to be calculated.
- Returns:
List of gases.
- Return type:
Optional[List[str]]
- property monthly_temps: List[float] | None
Retrieve a vector of monthly average temperatures.
- Returns:
List of monthly temperatures.
- Return type:
Optional[List[float]]
- name: str
- property reservoir_data: Dict | None
Retrieve input data for reservoir-scale process calculations.
- Returns:
Data dictionary for reservoir calculations.
- Return type:
Optional[Dict]
- property year_vector: Tuple[float, ...] | None
Retrieve a tuple of years for which emissions profiles are being calculated.
- Returns:
Tuple of years.
- Return type:
Optional[Tuple[float, …]]
- class reemission.input.Inputs(inputs: Dict[str, Input])[source]
Bases:
object
Collection of inputs for which GHG emissions are being calculated.
- inputs
Dictionary with input data for multiple reservoirs.
- Type:
Dict[str, Input]
- add_input(input_dict: Dict[str, dict]) None [source]
Add new input to self.inputs.
- Parameters:
input_dict (Dict[str, dict]) – Input dictionary with one or more reservoir names as keys and data for each reservoir as values.
- classmethod fromfile(file: str) InputsType [source]
Load inputs dictionary from JSON file.
- Parameters:
cls (Type[InputsType]) – The class type.
file (str) – Path to the input JSON file.
- Returns:
An instance of the Inputs class.
- Return type:
InputsType
- inputs: Dict[str, Input]