Code Duplication    Length = 42-42 lines in 2 locations

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

@@ 985-1026 (lines=42) @@
982
    return df_demand_share
983
984
985
def get_peta_demand(mvgd, scenario):
986
    """
987
    Retrieve annual peta heat demand for CTS for either
988
    eGon2035 or eGon100RE scenario.
989
990
    Parameters
991
    ----------
992
    mvgd : int
993
        ID of substation for which to get CTS demand.
994
    scenario : str
995
        Possible options are eGon2035 or eGon100RE
996
997
    Returns
998
    -------
999
    df_peta_demand : pd.DataFrame
1000
        Annual residential heat demand per building and scenario. Columns of
1001
        the dataframe are zensus_population_id and demand.
1002
1003
    """
1004
1005
    with db.session_scope() as session:
1006
        query = (
1007
            session.query(
1008
                MapZensusGridDistricts.zensus_population_id,
1009
                EgonPetaHeat.demand,
1010
            )
1011
            .filter(MapZensusGridDistricts.bus_id == int(mvgd))
1012
            .filter(
1013
                MapZensusGridDistricts.zensus_population_id
1014
                == EgonPetaHeat.zensus_population_id
1015
            )
1016
            .filter(
1017
                EgonPetaHeat.sector == "service",
1018
                EgonPetaHeat.scenario == scenario,
1019
            )
1020
        )
1021
1022
        df_peta_demand = pd.read_sql(
1023
            query.statement, query.session.bind, index_col=None
1024
        )
1025
1026
    return df_peta_demand
1027
1028
1029
def calc_cts_building_profiles(

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

@@ 737-778 (lines=42) @@
734
    )
735
736
737
def get_peta_demand(mvgd, scenario):
738
    """
739
    Retrieve annual peta heat demand for residential buildings for either
740
    eGon2035 or eGon100RE scenario.
741
742
    Parameters
743
    ----------
744
    mvgd : int
745
        MV grid ID.
746
    scenario : str
747
        Possible options are eGon2035 or eGon100RE
748
749
    Returns
750
    -------
751
    df_peta_demand : pd.DataFrame
752
        Annual residential heat demand per building and scenario. Columns of
753
        the dataframe are zensus_population_id and demand.
754
755
    """
756
757
    with db.session_scope() as session:
758
        query = (
759
            session.query(
760
                MapZensusGridDistricts.zensus_population_id,
761
                EgonPetaHeat.demand,
762
            )
763
            .filter(MapZensusGridDistricts.bus_id == mvgd)
764
            .filter(
765
                MapZensusGridDistricts.zensus_population_id
766
                == EgonPetaHeat.zensus_population_id
767
            )
768
            .filter(
769
                EgonPetaHeat.sector == "residential",
770
                EgonPetaHeat.scenario == scenario,
771
            )
772
        )
773
774
        df_peta_demand = pd.read_sql(
775
            query.statement, query.session.bind, index_col=None
776
        )
777
778
    return df_peta_demand
779
780
781
def get_residential_heat_profile_ids(mvgd):