zen_garden.postprocess.results.solution_loader¶
Contains the implementation of a SolutionLoader that reads the solution.
Functions
|
Helper-function that compares two versions. |
|
Helper-function that returns a Pandas series given the path of a file and the component name. |
|
Helper-function that returns the documentation of a h5-Group. |
|
Helper-function that returns the first scenario of a dictionary of scenarios. |
|
Helper-function that returns a boolean indicating if the component has units. |
|
Helper-function that returns the pandas dataframe index names of a h5-Group. |
|
Helper-function that checks the version of the solution. |
Classes
|
Class that defines a component. |
|
|
|
Implementation of the scenario. |
|
Implementation of a SolutionLoader. |
|
- class zen_garden.postprocess.results.solution_loader.Component(name: str, component_type: ComponentType, index_names: list[str], ts_type: TimestepType | None, ts_name: str | None, file_name: str, doc: str, has_units: bool)¶
Class that defines a component.
- __init__(name: str, component_type: ComponentType, index_names: list[str], ts_type: TimestepType | None, ts_name: str | None, file_name: str, doc: str, has_units: bool) None¶
- class zen_garden.postprocess.results.solution_loader.ComponentType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
- classmethod get_file_names_maps() dict[str, ComponentType]¶
Method that returns a dictionary that maps the file names to the component types.
- class zen_garden.postprocess.results.solution_loader.Scenario(path: str, name: str, base_scenario: str)¶
Implementation of the scenario. In this solution version, the analysis and system configs are stored as jsons for each of the scenario in the corresponding folder.
- __init__(path: str, name: str, base_scenario: str) None¶
- convert_ts2year(df: ['pd.DataFrame', 'pd.Series']) ['pd.DataFrame', 'pd.Series']¶
Converts the yearly ts column to the corresponding year.
- convert_year2ts(year: int) int¶
Converts the year to the corresponding time step.
- class zen_garden.postprocess.results.solution_loader.SolutionLoader(path: str, enable_cache: bool = True)¶
Implementation of a SolutionLoader.
- __init__(path: str, enable_cache: bool = True) None¶
- get_component_data(scenario: Scenario, component: Component, keep_raw: bool = False, data_type: Literal['dataframe', 'units'] = 'dataframe', index=None) pd.DataFrame | pd.Series[Any]¶
Returns the actual component values given a component and a scenario. Already combines the yearly data if the solution does not use perfect foresight, unless explicitly desired otherwise (keep_raw = True).
- get_optimized_years(scenario: Scenario) list[int]¶
Method that returns the years for which the solution was optimized.
- get_sequence_time_steps(scenario: Scenario, timestep_type: TimestepType) pd.Series[Any]¶
Method that returns the sequence time steps of a scenario.
- Parameters:
scenario
timestep_type
- get_time_steps_storage_level_startend_year(scenario: Scenario) dict[int, int]¶
Return time steps that define the start and end of the storage level.
- Parameters:
scenario – scenario name.
- get_timestep_duration(scenario: Scenario, component: Component) pd.Series[Any]¶
The timestep duration is stored as any other component, the only thing is to define the correct name depending on the component timestep type.
- get_timesteps(scenario: Scenario, component: Component, year: int) pd.Series[Any]¶
THe timesteps are stored in a file HDF-File called dict_all_sequence_time_steps saved for each scenario. The name of the dataframe depends on the timestep type.
- get_timesteps_of_years(scenario: Scenario, ts_type: TimestepType, years: tuple) pd.DataFrame | pd.Series[Any]¶
Method that returns the timesteps of the scenario for a given year.
- class zen_garden.postprocess.results.solution_loader.TimestepType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
- classmethod get_time_step_type(time_step: str) TimestepType | None¶
Method that returns the timestep type given a timestep name. :param time_step: The name of the timestep. :return: The timestep type.
- classmethod get_time_steps_names() list[str]¶
Method that returns a list of timestep names. :return: get_time_steps_names.
- zen_garden.postprocess.results.solution_loader.check_if_v1_leq_v2(version1: str, version2: str) bool¶
Helper-function that compares two versions.
The comparison is done by checking if version1 <= version2. Each version is a string of ..* format, where the number of positions is arbitrary.
- Parameters:
version1 – The first version.
version2 – The second version.
- Returns:
True if the version1 <= version2.
- zen_garden.postprocess.results.solution_loader.get_df_from_path(path: str, component_name: str, version: str, data_type: Literal['dataframe', 'units'] = 'dataframe', index: tuple[str] | None = None) pd.Series[Any]¶
Helper-function that returns a Pandas series given the path of a file and the component name.
- zen_garden.postprocess.results.solution_loader.get_doc(h5_file: File, component_name: str, version: str) str¶
Helper-function that returns the documentation of a h5-Group.
- zen_garden.postprocess.results.solution_loader.get_first_scenario(scenarios: dict[str, Scenario]) Scenario¶
Helper-function that returns the first scenario of a dictionary of scenarios. :param scenarios: The dictionary of scenarios.
- Returns:
The first scenario of the dictionary.
- zen_garden.postprocess.results.solution_loader.get_has_units(h5_file: File, component_name: str, version: str) bool¶
Helper-function that returns a boolean indicating if the component has units.
- zen_garden.postprocess.results.solution_loader.get_index_names(h5_file: File, component_name: str, version: str) list[str]¶
Helper-function that returns the pandas dataframe index names of a h5-Group.
- zen_garden.postprocess.results.solution_loader.get_solution_version(scenario: Scenario) str¶
Helper-function that checks the version of the solution. The order in versions is important as the highest version should be checked last {v1,v2,…}.
- Parameters:
scenario – The scenario for which the version should be checked.
- Returns:
The version of the solution.