HackCalculator: Calculate Hack’s law coefficients#

Calculate Hack parameters.

class HackCalculator(*args, **kwds)[source]#

Bases: Component

This component calculates Hack’s law parameters for drainage basins.

Hacks law is given as

..:math:

L = C * A**h

Where \(L\) is the distance to the drainage divide along the channel, \(A\) is the drainage area, and \(C\) are parameters.

The HackCalculator uses a ChannelProfiler to determine the nodes on which to calculate the parameter fit.

Examples

>>> import pandas as pd
>>> pd.set_option('display.max_columns', None)
>>> import numpy as np
>>> from landlab import RasterModelGrid
>>> from landlab.components import (
...     FlowAccumulator,
...     FastscapeEroder,
...     HackCalculator)
>>> np.random.seed(42)
>>> mg = RasterModelGrid((50, 100), xy_spacing=100)
>>> z = mg.add_zeros('node', 'topographic__elevation')
>>> z[mg.core_nodes] += np.random.randn(mg.core_nodes.size)
>>> fa = FlowAccumulator(mg)
>>> fs = FastscapeEroder(mg, K_sp=0.001)
>>> for i in range(100):
...     fa.run_one_step()
...     fs.run_one_step(1000)
...     z[mg.core_nodes] += 0.01 * 1000
>>> hc = HackCalculator(mg)
>>> hc.calculate_hack_parameters()
>>> largest_outlet = mg.boundary_nodes[
...     np.argsort(mg.at_node['drainage_area'][mg.boundary_nodes])[-1:]][0]
>>> largest_outlet
4978
>>> hc.hack_coefficient_dataframe.loc[largest_outlet, "A_max"]
2830000.0
>>> hc.hack_coefficient_dataframe.round(2)  
                     A_max     C     h
basin_outlet_id
4978             2830000.0  0.31  0.62
>>> hc = HackCalculator(
...     mg,
...     number_of_watersheds=3,
...     main_channel_only=False,
...     save_full_df=True)
>>> hc.calculate_hack_parameters()
>>> hc.hack_coefficient_dataframe.round(2)  
                     A_max     C     h
basin_outlet_id
39               2170000.0  0.13  0.69
4929             2350000.0  0.13  0.68
4978             2830000.0  0.23  0.64
>>> hc.full_hack_dataframe.head().round(2) 
        basin_outlet_id          A   L_obs    L_est
node_id
39                 39.0  2170000.0  3200.0  2903.43
139                39.0  2170000.0  3100.0  2903.43
238                39.0    10000.0     0.0    71.61
239                39.0  2160000.0  3000.0  2894.22
240                39.0    10000.0     0.0    71.61

References

Required Software Citation(s) Specific to this Component

None Listed

Additional References

Hack, J. T. Studies of longitudinal stream profiles in Virginia and Maryland (Vol. 294). U.S. Geological Survey Professional Paper 294-B (1957). https://doi.org/10.3133/pp294B

Parameters
  • grid (Landlab Model Grid instance, required) –

  • save_full_df (bool) – Flag indicating whether to create the full_hack_dataframe.

  • **kwds – Values to pass to the ChannelProfiler.

__init__(grid, save_full_df=False, **kwds)[source]#
Parameters
  • grid (Landlab Model Grid instance, required) –

  • save_full_df (bool) – Flag indicating whether to create the full_hack_dataframe.

  • **kwds – Values to pass to the ChannelProfiler.

calculate_hack_parameters()[source]#

Calculate Hack parameters for desired watersheds.

property full_hack_dataframe#

Full Hack calculation dataframe.

This dataframe is optionally created and stored on the component when the keyword argument full_hack_dataframe=True is passed to the component init.

It is pandas dataframe with a row for every model grid cell used to estimate the Hack parameters. It has the following index and columns.

  • Index
    • node_id*: The node ID of the model grid cell.

  • Columns
    • basin_outlet_id: The node IDs of watershed outlet

    • A: The drainage are of the model grid cell.

    • L_obs: The observed distance to the divide.

    • L_est: The predicted distance to divide based on the Hack coefficient fit.

property hack_coefficient_dataframe#

Hack coefficient dataframe.

This dataframe is created and stored on the component.

It is a pandas dataframe with one row for each basin for which Hack parameters are calculated. Thus, there are as many rows as the number of watersheds identified by the ChannelProfiler.

The dataframe has the following index and columns.

  • Index
    • basin_outlet_id: The node ID of the watershed outlet where each set of Hack parameters was estimated.

  • Columns
    • A_max: The drainage area of the watershed outlet.

    • C: The Hack coefficient as defined in the equations above.

    • h: The Hack exponent as defined in the equations above.