landlab.components.flow_director.flow_direction_DN¶
flow_direction_DN.py: calculates single-direction flow directions.
Works on both a regular or irregular grid.
GT Nov 2013 Modified Feb 2014
- flow_directions(elev, active_links, tail_node, head_node, link_slope, grid=None, baselevel_nodes=None)[source]¶
Find flow directions on a grid.
Finds and returns flow directions for a given elevation grid. Each node is assigned a single direction, toward one of its N neighboring nodes (or itself, if none of its neighbors are lower).
- Parameters:
elev (array_like) – Elevations at nodes.
active_links (array_like) – IDs of active links.
tail_node (array_like) – IDs of the tail node for each link.
head_node (array_like) – IDs of the head node for each link.
link_slope (array_like) – slope of each link, defined POSITIVE DOWNHILL (i.e., a negative value means the link runs uphill from the fromnode to the tonode).
baselevel_nodes (array_like, optional) – IDs of open boundary (baselevel) nodes.
- Returns:
receiver (ndarray) – For each node, the ID of the node that receives its flow. Defaults to the node itself if no other receiver is assigned.
steepest_slope (ndarray) – The slope value (positive downhill) in the direction of flow
sink (ndarray) – IDs of nodes that are flow sinks (they are their own receivers)
receiver_link (ndarray) – ID of link that leads from each node to its receiver, or BAD_INDEX_VALUE if none.
Examples
The example below assigns elevations to the 10-node example network in Braun and Willett (2012), so that their original flow pattern should be re-created.
>>> import numpy as np >>> from landlab.components.flow_director import flow_directions >>> z = np.array([2.4, 1.0, 2.2, 3.0, 0.0, 1.1, 2.0, 2.3, 3.1, 3.2]) >>> fn = np.array([1, 4, 4, 0, 1, 2, 5, 1, 5, 6, 7, 7, 8, 6, 3, 3, 2, 0]) >>> tn = np.array([4, 5, 7, 1, 2, 5, 6, 5, 7, 7, 8, 9, 9, 8, 8, 6, 3, 3]) >>> s = z[fn] - z[tn] # slope with unit link length, positive downhill >>> active_links = np.arange(len(fn)) >>> r, ss, snk, rl = flow_directions(z, active_links, fn, tn, s) >>> r array([1, 4, 1, 6, 4, 4, 5, 4, 6, 7]) >>> ss array([1.4, 1. , 1.2, 1. , 0. , 1.1, 0.9, 2.3, 1.1, 0.9]) >>> snk array([4]) >>> rl[3:8] array([15, -1, 1, 6, 2])