Code Duplication    Length = 42-42 lines in 2 locations

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

@@ 852-893 (lines=42) @@
849
    )
850
851
852
def get_peta_demand(mvgd, scenario):
853
    """
854
    Retrieve annual peta heat demand for residential buildings for either
855
    eGon2035 or eGon100RE scenario.
856
857
    Parameters
858
    ----------
859
    mvgd : int
860
        MV grid ID.
861
    scenario : str
862
        Possible options are eGon2035 or eGon100RE
863
864
    Returns
865
    -------
866
    df_peta_demand : pd.DataFrame
867
        Annual residential heat demand per building and scenario. Columns of
868
        the dataframe are zensus_population_id and demand.
869
870
    """
871
872
    with db.session_scope() as session:
873
        query = (
874
            session.query(
875
                MapZensusGridDistricts.zensus_population_id,
876
                EgonPetaHeat.demand,
877
            )
878
            .filter(MapZensusGridDistricts.bus_id == mvgd)
879
            .filter(
880
                MapZensusGridDistricts.zensus_population_id
881
                == EgonPetaHeat.zensus_population_id
882
            )
883
            .filter(
884
                EgonPetaHeat.sector == "residential",
885
                EgonPetaHeat.scenario == scenario,
886
            )
887
        )
888
889
        df_peta_demand = pd.read_sql(
890
            query.statement, query.session.bind, index_col=None
891
        )
892
893
    return df_peta_demand
894
895
896
def get_residential_heat_profile_ids(mvgd):

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

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