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

Merging models take 2 #1297

Open
SouthEndMusic opened this issue Mar 20, 2024 · 0 comments
Open

Merging models take 2 #1297

SouthEndMusic opened this issue Mar 20, 2024 · 0 comments
Labels
python Relates to one of the Ribasim python packages

Comments

@SouthEndMusic
Copy link
Collaborator

A few moons ago I made an attempt at supporting merging models in Ribasim Python, which was never merged:
Issue: #912
PR: #914

A few things have changed in Ribasim Python since then, most notably:

  • having non-unique node IDs, which we must use here,
  • the Add-API, which I suggest we do not use, and directly merge dataframes just as in the previous attempt.

New merge method structure

I propose the following structure for a method model.merge(other):

  • First obtain the highest subnetwork_id in model:
subnetwork_id_shift = self.max_subnetwork_id()

where self.max_subnetwork_id is a method which loops over the now distributed chunks of the node table to find the maximum subnetwork ID;

  • Now loop over all node types (e.g. node_type = basin) and call a merge method on the level of NodeModel (?):
node_id_type_shift = self.node_type.merge(other.node_type, subnetwork_id_shift)

This merge method looks something like this:

function merge(self, other, subnetwork_id_shift) -> Int:
   node_id_shift = max(self.node.df.node_id)

   # merge node table chunks using the node_id and subnetwork_id shifts
   ...

   # merge other tables using the node_id shift
   ...

   return node_id_shift
  • Now the edge tables can be merged using the node ID shifts from all different node types. What to do with the edge ID?
  • Special care has to be taken with tables from node types which refer to nodes from other types (i.e. control node types), in which the node ID shifts also have to be applied.
@github-project-automation github-project-automation bot moved this to To do in Ribasim Mar 20, 2024
@SouthEndMusic SouthEndMusic added the python Relates to one of the Ribasim python packages label Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Relates to one of the Ribasim python packages
Projects
Status: To do
Development

No branches or pull requests

1 participant