From b09a43e48040e34391a73be0835d5abc2712d47c Mon Sep 17 00:00:00 2001 From: nesnoj Date: Thu, 7 Sep 2023 07:23:45 +0200 Subject: [PATCH 1/2] Fix power and heat demand scaling for future scenario Scale demand data for 2022 instead of 2045 for scaling with slider values as 2022 is always the reference. --- digiplan/map/calculations.py | 4 ++-- digiplan/map/hooks.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/digiplan/map/calculations.py b/digiplan/map/calculations.py index 8afccef9..7a93316a 100644 --- a/digiplan/map/calculations.py +++ b/digiplan/map/calculations.py @@ -315,7 +315,7 @@ def electricity_demand_per_municipality_2045(simulation_id: int) -> pd.DataFrame } demand = demand.reindex(mappings.values()) sector_shares = pd.DataFrame( - {sector: demands_per_sector[sector]["2045"] / demands_per_sector[sector]["2045"].sum() for sector in mappings}, + {sector: demands_per_sector[sector]["2022"] / demands_per_sector[sector]["2022"].sum() for sector in mappings}, ) demand = sector_shares * demand.values demand.columns = demand.columns.map(lambda column: config.SIMULATION_DEMANDS[mappings[column]]) @@ -371,7 +371,7 @@ def heat_demand_per_municipality_2045(simulation_id: int) -> pd.DataFrame: } demand = demand.reindex(mappings.values()) sector_shares = pd.DataFrame( - {sector: demands_per_sector[sector]["2045"] / demands_per_sector[sector]["2045"].sum() for sector in mappings}, + {sector: demands_per_sector[sector]["2022"] / demands_per_sector[sector]["2022"].sum() for sector in mappings}, ) demand = sector_shares * demand.values demand.columns = demand.columns.map(lambda column: config.SIMULATION_DEMANDS[mappings[column]]) diff --git a/digiplan/map/hooks.py b/digiplan/map/hooks.py index e4046e25..9231cf27 100644 --- a/digiplan/map/hooks.py +++ b/digiplan/map/hooks.py @@ -64,11 +64,10 @@ def adapt_electricity_demand(scenario: str, data: dict, request: HttpRequest) -> Parameters for oemof with adapted demands """ del data["s_v_1"] - year = "2045" if scenario == "scenario_2045" else "2022" for sector, slider in (("hh", "s_v_3"), ("cts", "s_v_4"), ("ind", "s_v_5")): demand = datapackage.get_power_demand(sector)[sector] logging.info(f"Adapting electricity demand at {sector=}.") - data[f"ABW-electricity-demand_{sector}"] = {"amount": float(demand[year].sum()) * data.pop(slider) / 100} + data[f"ABW-electricity-demand_{sector}"] = {"amount": float(demand["2022"].sum()) * data.pop(slider) / 100} return data @@ -168,7 +167,7 @@ def adapt_heat_settings(scenario: str, data: dict, request: HttpRequest) -> dict # Calculate demands per sector for sector in ("hh", "cts", "ind"): summed_demand = int( # Convert to int, otherwise int64 is used - heat_demand_per_municipality[sector][distribution[:3]]["2045"].sum(), + heat_demand_per_municipality[sector][distribution[:3]]["2022"].sum(), ) demand[sector] = heat_demand[sector][distribution] * summed_demand percentage = ( From fc5ff94b128079d92e6557365a99dcaef5e0be2c Mon Sep 17 00:00:00 2001 From: nesnoj Date: Thu, 7 Sep 2023 07:23:58 +0200 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aabe9f98..792a6cbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project tries to adhere to [Semantic Versioning](https://semver.org/spe ### Fixed - various fixes in charts, texts and units - RES share calculation for SQ +- power and heat demand scaling for future scenario ## [0.6.0] - 2023-09-01 ### Added