Code Duplication    Length = 42-42 lines in 2 locations

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(

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

@@ 874-915 (lines=42) @@
871
    )
872
873
874
def get_peta_demand(mvgd, scenario):
875
    """
876
    Retrieve annual peta heat demand for residential buildings for either
877
    eGon2035 or eGon100RE scenario.
878
879
    Parameters
880
    ----------
881
    mvgd : int
882
        MV grid ID.
883
    scenario : str
884
        Possible options are eGon2035 or eGon100RE
885
886
    Returns
887
    -------
888
    df_peta_demand : pd.DataFrame
889
        Annual residential heat demand per building and scenario. Columns of
890
        the dataframe are zensus_population_id and demand.
891
892
    """
893
894
    with db.session_scope() as session:
895
        query = (
896
            session.query(
897
                MapZensusGridDistricts.zensus_population_id,
898
                EgonPetaHeat.demand,
899
            )
900
            .filter(MapZensusGridDistricts.bus_id == mvgd)
901
            .filter(
902
                MapZensusGridDistricts.zensus_population_id
903
                == EgonPetaHeat.zensus_population_id
904
            )
905
            .filter(
906
                EgonPetaHeat.sector == "residential",
907
                EgonPetaHeat.scenario == scenario,
908
            )
909
        )
910
911
        df_peta_demand = pd.read_sql(
912
            query.statement, query.session.bind, index_col=None
913
        )
914
915
    return df_peta_demand
916
917
918
def get_residential_heat_profile_ids(mvgd):