Code Duplication    Length = 36-36 lines in 2 locations

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

@@ 1429-1464 (lines=36) @@
1426
    log.info("Profile share exported to DB!")
1427
1428
1429
def cts_heat():
1430
    """
1431
    Calculate cts electricity demand share of hvmv substation profile
1432
     for buildings.
1433
    """
1434
    log.info("Start logging!")
1435
    with db.session_scope() as session:
1436
        cells_query = session.query(CtsBuildings)
1437
1438
    df_cts_buildings = pd.read_sql(
1439
        cells_query.statement, cells_query.session.bind, index_col=None
1440
    )
1441
    log.info("CTS buildings from DB imported!")
1442
1443
    df_demand_share = pd.DataFrame()
1444
1445
    for scenario in config.settings()["egon-data"]["--scenarios"]:
1446
        df_demand_share_per_scenario = calc_building_demand_profile_share(
1447
            df_cts_buildings, scenario=scenario, sector="heat"
1448
        )
1449
        log.info(f"Profile share for {scenario} calculated!")
1450
1451
        df_demand_share = pd.concat(
1452
            [df_demand_share, df_demand_share_per_scenario],
1453
            axis=0,
1454
            ignore_index=True,
1455
        )
1456
1457
    df_demand_share.rename(columns={"id": "building_id"}, inplace=True)
1458
1459
    write_table_to_postgres(
1460
        df_demand_share,
1461
        EgonCtsHeatDemandBuildingShare,
1462
        drop=True,
1463
    )
1464
    log.info("Profile share exported to DB!")
1465
1466
1467
def get_cts_electricity_peak_load():
@@ 1391-1426 (lines=36) @@
1388
    log.info("CTS buildings exported to DB!")
1389
1390
1391
def cts_electricity():
1392
    """
1393
    Calculate cts electricity demand share of hvmv substation profile
1394
     for buildings.
1395
    """
1396
    log.info("Start logging!")
1397
    with db.session_scope() as session:
1398
        cells_query = session.query(CtsBuildings)
1399
1400
    df_cts_buildings = pd.read_sql(
1401
        cells_query.statement, cells_query.session.bind, index_col=None
1402
    )
1403
    log.info("CTS buildings from DB imported!")
1404
1405
    df_demand_share = pd.DataFrame()
1406
1407
    for scenario in config.settings()["egon-data"]["--scenarios"]:
1408
        df_demand_share_per_scenario = calc_building_demand_profile_share(
1409
            df_cts_buildings, scenario=scenario, sector="electricity"
1410
        )
1411
        log.info(f"Profile share for {scenario} calculated!")
1412
1413
        df_demand_share = pd.concat(
1414
            [df_demand_share, df_demand_share_per_scenario],
1415
            axis=0,
1416
            ignore_index=True,
1417
        )
1418
1419
    df_demand_share.rename(columns={"id": "building_id"}, inplace=True)
1420
1421
    write_table_to_postgres(
1422
        df_demand_share,
1423
        EgonCtsElectricityDemandBuildingShare,
1424
        drop=True,
1425
    )
1426
    log.info("Profile share exported to DB!")
1427
1428
1429
def cts_heat():