landlab.components.sink_fill.fill_sinks¶
Created on Mon Oct 19.
@author: dejh
- class SinkFiller[source]¶
Bases:
Component
This component identifies depressions in a topographic surface, then fills them in in the topography. No attempt is made to conserve sediment mass. User may specify whether the holes should be filled to flat, or with a gradient downwards towards the depression outlet. The gradient can be spatially variable, and is chosen to not reverse any drainage directions at the perimeter of each lake.
The primary method of this class is ‘run_one_step’. ‘fill_pits’ is a synonym.
Constructor assigns a copy of the grid, and calls the initialize method.
Examples
>>> from landlab import RasterModelGrid >>> from landlab.components import FlowAccumulator, SinkFiller >>> import numpy as np >>> lake1 = np.array([34, 35, 36, 44, 45, 46, 54, 55, 56, 65, 74]) >>> lake2 = np.array([78, 87, 88]) >>> guard_nodes = np.array([23, 33, 53, 63, 73, 83]) >>> lake = np.concatenate((lake1, lake2)) >>> mg = RasterModelGrid((10, 10)) >>> z = np.ones(100, dtype=float) >>> z += mg.node_x # add a slope >>> z[guard_nodes] += 0.001 # forces the flow out of a particular node >>> z[lake] = 0.0 >>> field = mg.add_field( ... "topographic__elevation", ... z, ... at="node", ... units="-", ... copy=True, ... ) >>> fr = FlowAccumulator(mg, flow_director="D8") >>> fr.run_one_step() >>> mg.at_node["flow__sink_flag"][mg.core_nodes].sum() 14 >>> hf = SinkFiller(mg, apply_slope=False) >>> hf.run_one_step() >>> np.allclose(mg.at_node["topographic__elevation"][lake1], 4.0) True >>> np.allclose(mg.at_node["topographic__elevation"][lake2], 7.0) True
Now reset and demonstrate the adding of an inclined surface:
>>> field[:] = z >>> hf = SinkFiller(mg, apply_slope=True) >>> hf.run_one_step() >>> hole1 = np.array( ... [ ... 4.00007692, ... 4.00015385, ... 4.00023077, ... 4.00030769, ... 4.00038462, ... 4.00046154, ... 4.00053846, ... 4.00061538, ... 4.00069231, ... 4.00076923, ... 4.00084615, ... ] ... ) >>> hole2 = np.array([7.4, 7.2, 7.6]) >>> np.allclose(mg.at_node["topographic__elevation"][lake1], hole1) True >>> np.allclose(mg.at_node["topographic__elevation"][lake2], hole2) True >>> fr.run_one_step() >>> mg.at_node["flow__sink_flag"][mg.core_nodes].sum() 0
References
Required Software Citation(s) Specific to this Component
None Listed
Additional References
Tucker, G., Lancaster, S., Gasparini, N., Bras, R., Rybarczyk, S. (2001). An object-oriented framework for distributed hydrologic and geomorphic modeling using triangulated irregular networks. Computers & Geosciences 27(8), 959-973. https://dx.doi.org/10.1016/s0098-3004(00)00134-5
- Parameters:
grid (ModelGrid) – A landlab grid.
routing ({'D8', 'D4'} (optional)) – If grid is a raster type, controls whether fill connectivity can occur on diagonals (‘D8’, default), or only orthogonally (‘D4’). Has no effect if grid is not a raster.
apply_slope (bool) – If False (default), leave the top of the filled sink flat. If True, apply the slope fill_slope to the top surface to allow subsequent flow routing. A test is performed to ensure applying this slope will not alter the drainage structure at the edge of the filled region (i.e., that we are not accidentally reversing the flow direction far from the outlet.)
fill_slope (float (m/m)) – The slope added to the top surface of filled pits to allow flow routing across them, if apply_slope.
- __init__(grid, routing='D8', apply_slope=False, fill_slope=1e-05)[source]¶
- Parameters:
grid (ModelGrid) – A landlab grid.
routing ({'D8', 'D4'} (optional)) – If grid is a raster type, controls whether fill connectivity can occur on diagonals (‘D8’, default), or only orthogonally (‘D4’). Has no effect if grid is not a raster.
apply_slope (bool) – If False (default), leave the top of the filled sink flat. If True, apply the slope fill_slope to the top surface to allow subsequent flow routing. A test is performed to ensure applying this slope will not alter the drainage structure at the edge of the filled region (i.e., that we are not accidentally reversing the flow direction far from the outlet.)
fill_slope (float (m/m)) – The slope added to the top surface of filled pits to allow flow routing across them, if apply_slope.
- static __new__(cls, *args, **kwds)¶
- 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 = (('sediment_fill__depth', 'Depth of sediment added at eachnode'), ('topographic__elevation', 'Land surface topographic elevation'))¶
- drainage_directions_change(lake_nodes, old_elevs, new_elevs)[source]¶
True if the drainage structure at lake margin changes, False otherwise.
- fill_pits()[source]¶
This is a synonym for the main method
run_one_step
.
- classmethod from_path(grid, path)¶
Create a component from an input file.
- 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 = ('topographic__elevation',)¶
- name = 'SinkFiller'¶
- optional_var_names = ()¶
- output_var_names = ('sediment_fill__depth', 'topographic__elevation')¶
- run_one_step()[source]¶
This is the main method.
Call it to fill depressions in a starting topography.
- property shape¶
Return the grid shape attached to the component, if defined.
- unit_agnostic = True¶
- units = (('sediment_fill__depth', 'm'), ('topographic__elevation', 'm'))¶
- 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 = (('sediment_fill__depth', 'node'), ('topographic__elevation', 'node'))¶