Code Duplication    Length = 37-37 lines in 2 locations

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

@@ 1374-1410 (lines=37) @@
1371
    log.info("Profile share exported to DB!")
1372
1373
1374
def cts_heat():
1375
    """
1376
    Calculate cts electricity demand share of hvmv substation profile
1377
     for buildings.
1378
    """
1379
    log.info("Start logging!")
1380
    with db.session_scope() as session:
1381
        cells_query = session.query(CtsBuildings)
1382
1383
    df_cts_buildings = pd.read_sql(
1384
        cells_query.statement, cells_query.session.bind, index_col=None
1385
    )
1386
    log.info("CTS buildings from DB imported!")
1387
1388
    df_demand_share_2035 = calc_building_demand_profile_share(
1389
        df_cts_buildings, scenario="eGon2035", sector="heat"
1390
    )
1391
    log.info("Profile share for egon2035 calculated!")
1392
    df_demand_share_100RE = calc_building_demand_profile_share(
1393
        df_cts_buildings, scenario="eGon100RE", sector="heat"
1394
    )
1395
    log.info("Profile share for egon100RE calculated!")
1396
    df_demand_share = pd.concat(
1397
        [df_demand_share_2035, df_demand_share_100RE],
1398
        axis=0,
1399
        ignore_index=True,
1400
    )
1401
1402
    df_demand_share.rename(columns={"id": "building_id"}, inplace=True)
1403
1404
    write_table_to_postgres(
1405
        df_demand_share,
1406
        EgonCtsHeatDemandBuildingShare,
1407
        engine=engine,
1408
        drop=True,
1409
    )
1410
    log.info("Profile share exported to DB!")
1411
1412
1413
def get_cts_electricity_peak_load():
@@ 1335-1371 (lines=37) @@
1332
    log.info("CTS buildings exported to DB!")
1333
1334
1335
def cts_electricity():
1336
    """
1337
    Calculate cts electricity demand share of hvmv substation profile
1338
     for buildings.
1339
    """
1340
    log.info("Start logging!")
1341
    with db.session_scope() as session:
1342
        cells_query = session.query(CtsBuildings)
1343
1344
    df_cts_buildings = pd.read_sql(
1345
        cells_query.statement, cells_query.session.bind, index_col=None
1346
    )
1347
    log.info("CTS buildings from DB imported!")
1348
    df_demand_share_2035 = calc_building_demand_profile_share(
1349
        df_cts_buildings, scenario="eGon2035", sector="electricity"
1350
    )
1351
    log.info("Profile share for egon2035 calculated!")
1352
1353
    df_demand_share_100RE = calc_building_demand_profile_share(
1354
        df_cts_buildings, scenario="eGon100RE", sector="electricity"
1355
    )
1356
    log.info("Profile share for egon100RE calculated!")
1357
1358
    df_demand_share = pd.concat(
1359
        [df_demand_share_2035, df_demand_share_100RE],
1360
        axis=0,
1361
        ignore_index=True,
1362
    )
1363
    df_demand_share.rename(columns={"id": "building_id"}, inplace=True)
1364
1365
    write_table_to_postgres(
1366
        df_demand_share,
1367
        EgonCtsElectricityDemandBuildingShare,
1368
        engine=engine,
1369
        drop=True,
1370
    )
1371
    log.info("Profile share exported to DB!")
1372
1373
1374
def cts_heat():