From 76116021b0909c6aa4ee319340882c5675716b78 Mon Sep 17 00:00:00 2001 From: SabineHaas Date: Mon, 11 Nov 2024 15:26:33 +0100 Subject: [PATCH 01/13] Remove line, max time series is added in build_datapackage --- data_adapter_oemof/adapters.py | 1 - 1 file changed, 1 deletion(-) diff --git a/data_adapter_oemof/adapters.py b/data_adapter_oemof/adapters.py index 75cab94..2150a81 100644 --- a/data_adapter_oemof/adapters.py +++ b/data_adapter_oemof/adapters.py @@ -78,7 +78,6 @@ def get_default_parameters(self) -> dict: defaults = self.default_post_mapping_calculations(defaults) if "max_profile" in defaults: - self.timeseries = defaults["max_profile"] defaults["profile"] = defaults["max_profile"].columns[0] if not defaults["input_parameters"]: defaults.pop("input_parameters") From 96a18c7ea3052d9623efca344ea1d675e7e8a138 Mon Sep 17 00:00:00 2001 From: SabineHaas Date: Mon, 11 Nov 2024 15:52:30 +0100 Subject: [PATCH 02/13] Convert availablity_constant to full_load_time_max --- data_adapter_oemof/adapters.py | 3 +++ data_adapter_oemof/calculations.py | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/data_adapter_oemof/adapters.py b/data_adapter_oemof/adapters.py index 2150a81..25774f7 100644 --- a/data_adapter_oemof/adapters.py +++ b/data_adapter_oemof/adapters.py @@ -35,6 +35,7 @@ class Adapter: Field(name="name", type=str), Field(name="region", type=str), Field(name="year", type=int), + Field(name="full_load_time_max", type=float), ) output_parameters = (Field(name="max", type=float), Field(name="min", type=float)) input_parameters = () @@ -337,6 +338,7 @@ def default_pre_mapping_calculations(self): """ calculations.normalize_activity_bonds(self) + calculations.process_availability_constant_to_full_load_time_max(self) def default_post_mapping_calculations(self, mapped_defaults): """ @@ -608,6 +610,7 @@ class MIMOAdapter(Adapter): Field(name="name", type=str), Field(name="region", type=str), Field(name="year", type=int), + Field(name="full_load_time_max", type=float), Field(name="groups", type=dict), Field(name="lifetime", type=float), Field(name="capacity_cost", type=float), diff --git a/data_adapter_oemof/calculations.py b/data_adapter_oemof/calculations.py index ecab206..dfb971f 100644 --- a/data_adapter_oemof/calculations.py +++ b/data_adapter_oemof/calculations.py @@ -167,6 +167,15 @@ def normalize_activity_bonds(adapter): return adapter +def process_availability_constant_to_full_load_time_max(adapter): + """ Calculate full load time max from availability constant.""" + if "availability_constant" in adapter.data.keys(): + availability_constant = adapter.data["availability_constant"] + if availability_constant > 1: # assumption: then the unit is % + availability_constant = availability_constant / 100 + adapter.data["full_load_time_max"] = 8760 * availability_constant + + def floor_lifetime(mapped_defaults): """ From bea8f1de12a28db170fe7317b6a73d430c204c30 Mon Sep 17 00:00:00 2001 From: SabineHaas Date: Mon, 11 Nov 2024 16:00:12 +0100 Subject: [PATCH 03/13] Add author and fix typo --- examples/industry/data_adapter_industry.py | 2 +- pyproject.toml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/industry/data_adapter_industry.py b/examples/industry/data_adapter_industry.py index 64ef658..39b3f9d 100644 --- a/examples/industry/data_adapter_industry.py +++ b/examples/industry/data_adapter_industry.py @@ -72,7 +72,7 @@ logger.info("Building Adapter Map") -# create dicitonary with all found in and outputs +# create dictionary with all found in- and outputs process_adapter_map = pd.concat( [ pd.read_excel( diff --git a/pyproject.toml b/pyproject.toml index 3cc3a0b..6f5c655 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,8 @@ authors = [ "Sarah Berendes ", "Julian Endres ", "Felix Maurer ", - "Hendrik Huyskens " + "Hendrik Huyskens ", + "Sabine Haas " ] [tool.poetry.group.dev.dependencies] From 92bf37b1daabdd96eadb9a0ba2f93b509e54c903 Mon Sep 17 00:00:00 2001 From: SabineHaas Date: Mon, 11 Nov 2024 16:04:40 +0100 Subject: [PATCH 04/13] Remove empty default_pre_mapping_calculations from mimo adapter to make use of availability constant --- data_adapter_oemof/adapters.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/data_adapter_oemof/adapters.py b/data_adapter_oemof/adapters.py index 25774f7..bccf563 100644 --- a/data_adapter_oemof/adapters.py +++ b/data_adapter_oemof/adapters.py @@ -622,15 +622,6 @@ class MIMOAdapter(Adapter): ) output_parameters = () - def default_pre_mapping_calculations(self): - """ - Mimo adapter specific pre calculations - Returns - ------- - - """ - pass - def get_default_parameters(self) -> dict: defaults = super().get_default_parameters() defaults["groups"] = self.get_groups() From e487795dc51cf5f499d56a4495afcd691849dacf Mon Sep 17 00:00:00 2001 From: SabineHaas Date: Thu, 14 Nov 2024 15:49:52 +0100 Subject: [PATCH 05/13] Adding expandable parameter to investment processes --- data_adapter_oemof/adapters.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/data_adapter_oemof/adapters.py b/data_adapter_oemof/adapters.py index bccf563..3e4cd5b 100644 --- a/data_adapter_oemof/adapters.py +++ b/data_adapter_oemof/adapters.py @@ -344,7 +344,8 @@ def default_post_mapping_calculations(self, mapped_defaults): """ Does default calculations# - I. Decommissioning of existing Capacities + I. Decommissioning of existing Capacities (processes _0) and add + `expandable = True` if process is expandable (_1, _2, not _0) II. Reformatting of amount in case amount is not a number a) Multiply timeseries by the repeoctiv yearly amount b) Analogous to decommissioning of capacities @@ -361,6 +362,8 @@ def default_post_mapping_calculations(self, mapped_defaults): adapter_dict=mapped_defaults, column="capacity", ) + elif self.process_name[-1] == "1" or self.process_name[-1] == "2": + mapped_defaults["expandable"] = True # II: if "amount" in mapped_defaults.keys(): From bf3aa4f9020e9b1e3563b1bb7baf8e260aede5ad Mon Sep 17 00:00:00 2001 From: SabineHaas Date: Thu, 14 Nov 2024 15:50:03 +0100 Subject: [PATCH 06/13] Add bug fix for biogas treatment --- data_adapter_oemof/adapters.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/data_adapter_oemof/adapters.py b/data_adapter_oemof/adapters.py index 3e4cd5b..57dcc4b 100644 --- a/data_adapter_oemof/adapters.py +++ b/data_adapter_oemof/adapters.py @@ -364,6 +364,12 @@ def default_post_mapping_calculations(self, mapped_defaults): ) elif self.process_name[-1] == "1" or self.process_name[-1] == "2": mapped_defaults["expandable"] = True + elif "x2x_other_biogas_treatment" in self.process_name: + mapped_defaults["expandable"] = True + logging.warning( + "Setting capacity cost of x2x_other_biogas_treatment to 0 as " + "it is missing in the data.") + mapped_defaults["capacity_cost"] = 0 # II: if "amount" in mapped_defaults.keys(): From a0f7819852579fe4a481e73315a08659d15c09f4 Mon Sep 17 00:00:00 2001 From: SabineHaas Date: Thu, 14 Nov 2024 16:41:43 +0100 Subject: [PATCH 07/13] Add parameter primary in mimo adapter and drop 'primary' from foreign keys in datapackage --- data_adapter_oemof/adapters.py | 3 +++ data_adapter_oemof/build_datapackage.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/data_adapter_oemof/adapters.py b/data_adapter_oemof/adapters.py index 57dcc4b..aa7db67 100644 --- a/data_adapter_oemof/adapters.py +++ b/data_adapter_oemof/adapters.py @@ -628,6 +628,7 @@ class MIMOAdapter(Adapter): Field(name="activity_bound_min", type=float), Field(name="activity_bound_max", type=float), Field(name="activity_bound_fix", type=float), + Field(name="primary", type=str), ) output_parameters = () @@ -654,6 +655,8 @@ def get_bus_from_struct(bus_list: list, prefix: str) -> dict: buses = {} counter = 0 for bus_group in bus_list: + if prefix == "to_bus_" and counter == 0: + buses["primary"] = bus_group if isinstance(bus_group, str): buses[f"{prefix}{counter}"] = bus_group counter += 1 diff --git a/data_adapter_oemof/build_datapackage.py b/data_adapter_oemof/build_datapackage.py index b4a5370..7531604 100644 --- a/data_adapter_oemof/build_datapackage.py +++ b/data_adapter_oemof/build_datapackage.py @@ -297,6 +297,12 @@ def save_datapackage_to_csv( field_names = [field["name"] for field in resource["schema"]["fields"]] resource["dialect"] = {"delimiter": ";"} if resource["name"] in self.foreign_keys.keys(): + # drop "primary", see mimo converter of oemof.industry for more information + self.foreign_keys[resource["name"]] = [ + item for item in self.foreign_keys[resource["name"]] if + item["fields"] != "primary" + ] + # update schema resource["schema"].update( {"foreignKeys": self.foreign_keys[resource["name"]]} ) From 58b27f76740e5a15f23664f7326ed7bf41f0bb43 Mon Sep 17 00:00:00 2001 From: SabineHaas Date: Thu, 14 Nov 2024 17:37:20 +0100 Subject: [PATCH 08/13] Update oemof industry installation branch --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6f5c655..2bb3665 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ build-backend = "poetry.core.masonry.api" python = ">=3.10,<3.11" data_adapter = { git = "https://git@github.com/sedos-project/data_adapter", branch = "bug_fix/drop_comment_column"} oemof-tabular = { git = "https://git@github.com/oemof/oemof-tabular", branch = "dev"} -oemof-industry = { git = "https://github.com/sedos-project/oemof.industry.git", branch = "main"} +oemof-industry = { git = "https://github.com/sedos-project/oemof.industry.git", branch = "fix/facade_params"} boto3 = "1.26.125" # fix boto3 to fasten up dependency resolution python-dotenv = "^0.21.0" tsam = "^2.3.1" From 3f3c11d018fd1cd8d047dd5b7a6fa8710e660a24 Mon Sep 17 00:00:00 2001 From: SabineHaas Date: Thu, 14 Nov 2024 17:45:57 +0100 Subject: [PATCH 09/13] Bugfix add lifetime to x2x_other_biogas_treatment --- data_adapter_oemof/adapters.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/data_adapter_oemof/adapters.py b/data_adapter_oemof/adapters.py index aa7db67..f12554f 100644 --- a/data_adapter_oemof/adapters.py +++ b/data_adapter_oemof/adapters.py @@ -367,9 +367,10 @@ def default_post_mapping_calculations(self, mapped_defaults): elif "x2x_other_biogas_treatment" in self.process_name: mapped_defaults["expandable"] = True logging.warning( - "Setting capacity cost of x2x_other_biogas_treatment to 0 as " - "it is missing in the data.") + "Setting capacity cost of x2x_other_biogas_treatment to 0 and " + "life time to 20 as this is missing in the data.") mapped_defaults["capacity_cost"] = 0 + mapped_defaults["lifetime"] = 20 # II: if "amount" in mapped_defaults.keys(): From 237ec6f8d2849450416d0e4f512844375c141cc5 Mon Sep 17 00:00:00 2001 From: SabineHaas Date: Fri, 15 Nov 2024 12:57:33 +0100 Subject: [PATCH 10/13] Install main branch of data_adapter --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2bb3665..95b7958 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry.dependencies] python = ">=3.10,<3.11" -data_adapter = { git = "https://git@github.com/sedos-project/data_adapter", branch = "bug_fix/drop_comment_column"} +data_adapter = { git = "https://git@github.com/sedos-project/data_adapter", branch = "main"} oemof-tabular = { git = "https://git@github.com/oemof/oemof-tabular", branch = "dev"} oemof-industry = { git = "https://github.com/sedos-project/oemof.industry.git", branch = "fix/facade_params"} boto3 = "1.26.125" # fix boto3 to fasten up dependency resolution From bc0dae60eb363b41d38c86730aed5cef81dadb77 Mon Sep 17 00:00:00 2001 From: SabineHaas Date: Mon, 18 Nov 2024 08:53:19 +0100 Subject: [PATCH 11/13] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 95b7958..8a09e1f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ build-backend = "poetry.core.masonry.api" python = ">=3.10,<3.11" data_adapter = { git = "https://git@github.com/sedos-project/data_adapter", branch = "main"} oemof-tabular = { git = "https://git@github.com/oemof/oemof-tabular", branch = "dev"} -oemof-industry = { git = "https://github.com/sedos-project/oemof.industry.git", branch = "fix/facade_params"} +oemof-industry = { git = "https://github.com/sedos-project/oemof.industry.git", branch = "main"} boto3 = "1.26.125" # fix boto3 to fasten up dependency resolution python-dotenv = "^0.21.0" tsam = "^2.3.1" From 5b0d97eac3e0f5a277ddb0b392bc6bf8d9458d1d Mon Sep 17 00:00:00 2001 From: SabineHaas Date: Mon, 18 Nov 2024 16:09:38 +0100 Subject: [PATCH 12/13] Adapt oemof-tabular installation --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8a09e1f..322c294 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry.dependencies] python = ">=3.10,<3.11" data_adapter = { git = "https://git@github.com/sedos-project/data_adapter", branch = "main"} -oemof-tabular = { git = "https://git@github.com/oemof/oemof-tabular", branch = "dev"} +oemof-tabular = { git = "https://git@github.com/oemof/oemof-tabular", branch = "feature/multi-period-results "} oemof-industry = { git = "https://github.com/sedos-project/oemof.industry.git", branch = "main"} boto3 = "1.26.125" # fix boto3 to fasten up dependency resolution python-dotenv = "^0.21.0" From 28999d75be6a396c24478df0400bdc93f949f7ef Mon Sep 17 00:00:00 2001 From: SabineHaas Date: Mon, 18 Nov 2024 16:10:20 +0100 Subject: [PATCH 13/13] Correct error --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 322c294..954befd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry.dependencies] python = ">=3.10,<3.11" data_adapter = { git = "https://git@github.com/sedos-project/data_adapter", branch = "main"} -oemof-tabular = { git = "https://git@github.com/oemof/oemof-tabular", branch = "feature/multi-period-results "} +oemof-tabular = { git = "https://git@github.com/oemof/oemof-tabular", branch = "feature/multi-period-results"} oemof-industry = { git = "https://github.com/sedos-project/oemof.industry.git", branch = "main"} boto3 = "1.26.125" # fix boto3 to fasten up dependency resolution python-dotenv = "^0.21.0"