Skip to content

Commit

Permalink
Put max parameter back to output_parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
SabineHaas committed Dec 10, 2024
1 parent b303bff commit 813babd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
9 changes: 7 additions & 2 deletions data_adapter_oemof/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ def get_default_parameters(self) -> dict:
)

defaults = self.default_post_mapping_calculations(defaults)
if "max_profile" in defaults:
defaults["profile"] = defaults["max_profile"].columns[0]
if not defaults["input_parameters"]:
defaults.pop("input_parameters")
if not defaults["output_parameters"]:
Expand Down Expand Up @@ -356,12 +354,18 @@ def default_post_mapping_calculations(self, mapped_defaults):
-------
"""
if len(self.structure["outputs"]) == 0:
change_parameter = "input_parameters"
else:
change_parameter = "output_parameters"

# I:
if self.process_name[-1] == "0":
mapped_defaults = calculations.decommission(
process_name=self.process_name,
adapter_dict=mapped_defaults,
column="capacity",
input_output_parameters=change_parameter,
)
elif self.process_name[-1] == "1" or self.process_name[-1] == "2":
mapped_defaults["expandable"] = True
Expand Down Expand Up @@ -389,6 +393,7 @@ def default_post_mapping_calculations(self, mapped_defaults):
process_name=self.process_name,
adapter_dict=mapped_defaults,
column="amount",
input_output_parameters=change_parameter,
)

# III:
Expand Down
6 changes: 0 additions & 6 deletions data_adapter_oemof/build_datapackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,12 +560,6 @@ def _reduce_lists(x):
constraint_parameters = pd.DataFrame(components)
else:
parametrized_elements[process_name] = pd.DataFrame(components)

# if 'max_profile' exists the time series is added in `timeseries` and removed from `parametrized_elements`
# todo un-hard-code --> max_profile is set in calculations.decommission() which is called by Adapter.default_post_mapping_calculations()
if "max_profile" in parametrized_elements[process_name]:
timeseries = parametrized_elements[process_name]["max_profile"][0]
parametrized_elements[process_name].drop(columns=["max_profile"], inplace=True)
if not timeseries.empty:
parametrized_sequences.update({process_name: timeseries})
# Create Bus Element from all unique `busses` found in elements
Expand Down
10 changes: 6 additions & 4 deletions data_adapter_oemof/calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_capacity_cost(overnight_cost, fixed_cost, lifetime, wacc):


def decommission(
process_name, adapter_dict: dict, column: str = "capacity", max_column: str = "max",
process_name, adapter_dict: dict, column: str = "capacity", max_column: str = "max", input_output_parameters: str = "output_parameters",
) -> dict:
"""
Expand Down Expand Up @@ -93,18 +93,18 @@ def decommission(
return adapter_dict

# I:
if max_column not in adapter_dict["output_parameters"].keys():
if max_column not in adapter_dict[input_output_parameters].keys():
max = list(adapter_dict[column] / np.nanmax(adapter_dict[column]))

# II:
else:
max = list(multiply_two_lists(
adapter_dict["output_parameters"][max_column],
adapter_dict[input_output_parameters][max_column],
adapter_dict[column]
) / np.nanmax(adapter_dict[column]))

# max must be extended to time series over all time steps of each period
column_name = ["max_timeseries"]
column_name = [f"max_timeseries_{process_name}"]
timeseries = pd.DataFrame(columns=column_name)
for y in adapter_dict["year"]:
ts = pd.DataFrame(data=[1 for i in range(8760)], columns=column_name,
Expand All @@ -114,6 +114,8 @@ def decommission(
max_time_series = adapt_profile_with_yearly_value(profile=timeseries, value=max)

adapter_dict["max_profile"] = max_time_series
adapter_dict[input_output_parameters][max_column] = list(max_time_series[column_name[0]].values)
adapter_dict[input_output_parameters] = json.dumps(adapter_dict[input_output_parameters])

# set `column` value to maximum value
adapter_dict[column] = np.nanmax(adapter_dict[column])
Expand Down

0 comments on commit 813babd

Please sign in to comment.