layout
layout
Layout of a model on the map: nodes not on top of each other, and links without overlapping segments.
This only changes node and link geometries, which Ribasim does not use in the simulation.
Functions
| Name | Description |
|---|---|
| coincident_nodes | Pairs of node ids that are within distance of each other, as an array of shape (2, n). |
| move_nodes | Move nodes, and the ends of their links along. |
| offset_junctions | Offset the Junctions to the right of the direction of the flow through them, along with their links. |
| offset_links | Offset links to the right of their direction, like traffic, keeping their ends at their nodes. |
| overlapping_links | Pairs of flow and observation link ids that overlap over more than min_length, as an array of shape (2, n). |
| place_bergend_nodes | Place each bergend Basin distance from its doorgaand Basin, and its connector halfway. |
| resolve_overlaps | Offset links that still overlap other links further to their right, see offset_links. |
| separate_nodes | Move nodes that are within min_distance of another node, such that no nodes are on top of each other. |
| tidy_layout | Make the layout of a model readable: no nodes on top of each other, and no overlapping links. |
coincident_nodes
layout.coincident_nodes(model, distance)Pairs of node ids that are within distance of each other, as an array of shape (2, n).
move_nodes
layout.move_nodes(model, locations)Move nodes, and the ends of their links along.
offset_junctions
layout.offset_junctions(model, distance=5.0, junction_ids=None)Offset the Junctions to the right of the direction of the flow through them, along with their links.
The Junctions of the inflows and outflows of a Basin then no longer coincide. Only junction_ids are offset if given, else all Junctions.
offset_links
layout.offset_links(model, distance=5.0, link_ids=None, bend=False)Offset links to the right of their direction, like traffic, keeping their ends at their nodes.
Links that share a route in opposite directions, such as the inflows and outflows of a Basin, then no longer overlap, while links that share a route in the same direction stay together. With bend, straight links get a point halfway that is offset as well.
overlapping_links
layout.overlapping_links(model, min_length)Pairs of flow and observation link ids that overlap over more than min_length, as an array of shape (2, n).
place_bergend_nodes
layout.place_bergend_nodes(model, distance=100.0, directions=16)Place each bergend Basin distance from its doorgaand Basin, and its connector halfway.
The direction is the one with the most room to other links and nodes, within the area of the doorgaand Basin. If no direction fits at distance, half that distance is tried, and so on, and finally also directions outside the area.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| model | Model | Ribasim model, with meta_categorie “bergend” for the bergend Basins | required |
| distance | float | distance between the bergend and the doorgaand Basin | 100.0 |
| directions | int | number of directions to try | 16 |
resolve_overlaps
layout.resolve_overlaps(model, distance=5.0, min_length=1.0, max_iterations=5)Offset links that still overlap other links further to their right, see offset_links.
These are for instance the links of neighboring Basins along a shared waterway.
separate_nodes
layout.separate_nodes(model, min_distance=10.0)Move nodes that are within min_distance of another node, such that no nodes are on top of each other.
Of two such nodes, the most movable one is moved, see MOVABLE_NODE_TYPES; Basins are never moved. It is moved to the first free location around the other node, starting in the direction away from it.
tidy_layout
layout.tidy_layout(
model,
*,
offset=5.0,
min_distance=10.0,
bergend_distance=100.0,
)Make the layout of a model readable: no nodes on top of each other, and no overlapping links.
See place_bergend_nodes, offset_links, offset_junctions, separate_nodes and resolve_overlaps.