Skip to content

Commit

Permalink
minor_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielTollenaar committed Dec 10, 2024
1 parent d4b362a commit a694efc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions notebooks/samenvoegen_modellen.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,18 @@ def get_model_path(model, model_version):
# read model
ribasim_model = Model.read(model_path)

# TODO: make sure this isn't needed next round!
if model["authority"] in RESET_TABLES:
ribasim_model.remove_unassigned_basin_area()
ribasim_model = reset_static_tables(ribasim_model)

# run model
if not ribasim_model.basin_outstate.filepath.exists():
print("run model to update state")
returncode = ribasim_model.run()
if returncode != 0:
raise Exception("model won't run successfully!")
ribasim_model.update_state()
ribasim_model.update_state()

# add meta_waterbeheerder
for node_type in ribasim_model.node_table().df.node_type.unique():
Expand All @@ -211,11 +216,6 @@ def get_model_path(model, model_version):
if idx == 0:
lhm_model = ribasim_model
else:
# TODO: make sure this isn't needed next round!
if model["authority"] in RESET_TABLES:
ribasim_model.remove_unassigned_basin_area()
ribasim_model = reset_static_tables(ribasim_model)

lhm_model = concat([lhm_model, ribasim_model])
readme += f"""
**{model["authority"]}**: {model["model"]} ({model_version.version})"""
Expand Down
8 changes: 4 additions & 4 deletions src/ribasim_nl/ribasim_nl/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ def update_state(self, time_stamp: pd.Timestamp | None = None):
time_stamp (pd.Timestamp | None, optional): Timestamp in results to update basin.state with . Defaults to None.
"""
if time_stamp is None:
self.basin.state = self.basin_outstate.df
df = self.basin_outstate.df
else:
df = self.basin_results.df.loc[time_stamp][["node_id", "level"]]
df.reset_index(inplace=True, drop=True)
df.index += 1
df.index.name = "fid"
self.basin.state = df
df.index += 1
df.index.name = "fid"
self.basin.state.df = df

# methods relying on networkx. Discuss making this all in a subclass of Model
def _upstream_nodes(self, node_id):
Expand Down

0 comments on commit a694efc

Please sign in to comment.