-
Notifications
You must be signed in to change notification settings - Fork 5
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
Don't require unique node IDs #1513
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, some nitpicks. This will break the current assumptions in the Delwaq coupling scripts, so maybe not merge just yet?
I'll make the changes so the coupling can handle the non-uniqueness. Would be good to also create a new coupling test that takes a horribly non-unique model to convert. edit: Done, back to you @visr (feel free to review my changes) |
Fixes #1690 as a 🎁 for @deltamarnix when he is back from holiday. Triggered by #1648, which seems very hard to do in QGIS as it doesn't support compound indexes and we dislike a separate global unique id. In a discussion with @visr he mentioned most people don't use the non-global unique id feature (yet). Reverts #1513. Partially reverts #1690 as the `NodeID` changes are not reverted, as it is quite useful to know the node_type in several parts of the code (instead of only a node_id). Therefore, I've added a new `NodeID` constructor and joined the Edge table with the Node table. I had to change the node_ids of several new test models created by @SouthEndMusic, bit of a pain, but the tests seem to pass still. Furthermore, I changed the `node.add` functionality to *return* the `NodeData`, which should make the `edge.add` more straightforward (and pave the way for automatic id numbering in the future). So this: ```julia model.terminal.add(Node(terminal_id, Point(500, 200))) model.tabulated_rating_curve.add( Node(6, Point(450, 200)), [tabulated_rating_curve.Static(level=[0.0, 1.0], flow_rate=[0.0, 10 / 86400])], ) model.edge.add( model.basin[6], model.tabulated_rating_curve[6], ) model.edge.add( model.tabulated_rating_curve[6], model.terminal[terminal_id], ) ``` becomes this: ```julia term = model.terminal.add(Node(terminal_id, Point(500, 200))) trc0 = model.tabulated_rating_curve.add( Node(0, Point(450, 200)), [tabulated_rating_curve.Static(level=[0.0, 1.0], flow_rate=[0.0, 10 / 86400])], ) model.edge.add( basin6, trc0, ) model.edge.add(trc0, term) ``` I've made this change in a single Python test model, and in the first model of the examples notebook. We could gradually change this further over time. --------- Co-authored-by: Martijn Visser <[email protected]>
Fixes #1318
Fixes #1256
@evetion I didn't touch the Delwaq
node_lookup
. If only Basins are in the graph, then you can still use an ID as a unique index.The #1256 fix in 72dcf24 is not tested, since Ribasim-Python stops us from creating such an invalid model. I manually confirmed it works by duplicating rows in QGIS.
The
main
methods were needed to fixpixi run ribasim-core
.