zen-garden 2.7.14__py3-none-any.whl → 2.7.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zen_garden/postprocess/results/results.py +21 -0
- zen_garden/postprocess/results/solution_loader.py +11 -1
- zen_garden/utils.py +27 -0
- {zen_garden-2.7.14.dist-info → zen_garden-2.7.16.dist-info}/METADATA +1 -1
- {zen_garden-2.7.14.dist-info → zen_garden-2.7.16.dist-info}/RECORD +8 -8
- {zen_garden-2.7.14.dist-info → zen_garden-2.7.16.dist-info}/WHEEL +0 -0
- {zen_garden-2.7.14.dist-info → zen_garden-2.7.16.dist-info}/entry_points.txt +0 -0
- {zen_garden-2.7.14.dist-info → zen_garden-2.7.16.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -673,6 +673,27 @@ class Results:
|
|
|
673
673
|
return ""
|
|
674
674
|
return component.doc
|
|
675
675
|
|
|
676
|
+
def get_index_names(self, component_name: str, scenario_name: Optional[str] = None) -> list[str]:
|
|
677
|
+
"""
|
|
678
|
+
Docstring for get_index_names
|
|
679
|
+
|
|
680
|
+
:param self: Description
|
|
681
|
+
:param component_name: Description
|
|
682
|
+
:type component_name: str
|
|
683
|
+
:param scenario_name: Description
|
|
684
|
+
:type scenario_name: Optional[str]
|
|
685
|
+
:return: Description
|
|
686
|
+
:rtype: list[str]
|
|
687
|
+
"""
|
|
688
|
+
if scenario_name is None:
|
|
689
|
+
scenario_name = next(iter(self.solution_loader.scenarios.keys()))
|
|
690
|
+
scenario = self.solution_loader.scenarios[scenario_name]
|
|
691
|
+
if component_name not in scenario.components:
|
|
692
|
+
logging.warning(f"Component {component_name} not found and the index names cannot be returned.")
|
|
693
|
+
return []
|
|
694
|
+
component = scenario.components[component_name]
|
|
695
|
+
return component.index_names
|
|
696
|
+
|
|
676
697
|
def get_years(self, scenario_name: Optional[str] = None) -> list[int]:
|
|
677
698
|
"""
|
|
678
699
|
Extracts the years of a given Scenario. If no scenario is given, a random one is taken.
|
|
@@ -10,10 +10,13 @@ import h5py # type: ignore
|
|
|
10
10
|
import pint
|
|
11
11
|
import pandas as pd
|
|
12
12
|
import numpy as np
|
|
13
|
+
import logging
|
|
14
|
+
|
|
13
15
|
from typing import Optional, Any,Literal
|
|
14
16
|
from enum import Enum
|
|
15
17
|
from functools import cache
|
|
16
18
|
from zen_garden.default_config import Analysis, System, Solver
|
|
19
|
+
from zen_garden.utils import slice_df_by_index
|
|
17
20
|
|
|
18
21
|
class ComponentType(Enum):
|
|
19
22
|
parameter: str = "parameter"
|
|
@@ -665,7 +668,12 @@ class SolutionLoader():
|
|
|
665
668
|
version = get_solution_version(scenario)
|
|
666
669
|
if check_if_v1_leq_v2(version,"v1"):
|
|
667
670
|
sequence = self.get_sequence_time_steps(scenario,TimestepType.storage)
|
|
668
|
-
|
|
671
|
+
time_steps_per_year = scenario.system.unaggregated_time_steps_per_year
|
|
672
|
+
dict_startend = {}
|
|
673
|
+
for i in np.arange(scenario.system.optimized_years):
|
|
674
|
+
start_idx = i * time_steps_per_year
|
|
675
|
+
end_idx = (i + 1) * time_steps_per_year - 1
|
|
676
|
+
dict_startend[sequence.iloc[start_idx]] = sequence.iloc[end_idx]
|
|
669
677
|
else:
|
|
670
678
|
time_steps_file_name = _get_time_steps_file(scenario)
|
|
671
679
|
time_steps_file_name = time_steps_file_name + ".json"
|
|
@@ -788,6 +796,8 @@ def get_df_from_path(path: str, component_name: str, version: str, data_type: Li
|
|
|
788
796
|
|
|
789
797
|
if check_if_v1_leq_v2(version,"v0"):
|
|
790
798
|
pd_read = pd.read_hdf(path, component_name + f"/{data_type}")
|
|
799
|
+
if len(index) > 0:
|
|
800
|
+
pd_read = slice_df_by_index(pd_read,index)
|
|
791
801
|
else:
|
|
792
802
|
if data_type == "dataframe":
|
|
793
803
|
try:
|
zen_garden/utils.py
CHANGED
|
@@ -262,6 +262,33 @@ def reformat_slicing_index(index, component) -> tuple[str]:
|
|
|
262
262
|
|
|
263
263
|
return ref_index
|
|
264
264
|
|
|
265
|
+
def slice_df_by_index(df,index_tuple) -> dict:
|
|
266
|
+
""" recreates the slicing index from a tuple of strings and slices the dataframe accordingly
|
|
267
|
+
:param df: dataframe to be sliced
|
|
268
|
+
:param index_tuple: tuple of strings representing the slicing index
|
|
269
|
+
:return: sliced dataframe
|
|
270
|
+
"""
|
|
271
|
+
index = {}
|
|
272
|
+
for index_str in index_tuple:
|
|
273
|
+
if " in " in index_str:
|
|
274
|
+
key, value_str = index_str.split(" in ")
|
|
275
|
+
key = key.strip("'")
|
|
276
|
+
value = eval(value_str)
|
|
277
|
+
elif " == " in index_str:
|
|
278
|
+
key, value_str = index_str.split(" == ")
|
|
279
|
+
key = key.strip("'")
|
|
280
|
+
value = eval(value_str)
|
|
281
|
+
else:
|
|
282
|
+
continue
|
|
283
|
+
index[key] = value
|
|
284
|
+
for key in index:
|
|
285
|
+
if key in df.index.names:
|
|
286
|
+
if isinstance(index[key], list):
|
|
287
|
+
df = df.loc[df.index.get_level_values(key).isin(index[key])]
|
|
288
|
+
else:
|
|
289
|
+
df = df.xs(index[key], level=key, drop_level=False)
|
|
290
|
+
return df
|
|
291
|
+
|
|
265
292
|
def get_label_position(obj,label:int):
|
|
266
293
|
""" Get dict of index and coordinate for variable or constraint labels."""
|
|
267
294
|
name_element = obj.get_name_by_label(int(label))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: zen_garden
|
|
3
|
-
Version: 2.7.
|
|
3
|
+
Version: 2.7.16
|
|
4
4
|
Summary: ZEN-garden is an optimization model of energy systems and value chains.
|
|
5
5
|
Author: Alissa Ganter, Johannes Burger, Francesco De Marco, Lukas Kunz, Lukas Schmidt-Engelbertz, Paolo Gabrielli, Giovanni Sansavini
|
|
6
6
|
Author-email: Jacob Mannhardt <zen-garden@ethz.ch>
|
|
@@ -3,7 +3,7 @@ zen_garden/__main__.py,sha256=r3pop1FpaTfe9YUGxYP48T1uqdq5uZW8gBzZKbZOFno,4624
|
|
|
3
3
|
zen_garden/_internal.py,sha256=K648bT1O8gD9uIrfmqPXP5lDdlkJd3-Ai111_IyIc1w,5347
|
|
4
4
|
zen_garden/default_config.py,sha256=ozz2LBSGSaMH8alEAzh-6ziM9IE9zXM9PfRD3nulAIs,8663
|
|
5
5
|
zen_garden/optimization_setup.py,sha256=Rv_IciR_Y9GF-OaPDDAvTQ2huTuAt94jrWpcDJCQgWQ,42176
|
|
6
|
-
zen_garden/utils.py,sha256
|
|
6
|
+
zen_garden/utils.py,sha256=skTvbc0zRps1Q0EZFdJGPnG8RUeo_Xv2IraOR4SXdQU,58453
|
|
7
7
|
zen_garden/visualization.py,sha256=zZApEFtwdA1NpDKTvrZS9lyeiT__s6lR7QVaj6mUCmg,110
|
|
8
8
|
zen_garden/model/__init__.py,sha256=7QIygxkUlNsOBbJPr5VdAxcJQCz6t_FSlD1uytUhuDE,48
|
|
9
9
|
zen_garden/model/component.py,sha256=NeMV47l6Ec_ij_jburCx4cz6lI5k1-b6t0_DfuWFhhY,40488
|
|
@@ -23,15 +23,15 @@ zen_garden/postprocess/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
|
|
|
23
23
|
zen_garden/postprocess/comparisons.py,sha256=uyEtV0Q8_YPzJi4b12DWiqYU-kKJz6I3Li-I7_6RURY,13239
|
|
24
24
|
zen_garden/postprocess/postprocess.py,sha256=0_1iy028iZmvf2egXUFO2ZS13HmkacMt7A5eTI0iCE4,29644
|
|
25
25
|
zen_garden/postprocess/results/__init__.py,sha256=363lzC0uRJ5F42cOEhD9jxMPCioTt8WRt0qwZG0IizY,49
|
|
26
|
-
zen_garden/postprocess/results/results.py,sha256=
|
|
27
|
-
zen_garden/postprocess/results/solution_loader.py,sha256=
|
|
26
|
+
zen_garden/postprocess/results/results.py,sha256=jdJprpSbfs62TZKcHbkfCvSkpG-8fTRXTWoXew9M9AQ,40585
|
|
27
|
+
zen_garden/postprocess/results/solution_loader.py,sha256=ChEV4kUi4m5h3Q6B8oxf9wPdEmrH_CNTs5BRNR8UZQs,31252
|
|
28
28
|
zen_garden/preprocess/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
29
|
zen_garden/preprocess/extract_input_data.py,sha256=PWKdel7s488SELseyAaoFkwXpzJU4MZg0pW0wO2ZHoI,51523
|
|
30
30
|
zen_garden/preprocess/parameter_change_log.py,sha256=WNhLYTyuaFkUl_e4QH36W1chpqg00m7zg__PawPogAY,387
|
|
31
31
|
zen_garden/preprocess/time_series_aggregation.py,sha256=v8xRRk4I9WZ2yi7V3I_Ersj2RV1T2WIKslx8ohkMfWI,32112
|
|
32
32
|
zen_garden/preprocess/unit_handling.py,sha256=OGIHFyDdUmGU-GEGHkJGJ9RmKfDBy5-HmuBQmtYAK5Q,63043
|
|
33
|
-
zen_garden-2.7.
|
|
34
|
-
zen_garden-2.7.
|
|
35
|
-
zen_garden-2.7.
|
|
36
|
-
zen_garden-2.7.
|
|
37
|
-
zen_garden-2.7.
|
|
33
|
+
zen_garden-2.7.16.dist-info/entry_points.txt,sha256=Jfa7k0xmvGql3hGJid62hGV1rzDt81uTs3PgZre0VJk,118
|
|
34
|
+
zen_garden-2.7.16.dist-info/licenses/LICENSE.txt,sha256=_kEtxPe9gWOwMzdiy8nLzgABiPdMvUS0kaSCOIrEA_E,1101
|
|
35
|
+
zen_garden-2.7.16.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
36
|
+
zen_garden-2.7.16.dist-info/METADATA,sha256=rh8SzLVXjHwV9foyWEcIxOwR3xvyzQFASIXyT2YesZ0,5632
|
|
37
|
+
zen_garden-2.7.16.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|