landlab

SteepnessFinder: Calcuate steepness and concavity indices from gridded topography

class SteepnessFinder(grid, reference_concavity=0.5, min_drainage_area=1000000.0, elev_step=0.0, discretization_length=0.0, **kwds)[source]

Bases: landlab.core.model_component.Component

This component calculates steepness indices, sensu Wobus et al. 2006, for a Landlab landscape. Follows broadly the approach used in GeomorphTools, geomorphtools.org.

Construction:

SteepnessFinder(grid, reference_concavity=0.5, min_drainage_area=1.e6,
                elev_step=0., discretization_length=0.)
Parameters:

grid : RasterModelGrid

A landlab RasterModelGrid.

reference_concavity : float

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.

Examples

>>> import numpy as np
>>> from landlab import RasterModelGrid, CLOSED_BOUNDARY
>>> from landlab.components import FlowRouter, FastscapeEroder
>>> mg = RasterModelGrid((3, 10), (100., 100.))
>>> for nodes in (mg.nodes_at_right_edge, mg.nodes_at_bottom_edge,
...               mg.nodes_at_top_edge):
...     mg.status_at_node[nodes] = CLOSED_BOUNDARY
>>> _ = mg.add_zeros('node', 'topographic__elevation')
>>> mg.at_node['topographic__elevation'][mg.core_nodes] = mg.node_x[
...     mg.core_nodes]/1000.
>>> fr = FlowRouter(mg)
>>> sp = FastscapeEroder(mg, K_sp=0.01)
>>> sf = SteepnessFinder(mg, min_drainage_area=10000.)
>>> for i in range(10):
...     mg.at_node['topographic__elevation'][mg.core_nodes] += 10.
...     _ = fr.route_flow()
...     sp.run_one_step(1000.)
>>> 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], dtype=bool)
>>> sf.calculate_steepnesses(discretization_length=350.)
>>> 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.calculate_steepnesses(elev_step=1.5)
>>> 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.        ])
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 : array of floats

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.

Examples

>>> import numpy as np
>>> from landlab import RasterModelGrid, CLOSED_BOUNDARY
>>> from landlab.components import FlowRouter
>>> mg = RasterModelGrid((3,10), (5., 10.))
>>> for nodes in (mg.nodes_at_right_edge, mg.nodes_at_bottom_edge,
...               mg.nodes_at_top_edge):
...     mg.status_at_node[nodes] = CLOSED_BOUNDARY
>>> _ = mg.add_field('node', 'topographic__elevation', mg.node_x)
>>> fr = FlowRouter(mg)
>>> sf = SteepnessFinder(mg)
>>> _ = fr.route_flow()
>>> 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.)
>>> 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.)
>>> 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.)
>>> np.allclose(ch_ksn_overdiscretized, ksn_10)
True
calculate_steepnesses(**kwds)[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 : array of floats

Distances downstream from top node of ch_nodes.

Examples

>>> import numpy as np
>>> from landlab import RasterModelGrid, CLOSED_BOUNDARY
>>> from landlab.components import FlowRouter
>>> mg = RasterModelGrid((4,5), (5., 10.))
>>> for nodes in (mg.nodes_at_right_edge, mg.nodes_at_bottom_edge,
...               mg.nodes_at_top_edge):
...     mg.status_at_node[nodes] = CLOSED_BOUNDARY
>>> mg.status_at_node[[6, 12, 13, 14]] = CLOSED_BOUNDARY
>>> _ = mg.add_field('node', 'topographic__elevation', mg.node_x)
>>> fr = FlowRouter(mg)
>>> sf = SteepnessFinder(mg)
>>> _ = fr.route_flow()
>>> ch_nodes = np.array([8, 7, 11, 10])
>>> sf.channel_distances_downstream(ch_nodes)
array([  0.        ,  10.        ,  21.18033989,  31.18033989])
hillslope_mask

Return a boolean array, False where steepness indices exist.

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 : array of floats

Interpolated slopes at each node in the flowpath (always positive).

Examples

>>> import numpy as np
>>> from landlab import RasterModelGrid, CLOSED_BOUNDARY
>>> from landlab.components import FlowRouter
>>> mg = RasterModelGrid((3,10), (5., 10.))
>>> for nodes in (mg.nodes_at_right_edge, mg.nodes_at_bottom_edge,
...               mg.nodes_at_top_edge):
...     mg.status_at_node[nodes] = CLOSED_BOUNDARY
>>> _ = mg.add_field('node', 'topographic__elevation', mg.node_x**1.1)
>>> fr = FlowRouter(mg)
>>> sf = SteepnessFinder(mg)
>>> _ = fr.route_flow()
>>> ch_nodes = np.arange(18, 9, -1)
>>> ch_dists = sf.channel_distances_downstream(ch_nodes)
>>> interp_pt_elevs = np.array([0., 30., 60., 90., 120.])
>>> 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., 25., 50., 75., 80.])
>>> sf.interpolate_slopes_with_step(ch_nodes, ch_dists,
...                                 interp_pt_elevs)
array([ 1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.])
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, CLOSED_BOUNDARY
>>> from landlab.components import FlowRouter, FastscapeEroder
>>> mg = RasterModelGrid((5, 5), 100.)
>>> for nodes in (mg.nodes_at_right_edge, mg.nodes_at_bottom_edge,
...               mg.nodes_at_top_edge):
...     mg.status_at_node[nodes] = CLOSED_BOUNDARY
>>> _ = mg.add_zeros('node', 'topographic__elevation')
>>> mg.at_node['topographic__elevation'][mg.core_nodes] = mg.node_x[
...     mg.core_nodes]/1000.
>>> np.random.seed(0)
>>> mg.at_node['topographic__elevation'][
...     mg.core_nodes] += np.random.rand(mg.number_of_core_nodes)
>>> fr = FlowRouter(mg)
>>> sp = FastscapeEroder(mg, K_sp=0.01)
>>> cf = SteepnessFinder(mg, min_drainage_area=20000.)
>>> for i in range(10):
...     mg.at_node['topographic__elevation'][mg.core_nodes] += 10.
...     _ = fr.route_flow()
...     sp.run_one_step(1000.)
>>> _ = fr.route_flow()
>>> 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')
steepness_indices

Return the array of channel steepness indices. Nodes not in the channel receive zeros.