Code Duplication    Length = 37-37 lines in 2 locations

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

@@ 1401-1437 (lines=37) @@
1398
    log.info("Profile share exported to DB!")
1399
1400
1401
def cts_heat():
1402
    """
1403
    Calculate cts electricity demand share of hvmv substation profile
1404
     for buildings.
1405
    """
1406
    log.info("Start logging!")
1407
    with db.session_scope() as session:
1408
        cells_query = session.query(CtsBuildings)
1409
1410
    df_cts_buildings = pd.read_sql(
1411
        cells_query.statement, cells_query.session.bind, index_col=None
1412
    )
1413
    log.info("CTS buildings from DB imported!")
1414
1415
    df_demand_share_2035 = calc_building_demand_profile_share(
1416
        df_cts_buildings, scenario="eGon2035", sector="heat"
1417
    )
1418
    log.info("Profile share for egon2035 calculated!")
1419
    df_demand_share_100RE = calc_building_demand_profile_share(
1420
        df_cts_buildings, scenario="eGon100RE", sector="heat"
1421
    )
1422
    log.info("Profile share for egon100RE calculated!")
1423
    df_demand_share = pd.concat(
1424
        [df_demand_share_2035, df_demand_share_100RE],
1425
        axis=0,
1426
        ignore_index=True,
1427
    )
1428
1429
    df_demand_share.rename(columns={"id": "building_id"}, inplace=True)
1430
1431
    write_table_to_postgres(
1432
        df_demand_share,
1433
        EgonCtsHeatDemandBuildingShare,
1434
        engine=engine,
1435
        drop=True,
1436
    )
1437
    log.info("Profile share exported to DB!")
1438
1439
1440
def get_cts_electricity_peak_load():
@@ 1362-1398 (lines=37) @@
1359
    log.info("CTS buildings exported to DB!")
1360
1361
1362
def cts_electricity():
1363
    """
1364
    Calculate cts electricity demand share of hvmv substation profile
1365
     for buildings.
1366
    """
1367
    log.info("Start logging!")
1368
    with db.session_scope() as session:
1369
        cells_query = session.query(CtsBuildings)
1370
1371
    df_cts_buildings = pd.read_sql(
1372
        cells_query.statement, cells_query.session.bind, index_col=None
1373
    )
1374
    log.info("CTS buildings from DB imported!")
1375
    df_demand_share_2035 = calc_building_demand_profile_share(
1376
        df_cts_buildings, scenario="eGon2035", sector="electricity"
1377
    )
1378
    log.info("Profile share for egon2035 calculated!")
1379
1380
    df_demand_share_100RE = calc_building_demand_profile_share(
1381
        df_cts_buildings, scenario="eGon100RE", sector="electricity"
1382
    )
1383
    log.info("Profile share for egon100RE calculated!")
1384
1385
    df_demand_share = pd.concat(
1386
        [df_demand_share_2035, df_demand_share_100RE],
1387
        axis=0,
1388
        ignore_index=True,
1389
    )
1390
    df_demand_share.rename(columns={"id": "building_id"}, inplace=True)
1391
1392
    write_table_to_postgres(
1393
        df_demand_share,
1394
        EgonCtsElectricityDemandBuildingShare,
1395
        engine=engine,
1396
        drop=True,
1397
    )
1398
    log.info("Profile share exported to DB!")
1399
1400
1401
def cts_heat():