Code Duplication    Length = 31-32 lines in 2 locations

src/egon/data/datasets/electricity_demand_timeseries/cts_buildings.py 2 locations

@@ 1243-1273 (lines=31) @@
1240
    log.info("CTS buildings exported to DB!")
1241
1242
1243
def cts_electricity():
1244
    """
1245
    Calculate cts electricity demand share of hvmv substation profile
1246
     for buildings.
1247
    """
1248
    log.info("Start logging!")
1249
    with db.session_scope() as session:
1250
        cells_query = session.query(CtsBuildings)
1251
1252
    df_cts_buildings = pd.read_sql(
1253
        cells_query.statement, cells_query.session.bind, index_col=None
1254
    )
1255
    log.info("CTS buildings from DB imported!")
1256
    df_demand_share_2035 = calc_building_demand_profile_share(
1257
        df_cts_buildings, scenario="eGon2035", sector="electricity"
1258
    )
1259
    log.info("Profile share for egon2035 calculated!")
1260
1261
    df_demand_share_100RE = calc_building_demand_profile_share(
1262
        df_cts_buildings, scenario="eGon100RE", sector="electricity"
1263
    )
1264
    log.info("Profile share for egon100RE calculated!")
1265
1266
    df_demand_share = pd.concat(
1267
        [df_demand_share_2035, df_demand_share_100RE],
1268
        axis=0,
1269
        ignore_index=True,
1270
    )
1271
1272
    write_table_to_postgres(
1273
        df_demand_share, EgonCtsElectricityDemandBuildingShare, drop=True
1274
    )
1275
    log.info("Profile share exported to DB!")
1276
@@ 1278-1309 (lines=32) @@
1275
    log.info("Profile share exported to DB!")
1276
1277
1278
def cts_heat():
1279
    """
1280
    Calculate cts electricity demand share of hvmv substation profile
1281
     for buildings.
1282
    """
1283
    log.info("Start logging!")
1284
    with db.session_scope() as session:
1285
        cells_query = session.query(CtsBuildings)
1286
1287
    df_cts_buildings = pd.read_sql(
1288
        cells_query.statement, cells_query.session.bind, index_col=None
1289
    )
1290
    log.info("CTS buildings from DB imported!")
1291
1292
    df_demand_share_2035 = calc_building_demand_profile_share(
1293
        df_cts_buildings, scenario="eGon2035", sector="heat"
1294
    )
1295
    log.info("Profile share for egon2035 calculated!")
1296
    df_demand_share_100RE = calc_building_demand_profile_share(
1297
        df_cts_buildings, scenario="eGon100RE", sector="heat"
1298
    )
1299
    log.info("Profile share for egon100RE calculated!")
1300
    df_demand_share = pd.concat(
1301
        [df_demand_share_2035, df_demand_share_100RE],
1302
        axis=0,
1303
        ignore_index=True,
1304
    )
1305
1306
    write_table_to_postgres(
1307
        df_demand_share, EgonCtsHeatDemandBuildingShare, drop=True
1308
    )
1309
    log.info("Profile share exported to DB!")
1310
1311
1312
def get_cts_electricity_peak_load():