Skip to content

Commit

Permalink
Add constraint attribute to datapackage.
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasJeckstadt committed Mar 14, 2024
1 parent 39d9022 commit 1a16f96
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 7 additions & 2 deletions data_adapter_oemof/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,12 @@ def get_default_parameters(

def create_bev_share_constraint(self
):
"""
Creates data frame for bev share constraint and returns it.
Returns
-------
"""
df = pd.DataFrame(
{'name': [f'{self.process_name}_{year}' for year in self.data['year']],
'type': self.process_name,
Expand All @@ -434,8 +440,7 @@ def create_bev_share_constraint(self
'share_tra_inflex'],
}
)
# todo: save df to csv or find function to do so.
return
return {f'bev_share_{self.process_name}': df}


class TransportConversionAdapter(Adapter):
Expand Down
5 changes: 4 additions & 1 deletion data_adapter_oemof/build_datapackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class DataPackage:
periods: pd.DataFrame()
location_to_save_to: str = None
tsa_parameters: pd.DataFrame = None
constraints: dict[str, pd.DataFrame] = None

@staticmethod
def __split_timeseries_into_years(parametrized_sequences):
Expand Down Expand Up @@ -483,6 +484,7 @@ def build_datapackage(
parametrized_elements = {"bus": []}
parametrized_sequences = {}
foreign_keys = {}
constraints = {}
# Iterate Elements
for process_name, struct in adapter.structure.processes.items():
process_data = adapter.get_process(process_name)
Expand Down Expand Up @@ -513,7 +515,7 @@ def build_datapackage(
bus_map=bus_map,
)
if component_adapter.type == 'bev_fleet':
component_adapter.create_bev_share_constraint()
constraints.update(component_adapter.create_bev_share_constraint())
components.append(component_adapter.facade_dict)
# Fill with all buses occurring, needed for foreign keys as well!
process_busses += list(component_adapter.get_busses().values())
Expand Down Expand Up @@ -549,4 +551,5 @@ def build_datapackage(
foreign_keys=foreign_keys,
periods=periods,
location_to_save_to=location_to_save_to,
constraints=constraints,
)

0 comments on commit 1a16f96

Please sign in to comment.