Code Duplication    Length = 42-42 lines in 2 locations

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

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

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

@@ 819-860 (lines=42) @@
816
    )
817
818
819
def get_peta_demand(mvgd, scenario):
820
    """
821
    Retrieve annual peta heat demand for residential buildings for either
822
    eGon2035 or eGon100RE scenario.
823
824
    Parameters
825
    ----------
826
    mvgd : int
827
        MV grid ID.
828
    scenario : str
829
        Possible options are eGon2035 or eGon100RE
830
831
    Returns
832
    -------
833
    df_peta_demand : pd.DataFrame
834
        Annual residential heat demand per building and scenario. Columns of
835
        the dataframe are zensus_population_id and demand.
836
837
    """
838
839
    with db.session_scope() as session:
840
        query = (
841
            session.query(
842
                MapZensusGridDistricts.zensus_population_id,
843
                EgonPetaHeat.demand,
844
            )
845
            .filter(MapZensusGridDistricts.bus_id == mvgd)
846
            .filter(
847
                MapZensusGridDistricts.zensus_population_id
848
                == EgonPetaHeat.zensus_population_id
849
            )
850
            .filter(
851
                EgonPetaHeat.sector == "residential",
852
                EgonPetaHeat.scenario == scenario,
853
            )
854
        )
855
856
        df_peta_demand = pd.read_sql(
857
            query.statement, query.session.bind, index_col=None
858
        )
859
860
    return df_peta_demand
861
862
863
def get_residential_heat_profile_ids(mvgd):