Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rws network #67

Merged
merged 53 commits into from
Feb 26, 2024
Merged

Rws network #67

merged 53 commits into from
Feb 26, 2024

Conversation

d2hydro
Copy link
Contributor

@d2hydro d2hydro commented Feb 19, 2024

All code to create the hws and lhm 2024.2.X model-versions.

@visr, curious to your thoughts on how we merge models. I resetting a model index and concatting multiple models is defined here
https://github.com/Deltares/Ribasim-NL/blob/RWS-network/src/ribasim_nl/ribasim_nl/reset_index.py
https://github.com/Deltares/Ribasim-NL/blob/RWS-network/src/ribasim_nl/ribasim_nl/concat.py

For that I need to know tables with node_id columns from ribasim. Would be great if I could read that from the module directly instead of having my own global variable:

CLASS_TABLES = {
"Basin": ["static", "profile", "state"],
"LinearResistance": ["static"],
"ManningResistance": ["static"],
"Pump": ["static"],
"Outlet": ["static"],
"Terminal": ["static"],
"FlowBoundary": ["static"],
"LevelBoundary": ["static", "time"],
"FractionalFlow": ["static"],
"TabulatedRatingCurve": ["static"],
}

@d2hydro d2hydro requested a review from visr February 19, 2024 07:20
@visr
Copy link
Member

visr commented Feb 19, 2024

In Ribasim 2024.2.0 the node IDs are only unique to the node type, so that simplifies the merging quite a bit.

Deltares/Ribasim#1113

@d2hydro
Copy link
Contributor Author

d2hydro commented Feb 19, 2024

@visr; actually I think it will make merging (reindexing) a little bit more complex. I would like to have all nodes a unique id so I can create a networkx object (using Node and Edge) and route trought the network. But I can concat node_id and type and do the same for edge, so that's OK.

@visr
Copy link
Member

visr commented Feb 21, 2024

This should work:

CLASS_TABLES = {}
for node in model.nodes().values():
    CLASS_TABLES[node.get_input_type()] = node.fields()

Downside is that it requires a model instance. But the results doesn't depend on the model.

Copy link
Member

@visr visr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments. Glad to see this progress, a lot of work has been done. Looking at the amount of code I feel like the upcoming changes in Ribasim would've been useful. Updating to the new version might be a bit painful, also since there are not many tests here.

.vscode/settings.json Outdated Show resolved Hide resolved
src/ribasim_nl/ribasim_nl/discrete_control.py Outdated Show resolved Hide resolved
src/ribasim_nl/ribasim_nl/discrete_control.py Show resolved Hide resolved
src/ribasim_nl/ribasim_nl/geodataframe.py Outdated Show resolved Hide resolved
src/ribasim_nl/ribasim_nl/geodataframe.py Outdated Show resolved Hide resolved
src/ribasim_nl/ribasim_nl/verdeelsleutels.py Outdated Show resolved Hide resolved
database.gpkg Outdated Show resolved Hide resolved
scripts/merge_models Outdated Show resolved Hide resolved
notebooks/samenvoegen_modellen.py Show resolved Hide resolved
notebooks/rijkswaterstaat/1_create_bathymetrie.py Outdated Show resolved Hide resolved
Co-authored-by: Martijn Visser <[email protected]>
@visr visr merged commit 0cc9ad9 into main Feb 26, 2024
4 checks passed
@visr visr deleted the RWS-network branch February 26, 2024 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants