Code Duplication    Length = 37-37 lines in 2 locations

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

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