h2integrate.core.utilities#
Functions
|
|
|
|
|
Create an XDSM diagram from a given plant configuration and save it to a pdf file. |
|
Merges two dictionaries from a configuration object and resolves potential conflicts. |
Classes
A Mixin class to allow for kwargs overloading when a data class doesn't have a specific parameter defined. |
- h2integrate.core.utilities.create_xdsm_from_config(config, output_file='connections_xdsm')#
Create an XDSM diagram from a given plant configuration and save it to a pdf file.
- Parameters:
config (dict) – Configuration dictionary containing technology interconnections.
output_file (str, optional) – The name of the output file where the XDSM diagram will be saved.
Merges two dictionaries from a configuration object and resolves potential conflicts.
This function combines the dictionaries associated with shared_parameters and performance_parameters, cost_parameters, or finance_parameters in the provided config dictionary. If both dictionaries contain the same keys, a ValueError is raised to prevent duplicate parameter definitions.
- Parameters:
config (dict) – A dictionary containing configuration data. It must include keys like shared_parameters and {input_type}_parameters.
input_type (str) – The type of input parameters to merge. Valid values are ‘performance’, ‘control’, ‘cost’, or ‘finance’.
- Returns:
dict –
- A merged dictionary containing parameters from both shared_parameters
and {input_type}_parameters. If one of the dictionaries is missing, the function returns the existing dictionary.
- Raises:
ValueError – If duplicate keys are found in shared_parameters and {input_type}_parameters.
- class h2integrate.core.utilities.BaseConfig#
A Mixin class to allow for kwargs overloading when a data class doesn’t have a specific parameter defined. This allows passing of larger dictionaries to a data class without throwing an error.
- classmethod from_dict(data, strict=True, additional_cls_name=None)#
Maps a data dictionary to an
attrs-defined class.- Parameters:
data (dict) – The data dictionary to be mapped.
strict (bool) – A flag enabling strict parameter processing, meaning that no extra parameters may be passed in or an AttributeError will be raised.
additional_cls_name (str | None) – The name of the model class creating the configuration data class. Provides an easier to diagnose error message for end users when the class name is provided.
- Returns:
cls – The
attrs-defined class.
- as_dict()#
Creates a JSON and YAML friendly dictionary that can be save for future reloading. This dictionary will contain only Python types that can later be converted to their proper Turbine formats.
- Returns:
dict – All key, value pairs required for class re-creation.
- Return type:
dict
- h2integrate.core.utilities.attr_serializer(inst, field, value)#
- Parameters:
inst (type)
field (Attribute)
value (Any)
- h2integrate.core.utilities.attr_filter(inst, value)#
- Parameters:
inst (Attribute)
value (Any)
- Return type:
bool