Closed DanielTollenaar closed 2 months ago
Hi @DanielTollenaar, nice to read about the ideas for Ribasim NL. My two cents:
Model
as the class name can be confusing, especially if one works in both code bases. Something like NLModel
(whether aliased at import or not) seems a better choice to me.
- I think
Model
as the class name can be confusing, especially if one works in both code bases. Something likeNLModel
(whether aliased at import or not) seems a better choice to me.
I've considered NLModel
first, but I deliberately changed it to Model as it would be super-easy to switch within existing building-scripts by chaning the import.
- On inheritance is the age-old discussion on "Composition over inheritance".
Inheritance I only forsee for the Model-class, "extra gimmics" should be composed to this Model-class follow your lead. @visr In that sense, I woul normally expect to retrieve basin results as df by model.results.basin.df
, but model.results seems to be reserved for result-settings rather than actual results, is that correct?
model.results seems to be reserved for result-settings
Yes that's right. We don't really have any code for dealing with results other than model.to_xugrid()
, see here:
Some API for results (if present) would be nice. Not sure if something like model.results.basin.df
can be combined with the TOML results section.
Will be part of https://github.com/Deltares/Ribasim-NL/tree/hws_2024.5
Hi @visr and @evetion,
My thought is to build a
ribasim_nl.Model
class inhereting all specs from ribasim.Model and add some extra features. I have made a start in this branch; now the results of a model can be read in a DataFrame directly by running the code below.I am curious to your thought on this, if this is a proper approach or if there are better ways to achieve this.
I think this can benefit the ribasim-repo as I can imagine some code could be copied to the ribasim-repository later, e.g.
model.merge(other_model)
,model.clip_by_polygon(polygon:shapely.geometry.Polygon)
.Other methods probably will be NL-specific (e.g. forcing specific meta_columns at writing as mentioned in #68, init a model from the CloudStorage, etc).
The start I've made is here: https://github.com/Deltares/Ribasim-NL/blob/ribasim_nl.Model/src/ribasim_nl/ribasim_nl/model.py