Code Duplication    Length = 37-37 lines in 2 locations

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

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