diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6630c4f3c..92ddcf187 100755 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -772,6 +772,8 @@ Bug Fixes * Fix incorrect YAML serialization of the --scenarios CLI parameter that caused broken DAGs in the pipeline. `#343 `_ +* Fix hard coded scenario name in CTS building generation + `#1180 `_ .. _PR #692: https://github.com/openego/eGon-data/pull/692 diff --git a/src/egon/data/datasets/electricity_demand_timeseries/cts_buildings.py b/src/egon/data/datasets/electricity_demand_timeseries/cts_buildings.py index 5d643d98e..28464a3e5 100644 --- a/src/egon/data/datasets/electricity_demand_timeseries/cts_buildings.py +++ b/src/egon/data/datasets/electricity_demand_timeseries/cts_buildings.py @@ -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__( @@ -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( @@ -319,7 +329,7 @@ def amenities_without_buildings(): ) .filter( EgonDemandRegioZensusElectricity.sector == "service", - EgonDemandRegioZensusElectricity.scenario == "status2019", + EgonDemandRegioZensusElectricity.scenario == scn, ) ) @@ -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 @@ -663,7 +683,7 @@ def buildings_without_amenities(): ) .filter( EgonDemandRegioZensusElectricity.sector == "service", - EgonDemandRegioZensusElectricity.scenario == "status2019", + EgonDemandRegioZensusElectricity.scenario == scn, ) .filter( EgonDemandRegioZensusElectricity.zensus_population_id.notin_( @@ -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 = ( @@ -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_( @@ -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. """