Code Duplication    Length = 35-37 lines in 2 locations

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

@@ 1286-1322 (lines=37) @@
1283
    log.info("CTS buildings exported to DB!")
1284
1285
1286
def cts_electricity():
1287
    """
1288
    Calculate cts electricity demand share of hvmv substation profile
1289
     for buildings.
1290
    """
1291
    log.info("Start logging!")
1292
    with db.session_scope() as session:
1293
        cells_query = session.query(CtsBuildings)
1294
1295
    df_cts_buildings = pd.read_sql(
1296
        cells_query.statement, cells_query.session.bind, index_col=None
1297
    )
1298
    log.info("CTS buildings from DB imported!")
1299
    df_demand_share_2035 = calc_building_demand_profile_share(
1300
        df_cts_buildings, scenario="eGon2035", sector="electricity"
1301
    )
1302
    log.info("Profile share for egon2035 calculated!")
1303
1304
    df_demand_share_100RE = calc_building_demand_profile_share(
1305
        df_cts_buildings, scenario="eGon100RE", sector="electricity"
1306
    )
1307
    log.info("Profile share for egon100RE calculated!")
1308
1309
    df_demand_share = pd.concat(
1310
        [df_demand_share_2035, df_demand_share_100RE],
1311
        axis=0,
1312
        ignore_index=True,
1313
    )
1314
    df_demand_share.rename(columns={"id": "building_id"}, inplace=True)
1315
1316
    write_table_to_postgres(
1317
        df_demand_share,
1318
        EgonCtsElectricityDemandBuildingShare,
1319
        engine=engine,
1320
        drop=True,
1321
    )
1322
    log.info("Profile share exported to DB!")
1323
1324
1325
def cts_heat():
@@ 1325-1359 (lines=35) @@
1322
    log.info("Profile share exported to DB!")
1323
1324
1325
def cts_heat():
1326
    """
1327
    Calculate cts electricity demand share of hvmv substation profile
1328
     for buildings.
1329
    """
1330
    log.info("Start logging!")
1331
    with db.session_scope() as session:
1332
        cells_query = session.query(CtsBuildings)
1333
1334
    df_cts_buildings = pd.read_sql(
1335
        cells_query.statement, cells_query.session.bind, index_col=None
1336
    )
1337
    log.info("CTS buildings from DB imported!")
1338
1339
    df_demand_share_2035 = calc_building_demand_profile_share(
1340
        df_cts_buildings, scenario="eGon2035", sector="heat"
1341
    )
1342
    log.info("Profile share for egon2035 calculated!")
1343
    df_demand_share_100RE = calc_building_demand_profile_share(
1344
        df_cts_buildings, scenario="eGon100RE", sector="heat"
1345
    )
1346
    log.info("Profile share for egon100RE calculated!")
1347
    df_demand_share = pd.concat(
1348
        [df_demand_share_2035, df_demand_share_100RE],
1349
        axis=0,
1350
        ignore_index=True,
1351
    )
1352
1353
    write_table_to_postgres(
1354
        df_demand_share,
1355
        EgonCtsHeatDemandBuildingShare,
1356
        engine=engine,
1357
        drop=True,
1358
    )
1359
    log.info("Profile share exported to DB!")
1360
1361
1362
def get_cts_electricity_peak_load():