Deltares / Ribasim

Water resources modeling
https://deltares.github.io/Ribasim/
MIT License
36 stars 5 forks source link

Support `meta_` kwargs for Node and `model.edge.add` #1560

Closed visr closed 1 week ago

visr commented 1 week ago

For most data tables we accept and carry extra columns as long as they are prefixed with meta_. This is tested here and implemented on TableModel here.

With the add API redesign the Node and Edge table no longer inherit this behavior, and thus don't support extra columns. However metadata is often most relevant for these two tables.

I expect these to work and write these columns to the database. If they are not prefixed with meta_ it should error. Right now for Node it silently ignores any unknown kwargs.

from ribasim import Model, Node
from shapely.geometry import Point

Node(1, Point(3, 1), meta_a = 1)

model.edge.add(
    model.tabulated_rating_curve[1],
    model.terminal[1],
    meta_b = 2,
)
visr commented 1 week ago

Brought up by @DanielTollenaar, who now works around this limitation by setting it directly in the underlying dataframe:

model.basin.node.df.loc[0, "meta_code"] = "test"