Code Duplication    Length = 32-34 lines in 2 locations

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

@@ 1284-1317 (lines=34) @@
1281
    log.info("CTS buildings exported to DB!")
1282
1283
1284
def cts_electricity():
1285
    """
1286
    Calculate cts electricity demand share of hvmv substation profile
1287
     for buildings.
1288
    """
1289
    log.info("Start logging!")
1290
    with db.session_scope() as session:
1291
        cells_query = session.query(CtsBuildings)
1292
1293
    df_cts_buildings = pd.read_sql(
1294
        cells_query.statement, cells_query.session.bind, index_col=None
1295
    )
1296
    log.info("CTS buildings from DB imported!")
1297
    df_demand_share_2035 = calc_building_demand_profile_share(
1298
        df_cts_buildings, scenario="eGon2035", sector="electricity"
1299
    )
1300
    log.info("Profile share for egon2035 calculated!")
1301
1302
    df_demand_share_100RE = calc_building_demand_profile_share(
1303
        df_cts_buildings, scenario="eGon100RE", sector="electricity"
1304
    )
1305
    log.info("Profile share for egon100RE calculated!")
1306
1307
    df_demand_share = pd.concat(
1308
        [df_demand_share_2035, df_demand_share_100RE],
1309
        axis=0,
1310
        ignore_index=True,
1311
    )
1312
    df_demand_share.rename(columns={"id": "building_id"}, inplace=True)
1313
1314
    write_table_to_postgres(
1315
        df_demand_share, EgonCtsElectricityDemandBuildingShare, drop=True
1316
    )
1317
    log.info("Profile share exported to DB!")
1318
1319
1320
def cts_heat():
@@ 1320-1351 (lines=32) @@
1317
    log.info("Profile share exported to DB!")
1318
1319
1320
def cts_heat():
1321
    """
1322
    Calculate cts electricity demand share of hvmv substation profile
1323
     for buildings.
1324
    """
1325
    log.info("Start logging!")
1326
    with db.session_scope() as session:
1327
        cells_query = session.query(CtsBuildings)
1328
1329
    df_cts_buildings = pd.read_sql(
1330
        cells_query.statement, cells_query.session.bind, index_col=None
1331
    )
1332
    log.info("CTS buildings from DB imported!")
1333
1334
    df_demand_share_2035 = calc_building_demand_profile_share(
1335
        df_cts_buildings, scenario="eGon2035", sector="heat"
1336
    )
1337
    log.info("Profile share for egon2035 calculated!")
1338
    df_demand_share_100RE = calc_building_demand_profile_share(
1339
        df_cts_buildings, scenario="eGon100RE", sector="heat"
1340
    )
1341
    log.info("Profile share for egon100RE calculated!")
1342
    df_demand_share = pd.concat(
1343
        [df_demand_share_2035, df_demand_share_100RE],
1344
        axis=0,
1345
        ignore_index=True,
1346
    )
1347
1348
    write_table_to_postgres(
1349
        df_demand_share, EgonCtsHeatDemandBuildingShare, drop=True
1350
    )
1351
    log.info("Profile share exported to DB!")
1352
1353
1354
def get_cts_electricity_peak_load():