landlab.components.steepness_index.channel_steepness¶
Created on Mon Oct 19.
@author: dejh
- class SteepnessFinder[source]¶
Bases:
Component
This component calculates steepness indices, sensu Wobus et al. 2006, for a Landlab landscape. Follows broadly the approach used in GeomorphTools, geomorphtools.org.
Examples
>>> import numpy as np >>> from landlab import RasterModelGrid >>> from landlab.components import FlowAccumulator, FastscapeEroder >>> from landlab.components import SteepnessFinder >>> mg = RasterModelGrid((3, 10), xy_spacing=100.0) >>> for nodes in ( ... mg.nodes_at_right_edge, ... mg.nodes_at_bottom_edge, ... mg.nodes_at_top_edge, ... ): ... mg.status_at_node[nodes] = mg.BC_NODE_IS_CLOSED >>> _ = mg.add_zeros("topographic__elevation", at="node") >>> mg.at_node["topographic__elevation"][mg.core_nodes] = ( ... mg.node_x[mg.core_nodes] / 1000.0 ... ) >>> fr = FlowAccumulator(mg, flow_director="D8") >>> sp = FastscapeEroder(mg, K_sp=0.01) >>> sf = SteepnessFinder(mg, min_drainage_area=10000.0) >>> for i in range(10): ... mg.at_node["topographic__elevation"][mg.core_nodes] += 10.0 ... _ = fr.run_one_step() ... sp.run_one_step(1000.0) ... >>> sf.calculate_steepnesses() >>> mg.at_node["channel__steepness_index"].reshape((3, 10))[1, :] array([ 0. , 29.28427125, 1. , 1. , 1. , 1. , 1. , 1. , 0.99999997, 0. ]) >>> sf.hillslope_mask array([ True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True])
>>> sf = SteepnessFinder(mg, min_drainage_area=10000.0, discretization_length=350.0) >>> sf.calculate_steepnesses() >>> mg.at_node["channel__steepness_index"].reshape((3, 10))[1, :] array([0. , 3.08232295, 3.08232295, 3.08232295, 1. , 1. , 1. , 1. , 0. , 0. ])
>>> sf = SteepnessFinder(mg, min_drainage_area=10000.0, elev_step=1.5) >>> sf.calculate_steepnesses() >>> mg.at_node["channel__steepness_index"].reshape((3, 10))[1, :] array([0. , 1.22673541, 1.2593727 , 1.27781936, 1.25659369, 1.12393156, 0.97335328, 0.79473963, 0.56196578, 0. ])
References
Required Software Citation(s) Specific to this Component
None Listed
Additional References
Wobus, C. W., Whipple, K. X., Kirby, E., Snyder, N. P., Johnson, J., Spyropolou, K., Crosby, B. T., and Sheenan, D.: Tectonics from topography: Procedures, promise, and pitfalls, in: Tectonics, Climate, and Landscape Evolution, edited by: Willett, S. D., Hovius, N., Brandon, M. T., and Fisher, D., Geological Society of America Special Paper 398, Geological Society of America, Boulder, CO, USA, 55–74, 2006.
- Parameters:
grid (RasterModelGrid) – A landlab RasterModelGrid.
reference_concavity (float (default 0.5)) – The reference concavity to use in the calculation.
min_drainage_area (float (m**2; default 1.e6)) – The minimum drainage area above which steepness indices are calculated. Defaults to 1.e6 m**2, per Wobus et al. 2006.
elev_step (float (m; default 0.)) – If >0., becomes a vertical elevation change step to use to discretize the data (per Wobus). If 0., all nodes are used and no discretization happens.
discretization_length (float (m; default 0.)) – If >0., becomes the lengthscale over which to segment the profiles - i.e., one different steepness index value is calculated every discretization_length. If only one (or no) points are present in a segment, it will be lumped together with the next segment. If zero, one value is assigned to each channel node.
- __init__(grid, reference_concavity=0.5, min_drainage_area=1000000.0, elev_step=0.0, discretization_length=0.0)[source]¶
- Parameters:
grid (RasterModelGrid) – A landlab RasterModelGrid.
reference_concavity (float (default 0.5)) – The reference concavity to use in the calculation.
min_drainage_area (float (m**2; default 1.e6)) – The minimum drainage area above which steepness indices are calculated. Defaults to 1.e6 m**2, per Wobus et al. 2006.
elev_step (float (m; default 0.)) – If >0., becomes a vertical elevation change step to use to discretize the data (per Wobus). If 0., all nodes are used and no discretization happens.
discretization_length (float (m; default 0.)) – If >0., becomes the lengthscale over which to segment the profiles - i.e., one different steepness index value is calculated every discretization_length. If only one (or no) points are present in a segment, it will be lumped together with the next segment. If zero, one value is assigned to each channel node.
- static __new__(cls, *args, **kwds)¶
- calc_ksn_discretized(ch_dists, ch_A, ch_S, ref_theta, discretization_length)[source]¶
Calculate normalized steepness index on defined channel segments.
Every segment must have at least 2 nodes along it. If not, segments will be automatically merged to achieve this. The channel will be segmented starting at the downstream end.
NB: The final node in the channel does not receive an index, as it either belongs to a longer, existing flow path, or it is a boundary node with S = 0. Neither works.
- Parameters:
ch_dists (array of floats) – Distances downstream from top node of a single stream path.
ch_A (array of floats) – Drainage areas at each node in the flowpath.
ch_S (array of floats) – Slope at each node in the flowpath (defined as positive).
ref_theta (float) – The reference concavity; must be positive.
discretization_length (float (m)) – The streamwise length of each segment.
- Returns:
ch_ksn – The normalized steepness index at each node in the flowpath, EXCEPT THE LAST. (i.e., length is (ch_dists.size - 1)). Values will be the same within each defined segment.
- Return type:
array of floats
Examples
>>> import numpy as np >>> from landlab import RasterModelGrid >>> from landlab.components import FlowAccumulator >>> from landlab.components import SteepnessFinder >>> mg = RasterModelGrid((3, 10), xy_spacing=(10.0, 5.0)) >>> for nodes in ( ... mg.nodes_at_right_edge, ... mg.nodes_at_bottom_edge, ... mg.nodes_at_top_edge, ... ): ... mg.status_at_node[nodes] = mg.BC_NODE_IS_CLOSED >>> _ = mg.add_field("topographic__elevation", mg.node_x, at="node") >>> fr = FlowAccumulator(mg, flow_director="D8") >>> sf = SteepnessFinder(mg) >>> _ = fr.run_one_step() >>> ch_nodes = np.arange(18, 9, -1) >>> ch_dists = sf.channel_distances_downstream(ch_nodes) >>> ch_A = mg.at_node["drainage_area"][ch_nodes] >>> ch_S = mg.at_node["topographic__steepest_slope"][ch_nodes]
>>> ksn_25 = sf.calc_ksn_discretized(ch_dists, ch_A, ch_S, 0.5, 25.0) >>> ksn_25.size == ch_dists.size - 1 True >>> ksn_25 array([-1. , 11.0668192 , 11.0668192 , 15.70417802, 15.70417802, 15.70417802, 19.3433642 , 19.3433642 ])
>>> ksn_10 = sf.calc_ksn_discretized(ch_dists, ch_A, ch_S, 0.5, 10.0) >>> ksn_10 array([ 8.40896415, 8.40896415, 13.16074013, 13.16074013, 16.5487546 , 16.5487546 , 19.3433642 , 19.3433642 ])
>>> ch_ksn_overdiscretized = sf.calc_ksn_discretized( ... ch_dists, ch_A, ch_S, 0.5, 10.0 ... ) >>> np.allclose(ch_ksn_overdiscretized, ksn_10) True
- calculate_steepnesses()[source]¶
This is the main method. Call it to calculate local steepness indices at all points with drainage areas greater than min_drainage_area.
This “run” method can optionally take the same parameter set as provided at instantiation. If they are provided, they will override the existing values from instantiation.
Normalized steepness of any node without a defined value is reported as 0. These nodes are also identified in the mask retrieved with
hillslope_mask
.
- channel_distances_downstream(ch_nodes)[source]¶
Calculates distances downstream from top node of a defined flowpath.
- Parameters:
ch_nodes (array of ints) – The nodes along a single defined flow path, starting upstream.
- Returns:
ch_dists – Distances downstream from top node of ch_nodes.
- Return type:
array of floats
Examples
>>> import numpy as np >>> from landlab import RasterModelGrid >>> from landlab.components import FlowAccumulator >>> mg = RasterModelGrid((4, 5), xy_spacing=(10.0, 5.0)) >>> for nodes in ( ... mg.nodes_at_right_edge, ... mg.nodes_at_bottom_edge, ... mg.nodes_at_top_edge, ... ): ... mg.status_at_node[nodes] = mg.BC_NODE_IS_CLOSED >>> mg.status_at_node[[6, 12, 13, 14]] = mg.BC_NODE_IS_CLOSED >>> _ = mg.add_field("topographic__elevation", mg.node_x, at="node") >>> fr = FlowAccumulator(mg, flow_director="D8") >>> sf = SteepnessFinder(mg) >>> _ = fr.run_one_step() >>> ch_nodes = np.array([8, 7, 11, 10]) >>> sf.channel_distances_downstream(ch_nodes) array([ 0. , 10. , 21.18033989, 31.18033989])
- cite_as = ''¶
- property coords¶
Return the coordinates of nodes on grid attached to the component.
- property current_time¶
Current time.
Some components may keep track of the current time. In this case, the
current_time
attribute is incremented. Otherwise it is set to None.- Return type:
current_time
- definitions = (('channel__steepness_index', 'the local steepness index'), ('drainage_area', "Upstream accumulated surface area contributing to the node's discharge"), ('flow__link_to_receiver_node', 'ID of link downstream of each node, which carries the discharge'), ('flow__receiver_node', 'Node array of receivers (node that receives flow from current node)'), ('flow__upstream_node_order', 'Node array containing downstream-to-upstream ordered list of node IDs'), ('topographic__elevation', 'Land surface topographic elevation'), ('topographic__steepest_slope', 'The steepest *downhill* slope'))¶
- classmethod from_path(grid, path)¶
Create a component from an input file.
- property grid¶
Return the grid attached to the component.
- property hillslope_mask¶
Return a boolean array, False where steepness indices exist.
- initialize_optional_output_fields()¶
Create fields for a component based on its optional field outputs, if declared in _optional_var_names.
This method will create new fields (without overwrite) for any fields output by the component as optional. New fields are initialized to zero. New fields are created as arrays of floats, unless the component also contains the specifying property _var_type.
- initialize_output_fields(values_per_element=None)¶
Create fields for a component based on its input and output var names.
This method will create new fields (without overwrite) for any fields output by, but not supplied to, the component. New fields are initialized to zero. Ignores optional fields. New fields are created as arrays of floats, unless the component specifies the variable type.
- Parameters:
values_per_element (int (optional)) – On occasion, it is necessary to create a field that is of size (n_grid_elements, values_per_element) instead of the default size (n_grid_elements,). Use this keyword argument to acomplish this task.
- input_var_names = ('drainage_area', 'flow__link_to_receiver_node', 'flow__receiver_node', 'flow__upstream_node_order', 'topographic__elevation', 'topographic__steepest_slope')¶
- interpolate_slopes_with_step(ch_nodes, ch_dists, interp_pt_elevs)[source]¶
Maps slopes to nodes, interpolating withing defined vertical intervals.
This follows Geomorphtools’ discretization methods. It is essentially a downwind map of the slopes.
- Parameters:
ch_nodes (array of ints) – The nodes along a single defined flow path, starting upstream.
ch_dists (array of floats) – Distances downstream from top node of ch_nodes.
interp_pt_elevs (array of floats) – Elevations at the discretizing points along the profile, in order of increasing elevation.
- Returns:
ch_S – Interpolated slopes at each node in the flowpath (always positive).
- Return type:
array of floats
Examples
>>> import numpy as np >>> from landlab import RasterModelGrid >>> from landlab.components import FlowAccumulator >>> mg = RasterModelGrid((3, 10), xy_spacing=(10.0, 5.0)) >>> for nodes in ( ... mg.nodes_at_right_edge, ... mg.nodes_at_bottom_edge, ... mg.nodes_at_top_edge, ... ): ... mg.status_at_node[nodes] = mg.BC_NODE_IS_CLOSED >>> _ = mg.add_field("topographic__elevation", mg.node_x**1.1, at="node") >>> fr = FlowAccumulator(mg, flow_director="D8") >>> sf = SteepnessFinder(mg) >>> _ = fr.run_one_step() >>> ch_nodes = np.arange(18, 9, -1) >>> ch_dists = sf.channel_distances_downstream(ch_nodes) >>> interp_pt_elevs = np.array([0.0, 30.0, 60.0, 90.0, 120.0]) >>> sf.interpolate_slopes_with_step(ch_nodes, ch_dists, interp_pt_elevs) array([1.67970205, 1.67970205, 1.67970205, 1.65129294, 1.62115336, 1.5811951 , 1.53157521, 1.44240187, 1.36442227]) >>> mg.at_node["topographic__steepest_slope"][ch_nodes] array([1.69383001, 1.66972677, 1.64200694, 1.60928598, 1.56915472, 1.51678178, 1.43964028, 1.25892541, 0. ]) >>> mg.at_node["topographic__elevation"][:] = mg.node_x >>> interp_pt_elevs = np.array([0.0, 25.0, 50.0, 75.0, 80.0]) >>> sf.interpolate_slopes_with_step(ch_nodes, ch_dists, interp_pt_elevs) array([1., 1., 1., 1., 1., 1., 1., 1., 1.])
- property masked_steepness_indices¶
Returns a masked array version of the ‘channel__steepness_index’ field. This enables easier plotting of the values with.
landlab.imshow_grid_at_node
or similar.Examples
Make a topographic map with an overlay of steepness values:
>>> from landlab import imshow_grid_at_node >>> from landlab import RasterModelGrid >>> from landlab.components import FlowAccumulator, FastscapeEroder >>> from landlab.components import SteepnessFinder >>> mg = RasterModelGrid((5, 5), xy_spacing=100.0) >>> for nodes in ( ... mg.nodes_at_right_edge, ... mg.nodes_at_bottom_edge, ... mg.nodes_at_top_edge, ... ): ... mg.status_at_node[nodes] = mg.BC_NODE_IS_CLOSED >>> _ = mg.add_zeros("topographic__elevation", at="node") >>> mg.at_node["topographic__elevation"][mg.core_nodes] = ( ... mg.node_x[mg.core_nodes] / 1000.0 ... ) >>> np.random.seed(0) >>> mg.at_node["topographic__elevation"][mg.core_nodes] += np.random.rand( ... mg.number_of_core_nodes ... ) >>> fr = FlowAccumulator(mg, flow_director="D8") >>> sp = FastscapeEroder(mg, K_sp=0.01) >>> cf = SteepnessFinder(mg, min_drainage_area=20000.0) >>> for i in range(10): ... mg.at_node["topographic__elevation"][mg.core_nodes] += 10.0 ... _ = fr.run_one_step() ... sp.run_one_step(1000.0) ... >>> _ = fr.run_one_step() >>> cf.calculate_steepnesses()
>>> imshow_grid_at_node(mg, "topographic__elevation", allow_colorbar=False) >>> imshow_grid_at_node( ... mg, cf.masked_steepness_indices, color_for_closed=None, cmap="winter" ... )
- name = 'SteepnessFinder'¶
- optional_var_names = ()¶
- output_var_names = ('channel__steepness_index',)¶
- property shape¶
Return the grid shape attached to the component, if defined.
- property steepness_indices¶
Return the array of channel steepness indices.
Nodes not in the channel receive zeros.
- unit_agnostic = True¶
- units = (('channel__steepness_index', 'variable'), ('drainage_area', 'm**2'), ('flow__link_to_receiver_node', '-'), ('flow__receiver_node', '-'), ('flow__upstream_node_order', '-'), ('topographic__elevation', 'm'), ('topographic__steepest_slope', '-'))¶
- classmethod var_definition(name)¶
Get a description of a particular field.
- Parameters:
name (str) – A field name.
- Returns:
A description of each field.
- Return type:
tuple of (name, *description*)
- classmethod var_help(name)¶
Print a help message for a particular field.
- Parameters:
name (str) – A field name.
- classmethod var_loc(name)¶
Location where a particular variable is defined.
- var_mapping = (('channel__steepness_index', 'node'), ('drainage_area', 'node'), ('flow__link_to_receiver_node', 'node'), ('flow__receiver_node', 'node'), ('flow__upstream_node_order', 'node'), ('topographic__elevation', 'node'), ('topographic__steepest_slope', 'node'))¶