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

NetworkValidator #128

Closed
8 tasks done
DanielTollenaar opened this issue Aug 15, 2024 · 2 comments
Closed
8 tasks done

NetworkValidator #128

DanielTollenaar opened this issue Aug 15, 2024 · 2 comments

Comments

@DanielTollenaar
Copy link
Collaborator

DanielTollenaar commented Aug 15, 2024

We see some network-issues in regional models (see #102). We want to get an overview within Python so we can (1) see all issues at once and (2) correct them on-the-fly.

Functions build:

  • node_overlapping: Check if the node-geometry overlaps another node within tolerance (default=1m)
  • node_duplicated: Check if node_id is duplicated
  • node_internal_basin: Check if a Node with node_type Basin is not connected to another node
  • edge_duplicated: Check if the from_node_id and to_node_id in the edge-table is duplicated
  • edge_missing_nodes: Check if the from_node_id and to_node_id in the edge-table are both as node-id in the node-table
  • edge_incorrect_from_node: Check if the from_node_type in edge-table in matches the node_type of the corresponding node in the node-table
  • edge_incorrect_to_node: Check if the to_node_type in edge-table in matches the node_type of the corresponding node in the node-table
  • edge_incorrect_connectivity Check if the geometries of the from_node_id and to_node_id are on the start and end vertices of the edge-geometry within tolerance (default=1m)
@DanielTollenaar DanielTollenaar converted this from a draft issue Aug 15, 2024
@Huite
Copy link

Huite commented Aug 15, 2024

I noticed:
#102 (comment)

Maybe worthwhile to check connected components:

https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csgraph.connected_components.html

I guess multiple separate networks should be valid. However, if a component is 1- or 2-sized, it's probably wrong?

n_labels, labels = scipy.sparse.csgraph.connected_components(adj_matrix)
if (np.bincounts(labels) == 1).any():
    raise ValueError("...")

Easiest to setup as a COO sparse matrix using from_node_id and to_node_id. If a Ugrid1d topology is available, the node_node_connectivity can be directly used:

https://deltares.github.io/xugrid/api/xugrid.Ugrid1d.node_node_connectivity.html#xugrid-ugrid1d-node-node-connectivity

@DanielTollenaar
Copy link
Collaborator Author

Fixed by #129

@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Ribasim NL Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

No branches or pull requests

2 participants