landlab.components.drainage_density.drainage_density

Landlab component to calculate drainage density.

class DrainageDensity[source]

Bases: Component

Calculate drainage density over a DEM.

Landlab component that implements the distance to channel algorithm of Tucker et al., 2001.

This component requires EITHER a channel__mask array with 1’s where channels exist and 0’s elsewhere, OR a set of coefficients and exponents for a slope-area relationship and a channelization threshold to compare against that relationship.

If an array is provided it MUST be of type np.uint8. See the example below for how to make such an array.

The channel__mask array will be assigned to an at-node field with the name channel__mask. If the channel__mask was originaly created from a passed array, a user can update this array to change the mask.

If the channel__mask is created using an area coefficent, slope coefficient, area exponent, slope exponent, and channelization threshold, the location of the mask will be re-update when calculate_drainage_density is called.

If an area coefficient, \(C_A\), a slope coefficent, \(C_S\), an area exponent, \(m_r\), a slope exponent, \(n_r\), and channelization threshold \(T_C\) are provided, nodes that meet the criteria

\[C_A A^{m_r} C_s S^{n_r} > T_c\]

where \(A\) is the drainage density and \(S\) is the local slope, will be marked as channel nodes.

The calculate_drainage_density function returns drainage density for the model domain. This function calculates the distance from every node to the nearest channel node \(L\) along the flow line of steepest descent (assuming D8 routing if the grid is a RasterModelGrid).

This component stores this distance a field, called: surface_to_channel__minimum_distance. The drainage density is then calculated (after Tucker et al., 2001):

\[D_d = \frac{1}{2\overline{L}}\]

where \(\overline{L}\) is the mean L for the model domain.

Examples

>>> import numpy as np
>>> from landlab import RasterModelGrid
>>> from landlab.components import FlowAccumulator, FastscapeEroder
>>> mg = RasterModelGrid((10, 10))
>>> _ = mg.add_zeros("node", "topographic__elevation")
>>> np.random.seed(50)
>>> noise = np.random.rand(100)
>>> mg.at_node["topographic__elevation"] += noise
>>> mg.at_node["topographic__elevation"].reshape(mg.shape)
array([[0.49460165, 0.2280831 , 0.25547392, 0.39632991, 0.3773151 ,
        0.99657423, 0.4081972 , 0.77189399, 0.76053669, 0.31000935],
       [0.3465412 , 0.35176482, 0.14546686, 0.97266468, 0.90917844,
        0.5599571 , 0.31359075, 0.88820004, 0.67457307, 0.39108745],
       [0.50718412, 0.5241035 , 0.92800093, 0.57137307, 0.66833757,
        0.05225869, 0.3270573 , 0.05640164, 0.17982769, 0.92593317],
       [0.93801522, 0.71409271, 0.73268761, 0.46174768, 0.93132927,
        0.40642024, 0.68320577, 0.64991587, 0.59876518, 0.22203939],
       [0.68235717, 0.8780563 , 0.79671726, 0.43200225, 0.91787822,
        0.78183368, 0.72575028, 0.12485469, 0.91630845, 0.38771099],
       [0.29492955, 0.61673141, 0.46784623, 0.25533891, 0.83899589,
        0.1786192 , 0.22711417, 0.65987645, 0.47911625, 0.07344734],
       [0.13896007, 0.11230718, 0.47778497, 0.54029623, 0.95807105,
        0.58379231, 0.52666409, 0.92226269, 0.91925702, 0.25200886],
       [0.68263261, 0.96427612, 0.22696165, 0.7160172 , 0.79776011,
        0.9367512 , 0.8537225 , 0.42154581, 0.00543987, 0.03486533],
       [0.01390537, 0.58890993, 0.3829931 , 0.11481895, 0.86445401,
        0.82165703, 0.73749168, 0.84034417, 0.4015291 , 0.74862   ],
       [0.55962945, 0.61323757, 0.29810165, 0.60237917, 0.42567684,
        0.53854438, 0.48672986, 0.49989164, 0.91745948, 0.26287702]])
>>> fr = FlowAccumulator(mg, flow_director="D8")
>>> fsc = FastscapeEroder(mg, K_sp=0.01, m_sp=0.5, n_sp=1)
>>> for x in range(100):
...     fr.run_one_step()
...     fsc.run_one_step(dt=10.0)
...     mg.at_node["topographic__elevation"][mg.core_nodes] += 0.01
...
>>> channels = np.array(mg.at_node["drainage_area"] > 5, dtype=np.uint8)
>>> dd = DrainageDensity(mg, channel__mask=channels)
>>> mean_drainage_density = dd.calculate_drainage_density()
>>> np.isclose(mean_drainage_density, 0.3831100571)
True

Alternatively you can pass a set of coefficients to identify the channel mask. Next shows the same example as above, but with these coefficients provided.

>>> mg = RasterModelGrid((10, 10))
>>> _ = mg.add_zeros("node", "topographic__elevation")
>>> np.random.seed(50)
>>> noise = np.random.rand(100)
>>> mg.at_node["topographic__elevation"] += noise
>>> fr = FlowAccumulator(mg, flow_director="D8")
>>> fsc = FastscapeEroder(mg, K_sp=0.01, m_sp=0.5, n_sp=1)
>>> for x in range(100):
...     fr.run_one_step()
...     fsc.run_one_step(dt=10.0)
...     mg.at_node["topographic__elevation"][mg.core_nodes] += 0.01
...
>>> channels = np.array(mg.at_node["drainage_area"] > 5, dtype=np.uint8)
>>> dd = DrainageDensity(
...     mg,
...     area_coefficient=1.0,
...     slope_coefficient=1.0,
...     area_exponent=1.0,
...     slope_exponent=0.0,
...     channelization_threshold=5,
... )
>>> mean_drainage_density = dd.calculate_drainage_density()
>>> np.isclose(mean_drainage_density, 0.3831100571)
True

References

Required Software Citation(s) Specific to this Component

None Listed

Additional References

Tucker, G., Catani, F., Rinaldo, A., Bras, R. (2001). Statistical analysis of drainage density from digital terrain data. Geomorphology 36(3-4), 187-202. https://dx.doi.org/10.1016/s0169-555x(00)00056-8

Initialize the DrainageDensity component.

Parameters:
  • grid (ModelGrid)

  • channel__mask (Array that holds 1's where) – channels exist and 0’s elsewhere

  • area_coefficient (coefficient to multiply drainage area by,) – for calculating channelization threshold

  • slope_coefficient (coefficient to multiply slope by,) – for calculating channelization threshold

  • area_exponent (exponent to raise drainage area to,) – for calculating channelization threshold

  • slope_exponent (exponent to raise slope to,) – for calculating channelization threshold

  • channelization_threshold (threshold value above) – which channels exist

__init__(grid, channel__mask=None, area_coefficient=None, slope_coefficient=None, area_exponent=None, slope_exponent=None, channelization_threshold=None)[source]

Initialize the DrainageDensity component.

Parameters:
  • grid (ModelGrid)

  • channel__mask (Array that holds 1's where) – channels exist and 0’s elsewhere

  • area_coefficient (coefficient to multiply drainage area by,) – for calculating channelization threshold

  • slope_coefficient (coefficient to multiply slope by,) – for calculating channelization threshold

  • area_exponent (exponent to raise drainage area to,) – for calculating channelization threshold

  • slope_exponent (exponent to raise slope to,) – for calculating channelization threshold

  • channelization_threshold (threshold value above) – which channels exist

static __new__(cls, *args, **kwds)
calculate_drainage_density()[source]

Calculate drainage density.

If the channel mask is defined based on slope and area coefficients, it will be update based on the current drainage area and slope fields.

Returns:

landscape_drainage_density – Drainage density over the model domain.

Return type:

float (1/m)

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 = (('area_coefficient', 'Area coefficient to define channels.'), ('area_exponent', 'Area exponent to define channels.'), ('channel__mask', 'Logical map of at which grid nodes channels are present'), ('channelization_threshold', 'Channelization threshold for use with area and slope coefficients and exponents.'), ('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'), ('slope_coefficient', 'Slope coefficient to define channels.'), ('slope_exponent', 'Slope exponent to define channels.'), ('surface_to_channel__minimum_distance', 'Distance from each node to the nearest channel'), ('topographic__steepest_slope', 'The steepest *downhill* slope'))
classmethod from_path(grid, path)

Create a component from an input file.

Parameters:
  • grid (ModelGrid) – A landlab grid.

  • path (str or file_like) – Path to a parameter file, contents of a parameter file, or a file-like object.

Returns:

A newly-created component.

Return type:

Component

property grid

Return the grid attached to the component.

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 = ('flow__link_to_receiver_node', 'flow__receiver_node', 'flow__upstream_node_order', 'topographic__steepest_slope')
name = 'DrainageDensity'
optional_var_names = ('area_coefficient', 'area_exponent', 'channel__mask', 'channelization_threshold', 'slope_coefficient', 'slope_exponent')
output_var_names = ('surface_to_channel__minimum_distance',)
property shape

Return the grid shape attached to the component, if defined.

unit_agnostic = True
units = (('area_coefficient', '-'), ('area_exponent', '-'), ('channel__mask', '-'), ('channelization_threshold', '-'), ('flow__link_to_receiver_node', '-'), ('flow__receiver_node', '-'), ('flow__upstream_node_order', '-'), ('slope_coefficient', '-'), ('slope_exponent', '-'), ('surface_to_channel__minimum_distance', '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.

Parameters:

name (str) – A field name.

Returns:

The location (‘node’, ‘link’, etc.) where a variable is defined.

Return type:

str

var_mapping = (('area_coefficient', 'node'), ('area_exponent', 'node'), ('channel__mask', 'node'), ('channelization_threshold', 'node'), ('flow__link_to_receiver_node', 'node'), ('flow__receiver_node', 'node'), ('flow__upstream_node_order', 'node'), ('slope_coefficient', 'node'), ('slope_exponent', 'node'), ('surface_to_channel__minimum_distance', 'node'), ('topographic__steepest_slope', 'node'))
classmethod var_type(name)

Returns the dtype of a field (float, int, bool, str…).

Parameters:

name (str) – A field name.

Returns:

The dtype of the field.

Return type:

dtype

classmethod var_units(name)

Get the units of a particular field.

Parameters:

name (str) – A field name.

Returns:

Units for the given field.

Return type:

str