-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes for #155 --------- Co-authored-by: Martijn Visser <[email protected]>
- Loading branch information
1 parent
2559c7e
commit e948608
Showing
3 changed files
with
128 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# %% | ||
from ribasim_nl import CloudStorage | ||
|
||
cloud = CloudStorage() | ||
|
||
data_url = cloud.joinurl("Noorderzijlvest", "verwerkt") | ||
|
||
# %% | ||
cloud.download_content(data_url) | ||
|
||
# %% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# %% | ||
import numpy as np | ||
import pandas as pd | ||
from ribasim.nodes import basin, level_boundary, manning_resistance, outlet, pump | ||
|
||
from ribasim_nl import CloudStorage, Model, NetworkValidator | ||
|
||
cloud = CloudStorage() | ||
|
||
authority = "Noorderzijlvest" | ||
short_name = "nzv" | ||
|
||
ribasim_toml = cloud.joinpath(authority, "modellen", f"{authority}_2024_6_3", f"{short_name}.toml") | ||
database_gpkg = ribasim_toml.with_name("database.gpkg") | ||
|
||
# %% read model | ||
model = Model.read(ribasim_toml) | ||
ribasim_toml = cloud.joinpath(authority, "modellen", f"{authority}_fix_model_network", f"{short_name}.toml") | ||
network_validator = NetworkValidator(model) | ||
|
||
# %% some stuff we'll need again | ||
manning_data = manning_resistance.Static(length=[100], manning_n=[0.04], profile_width=[10], profile_slope=[1]) | ||
level_data = level_boundary.Static(level=[0]) | ||
|
||
basin_data = [ | ||
basin.Profile(level=[0.0, 1.0], area=[0.01, 1000.0]), | ||
basin.Static( | ||
drainage=[0.0], | ||
potential_evaporation=[0.001 / 86400], | ||
infiltration=[0.0], | ||
precipitation=[0.005 / 86400], | ||
), | ||
basin.State(level=[0]), | ||
] | ||
outlet_data = outlet.Static(flow_rate=[100]) | ||
pump_data = pump.Static(flow_rate=[10]) | ||
|
||
# %% | ||
# %% https://github.com/Deltares/Ribasim-NL/issues/155#issuecomment-2454955046 | ||
|
||
# 76 edges bij opgeheven nodes verwijderen | ||
mask = model.edge.df.to_node_id.isin(model.node_table().df.index) & model.edge.df.from_node_id.isin( | ||
model.node_table().df.index | ||
) | ||
missing_edges_df = model.edge.df[~mask] | ||
|
||
model.edge.df = model.edge.df[~model.edge.df.index.isin(missing_edges_df.index)] | ||
|
||
# %% | ||
# basin-profielen updaten | ||
|
||
df = pd.DataFrame( | ||
{ | ||
"node_id": np.repeat(model.basin.node.df.index.to_numpy(), 2), | ||
"level": [0.0, 1.0] * len(model.basin.node.df), | ||
"area": [0.01, 1000.0] * len(model.basin.node.df), | ||
} | ||
) | ||
df.index.name = "fid" | ||
model.basin.profile.df = df | ||
|
||
df = model.basin.profile.df.groupby("node_id")[["level"]].max().reset_index() | ||
df.index.name = "fid" | ||
model.basin.state.df = df | ||
|
||
# %% | ||
# tabulated_rating_curves updaten | ||
df = pd.DataFrame( | ||
{ | ||
"node_id": np.repeat(model.tabulated_rating_curve.node.df.index.to_numpy(), 2), | ||
"level": [0.0, 5] * len(model.tabulated_rating_curve.node.df), | ||
"flow_rate": [0, 0.1] * len(model.tabulated_rating_curve.node.df), | ||
} | ||
) | ||
df.index.name = "fid" | ||
model.tabulated_rating_curve.static.df = df | ||
|
||
|
||
# %% | ||
|
||
# level_boundaries updaten | ||
df = pd.DataFrame( | ||
{ | ||
"node_id": model.level_boundary.node.df.index.to_list(), | ||
"level": [0.0] * len(model.level_boundary.node.df), | ||
} | ||
) | ||
df.index.name = "fid" | ||
model.level_boundary.static.df = df | ||
|
||
# %% | ||
# manning_resistance updaten | ||
length = len(model.manning_resistance.node.df) | ||
df = pd.DataFrame( | ||
{ | ||
"node_id": model.manning_resistance.node.df.index.to_list(), | ||
"length": [100.0] * length, | ||
"manning_n": [100.0] * length, | ||
"profile_width": [100.0] * length, | ||
"profile_slope": [100.0] * length, | ||
} | ||
) | ||
df.index.name = "fid" | ||
model.manning_resistance.static.df = df | ||
|
||
|
||
# %% write model | ||
model.use_validation = True | ||
model.write(ribasim_toml) | ||
|
||
# %% |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.