landlab.components.flow_director.flow_direction_dinf¶
flow_direction_dinf.py: calculate Dinfinity flow direction on raster grids.
Calculates flow direction and proportion on a raster grid by the Dinfinity algorithm of Tarboton 1997.
KRB Feb 2017
- flow_directions_dinf(grid, elevs='topographic__elevation', baselevel_nodes=None)[source]¶
Find Dinfinity flow directions and proportions on a raster grid.
Finds and returns flow directions and proportions for a given elevation grid by the D infinity method (Tarboton, 1997). Each node is assigned two flow directions, toward the two neighboring nodes that are on the steepest subtriangle. Partitioning of flow is done based on the aspect of the subtriangle.
This method does not support irregular grids.
- Parameters:
grid (ModelGrid) – A grid of type Voroni.
elevs (field name at node or array of length node) – The surface to direct flow across.
baselevel_nodes (array_like, optional) – IDs of open boundary (baselevel) nodes.
- Returns:
receivers (ndarray of size (num nodes, max neighbors at node)) – For each node, the IDs of the nodes that receive its flow. For nodes that do not direct flow to all neighbors, grid.BAD_INDEX is given as a placeholder. The ID of the node itself is given if no other receiver is assigned.
proportions (ndarray of size (num nodes, max neighbors at node)) – For each receiver, the proportion of flow (between 0 and 1) is given. A proportion of zero indicates that the link does not have flow along it.
slopes (ndarray of size (num nodes, max neighbors at node)) – For each node in the array
recievers
, the slope value (positive downhill) in the direction of flow. If no flow occurs (value ofrecievers
is -1), then this array is set to 0.steepest_slope (ndarray) – The slope value (positive downhill) in the direction of flow.
steepest_receiver (ndarray) – For each node, the node ID of the node connected by the steepest link. grid.BAD_INDEX is given if no flow emmanates from the node.
sink (ndarray) – IDs of nodes that are flow sinks (they are their own receivers)
receiver_links (ndarray of size (num nodes, max neighbors at node)) – ID of links that leads from each node to its receiver, or grid.BAD_INDEX if no flow occurs on this link.
steepest_link (ndarray) – For each node, the link ID of the steepest link. grid.BAD_INDEX is given if no flow emmanates from the node.
Examples
>>> from landlab import RasterModelGrid >>> from landlab.components.flow_director.flow_direction_dinf import ( ... flow_directions_dinf, ... )
Dinfinity routes flow based on the relative proportion of flow along the triangular facets around a central raster node.
>>> grid = RasterModelGrid((3, 3), xy_spacing=(1, 1)) >>> _ = grid.add_field( ... "topographic__elevation", ... 2.0 * grid.node_x + grid.node_y, ... at="node", ... ) >>> ( ... receivers, ... proportions, ... slopes, ... steepest_slope, ... steepest_receiver, ... sink, ... receiver_links, ... steepest_link, ... ) = flow_directions_dinf(grid) >>> receivers array([[ 0, -1], [ 0, -1], [ 1, -1], [ 0, -1], [ 3, 0], [ 4, 1], [ 3, -1], [ 6, 3], [ 7, 4]]) >>> proportions array([[ 1. , 0. ], [ 1. , -0. ], [ 1. , -0. ], [ 1. , 0. ], [ 0.40966553, 0.59033447], [ 0.40966553, 0.59033447], [ 1. , 0. ], [ 0.40966553, 0.59033447], [ 0.40966553, 0.59033447]])
This method also works if the elevations are passed as an array instead of the (implied) field name ‘topographic__elevation’.
>>> z = grid["node"]["topographic__elevation"] >>> ( ... receivers, ... proportions, ... slopes, ... steepest_slope, ... steepest_receiver, ... sink, ... receiver_links, ... steepest_link, ... ) = flow_directions_dinf(grid, z) >>> receivers array([[ 0, -1], [ 0, -1], [ 1, -1], [ 0, -1], [ 3, 0], [ 4, 1], [ 3, -1], [ 6, 3], [ 7, 4]]) >>> slopes array([[-1. , -2.12132034], [ 2. , 0.70710678], [ 2. , 0.70710678], [ 1. , -0.70710678], [ 2. , 2.12132034], [ 2. , 2.12132034], [ 1. , -0.70710678], [ 2. , 2.12132034], [ 2. , 2.12132034]]) >>> proportions array([[ 1. , 0. ], [ 1. , -0. ], [ 1. , -0. ], [ 1. , 0. ], [ 0.40966553, 0.59033447], [ 0.40966553, 0.59033447], [ 1. , 0. ], [ 0.40966553, 0.59033447], [ 0.40966553, 0.59033447]])