Code Duplication    Length = 33-34 lines in 2 locations

src/egon/data/datasets/pypsaeur/__init__.py 2 locations

@@ 366-398 (lines=33) @@
363
        print("Pypsa-eur is not executed due to the settings of egon-data")
364
365
366
def read_network(planning_horizon=3):
367
    if config.settings()["egon-data"]["--run-pypsa-eur"]:
368
        with open(
369
            __path__[0] + "/datasets/pypsaeur/config_solve.yaml", "r"
370
        ) as stream:
371
            data_config = yaml.safe_load(stream)
372
373
        target_file = (
374
            Path(".")
375
            / "run-pypsa-eur"
376
            / "pypsa-eur"
377
            / "results"
378
            / data_config["run"]["name"]
379
            / "postnetworks"
380
            / f"base_s_{data_config['scenario']['clusters'][0]}"
381
            f"_l{data_config['scenario']['ll'][0]}"
382
            f"_{data_config['scenario']['opts'][0]}"
383
            f"_{data_config['scenario']['sector_opts'][0]}"
384
            f"_{data_config['scenario']['planning_horizons'][planning_horizon]}.nc"
385
        )
386
387
    else:
388
        target_file = (
389
            Path(".")
390
            / "data_bundle_powerd_data"
391
            / "pypsa_eur"
392
            / "21122024_3h_clean_run"
393
            / "results"
394
            / "postnetworks"
395
            / "base_s_39_lc1.25__cb40ex0-T-H-I-B-solar+p3-dist1_2045.nc"
396
        )
397
398
    return pypsa.Network(target_file)
399
400
401
def clean_database():
@@ 1662-1695 (lines=34) @@
1659
        )
1660
1661
1662
def prepared_network(planning_horizon=3):
1663
    if egon.data.config.settings()["egon-data"]["--run-pypsa-eur"]:
1664
        with open(
1665
            __path__[0] + "/datasets/pypsaeur/config_prepare.yaml", "r"
1666
        ) as stream:
1667
            data_config = yaml.safe_load(stream)
1668
1669
        target_file = (
1670
            Path(".")
1671
            / "run-pypsa-eur"
1672
            / "pypsa-eur"
1673
            / "results"
1674
            / data_config["run"]["name"]
1675
            / "prenetworks"
1676
            / f"base_s_{data_config['scenario']['clusters'][0]}"
1677
            f"_l{data_config['scenario']['ll'][0]}"
1678
            f"_{data_config['scenario']['opts'][0]}"
1679
            f"_{data_config['scenario']['sector_opts'][0]}"
1680
            f"_{data_config['scenario']['planning_horizons'][planning_horizon]}.nc"
1681
        )
1682
1683
    else:
1684
        target_file = (
1685
            Path(".")
1686
            / "data_bundle_powerd_data"
1687
            / "pypsa_eur"
1688
            / "21122024_3h_clean_run"
1689
            / "results"
1690
            / "prenetworks"
1691
            / "prenetwork_post-manipulate_pre-solve"
1692
            / "base_s_39_lc1.25__cb40ex0-T-H-I-B-solar+p3-dist1_2045.nc"
1693
        )
1694
1695
    return pypsa.Network(target_file.absolute().as_posix())
1696
1697
1698
def overwrite_H2_pipeline_share():