Code Duplication    Length = 42-42 lines in 2 locations

src/egon/data/datasets/electricity_demand_timeseries/cts_buildings.py 1 location

@@ 939-980 (lines=42) @@
936
    return df_demand_share
937
938
939
def get_peta_demand(mvgd, scenario):
940
    """
941
    Retrieve annual peta heat demand for CTS for either
942
    eGon2035 or eGon100RE scenario.
943
944
    Parameters
945
    ----------
946
    mvgd : int
947
        ID of substation for which to get CTS demand.
948
    scenario : str
949
        Possible options are eGon2035 or eGon100RE
950
951
    Returns
952
    -------
953
    df_peta_demand : pd.DataFrame
954
        Annual residential heat demand per building and scenario. Columns of
955
        the dataframe are zensus_population_id and demand.
956
957
    """
958
959
    with db.session_scope() as session:
960
        query = (
961
            session.query(
962
                MapZensusGridDistricts.zensus_population_id,
963
                EgonPetaHeat.demand,
964
            )
965
            .filter(MapZensusGridDistricts.bus_id == int(mvgd))
966
            .filter(
967
                MapZensusGridDistricts.zensus_population_id
968
                == EgonPetaHeat.zensus_population_id
969
            )
970
            .filter(
971
                EgonPetaHeat.sector == "service",
972
                EgonPetaHeat.scenario == scenario,
973
            )
974
        )
975
976
        df_peta_demand = pd.read_sql(
977
            query.statement, query.session.bind, index_col=None
978
        )
979
980
    return df_peta_demand
981
982
983
def calc_cts_building_profiles(

src/egon/data/datasets/heat_supply/individual_heating.py 1 location

@@ 589-630 (lines=42) @@
586
    )
587
588
589
def get_peta_demand(mvgd, scenario):
590
    """
591
    Retrieve annual peta heat demand for residential buildings for either
592
    eGon2035 or eGon100RE scenario.
593
594
    Parameters
595
    ----------
596
    mvgd : int
597
        MV grid ID.
598
    scenario : str
599
        Possible options are eGon2035 or eGon100RE
600
601
    Returns
602
    -------
603
    df_peta_demand : pd.DataFrame
604
        Annual residential heat demand per building and scenario. Columns of
605
        the dataframe are zensus_population_id and demand.
606
607
    """
608
609
    with db.session_scope() as session:
610
        query = (
611
            session.query(
612
                MapZensusGridDistricts.zensus_population_id,
613
                EgonPetaHeat.demand,
614
            )
615
            .filter(MapZensusGridDistricts.bus_id == mvgd)
616
            .filter(
617
                MapZensusGridDistricts.zensus_population_id
618
                == EgonPetaHeat.zensus_population_id
619
            )
620
            .filter(
621
                EgonPetaHeat.sector == "residential",
622
                EgonPetaHeat.scenario == scenario,
623
            )
624
        )
625
626
        df_peta_demand = pd.read_sql(
627
            query.statement, query.session.bind, index_col=None
628
        )
629
630
    return df_peta_demand
631
632
633
def get_residential_heat_profile_ids(mvgd):