Skip to content

Commit

Permalink
Merge pull request #365 from rl-institut/feature/#364_demand_el_th_re…
Browse files Browse the repository at this point in the history
…sults

Feature/#364 demand el th results
  • Loading branch information
nesnoj authored Sep 7, 2023
2 parents 3a78270 + fc5ff94 commit 14effb2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions digiplan/map/calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]])
Expand Down Expand Up @@ -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]])
Expand Down
5 changes: 2 additions & 3 deletions digiplan/map/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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 = (
Expand Down

0 comments on commit 14effb2

Please sign in to comment.