Skip to content

Commit

Permalink
Merge pull request #1181 from openego/fix/#1180-missing-cts-buildings
Browse files Browse the repository at this point in the history
Fix/#1180 missing cts buildings
  • Loading branch information
khelfen authored Feb 3, 2025
2 parents 5cd0882 + 687c182 commit 5a59dee
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,8 @@ Bug Fixes
* Fix incorrect YAML serialization of the --scenarios CLI
parameter that caused broken DAGs in the pipeline.
`#343 <https://github.com/openego/powerd-data/issues/343>`_
* Fix hard coded scenario name in CTS building generation
`#1180 <https://github.com/openego/eGon-data/issues/1180>`_


.. _PR #692: https://github.com/openego/eGon-data/pull/692
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class CtsDemandBuildings(Dataset):
#:
name: str = "CtsDemandBuildings"
#:
version: str = "0.0.3"
version: str = "0.0.4"

def __init__(self, dependencies):
super().__init__(
Expand Down Expand Up @@ -300,6 +300,16 @@ def amenities_without_buildings():
"""
from saio.openstreetmap import osm_amenities_not_in_buildings_filtered

with db.session_scope() as session:
scn_query = session.query(
func.distinct(EgonDemandRegioZensusElectricity.scenario)
)

# FIXME: Cells with CTS demand, amenities and buildings do not change within the
# scenarios, only the demand itself. Therefore any scenario can be used
# universally to determine the cts buildings but not for the demand share.
scn = db.select_dataframe(scn_query.statement).iat[0, 0]

with db.session_scope() as session:
cells_query = (
session.query(
Expand All @@ -319,7 +329,7 @@ def amenities_without_buildings():
)
.filter(
EgonDemandRegioZensusElectricity.sector == "service",
EgonDemandRegioZensusElectricity.scenario == "status2019",
EgonDemandRegioZensusElectricity.scenario == scn,
)
)

Expand Down Expand Up @@ -617,6 +627,16 @@ def buildings_without_amenities():
osm_buildings_synthetic,
)

with db.session_scope() as session:
scn_query = session.query(
func.distinct(EgonDemandRegioZensusElectricity.scenario)
)

# FIXME: Cells with CTS demand, amenities and buildings do not change within the
# scenarios, only the demand itself. Therefore any scenario can be used
# universally to determine the cts buildings but not for the demand share.
scn = db.select_dataframe(scn_query.statement).iat[0, 0]

# buildings_filtered in cts-demand-cells without amenities
with db.session_scope() as session:
# Synthetic Buildings
Expand Down Expand Up @@ -663,7 +683,7 @@ def buildings_without_amenities():
)
.filter(
EgonDemandRegioZensusElectricity.sector == "service",
EgonDemandRegioZensusElectricity.scenario == "status2019",
EgonDemandRegioZensusElectricity.scenario == scn,
)
.filter(
EgonDemandRegioZensusElectricity.zensus_population_id.notin_(
Expand Down Expand Up @@ -738,6 +758,16 @@ def cells_with_cts_demand_only(df_buildings_without_amenities):
"""
from saio.openstreetmap import osm_amenities_shops_filtered

with db.session_scope() as session:
scn_query = session.query(
func.distinct(EgonDemandRegioZensusElectricity.scenario)
)

# FIXME: Cells with CTS demand, amenities and buildings do not change within the
# scenarios, only the demand itself. Therefore any scenario can be used
# universally to determine the cts buildings but not for the demand share.
scn = db.select_dataframe(scn_query.statement).iat[0, 0]

# cells mit amenities
with db.session_scope() as session:
sub_query = (
Expand All @@ -763,7 +793,7 @@ def cells_with_cts_demand_only(df_buildings_without_amenities):
)
.filter(
EgonDemandRegioZensusElectricity.sector == "service",
EgonDemandRegioZensusElectricity.scenario == "status2019",
EgonDemandRegioZensusElectricity.scenario == scn,
)
.filter(
EgonDemandRegioZensusElectricity.zensus_population_id.notin_(
Expand Down Expand Up @@ -1210,7 +1240,7 @@ def cts_buildings():
Note:
-----
Cells with CTS demand, amenities and buildings do not change within
the scenarios, only the demand itself. Therefore scenario status2019
the scenarios, only the demand itself. Therefore any scenario
can be used universally to determine the cts buildings but not for
the demand share.
"""
Expand Down

0 comments on commit 5a59dee

Please sign in to comment.