Skip to content

Commit

Permalink
Allow importing extnesion scenario, e.g. for lines from NEP
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaraBuettner committed Oct 31, 2023
1 parent 94acf8d commit c2436da
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions etrago/tools/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ def __init__(
start_snapshot=1,
end_snapshot=20,
temp_id=1,
scenario_extension=False,
**kwargs,
):
self.scn_name = scn_name
self.start_snapshot = start_snapshot
self.end_snapshot = end_snapshot
self.temp_id = temp_id
self.scenario_extension = scenario_extension

super().__init__(engine, session, **kwargs)

Expand Down Expand Up @@ -207,6 +209,14 @@ def fetch_by_relname(self, name):
egon_etrago_transformer,
)

if self.scenario_extension:
from saio.grid import ( # noqa: F401
egon_etrago_extension_bus as egon_etrago_bus,
egon_etrago_extension_line as egon_etrago_line,
egon_etrago_extension_link as egon_etrago_link,
egon_etrago_extension_transformer as egon_etrago_transformer,
)

index = f"{name.lower()}_id"

if name == "Transformer":
Expand Down Expand Up @@ -798,22 +808,17 @@ def extension(self, **kwargs):
"""
if self.args["scn_extension"] is not None:
if self.args["gridversion"] is None:
ormcls_prefix = "EgoGridPfHvExtension"
else:
ormcls_prefix = "EgoPfHvExtension"

for i in range(len(self.args["scn_extension"])):
scn_extension = self.args["scn_extension"][i]
# Adding overlay-network to existing network
scenario = NetworkScenario(
self.engine,
self.session,
version=self.args["gridversion"],
prefix=ormcls_prefix,
method=kwargs.get("method", "lopf"),
start_snapshot=self.args["start_snapshot"],
end_snapshot=self.args["end_snapshot"],
scn_name="extension_" + scn_extension,
scn_name=scn_extension,
scenario_extension=True,
)

self.network = scenario.build_network(self.network)
Expand Down

0 comments on commit c2436da

Please sign in to comment.