landlab.components.network_sediment_transporter.sediment_pulser_at_links¶
- class SedimentPulserAtLinks[source]¶
Bases:
SedimentPulserBase
Send a pulse of parcels to specific links in a channel network
SedimentPulserAtLinks
is instantiated by specifying theNetworkModelGrid
it will pulse the parcels into and the time(s) when a pulse is allowed to occur. It inherits attributes and functions from theSedimentPulserBase
.SedimentPulserAtLinks
is run (adds parcels toDataRecord
) by calling the instance with a list of links and a list of the number of parcels added to each link.If parcel attributes are constant with time and uniform across the basin, these constant-uniform-attributes can be defined when
SedimentPulserAtLinks
is instantiated. If parcel attributes vary with location and time, the user specifies the varying parcel attributes each time the instance is called with a list for each attribute of length equal to the number of links included in the pulse.Code author: Jeff Keck, Allison Pfeiffer, Shelby Ahrendt (with help from Eric Hutton and Katy Barnhart)
Examples
>>> import numpy as np >>> from landlab import NetworkModelGrid
Create the network model grid the parcels will be added to.
>>> y_of_node = (0, 100, 200, 200, 300, 400, 400, 125) >>> x_of_node = (0, 0, 100, -50, -100, 50, -150, -100) >>> nodes_at_link = ((1, 0), (2, 1), (1, 7), (3, 1), (3, 4), (4, 5), (4, 6)) >>> grid = NetworkModelGrid((y_of_node, x_of_node), nodes_at_link) >>> grid.at_link["channel_width"] = np.full(grid.number_of_links, 1.0) # m >>> grid.at_link["channel_slope"] = np.full(grid.number_of_links, 0.01) # m / m >>> grid.at_link["reach_length"] = np.full(grid.number_of_links, 100.0) # m
Define a function that contains which times a pulse is allowed to occur. This function says a pulse can occur at any time
>>> def time_to_pulse(time): ... return True ...
Instantiate
SedimentPulserAtLinks
>>> make_pulse = SedimentPulserAtLinks(grid, time_to_pulse=time_to_pulse)
Run the instance with inputs for the time, link location and number of parcels. Other attributes will use the default values in the base class
>>> time = 11 >>> links = [2, 6] >>> n_parcels_at_link = [2, 3] >>> parcels = make_pulse( ... time=time, links=links, n_parcels_at_link=n_parcels_at_link ... )
Check the element_id of each parcel
>>> print(parcels.dataset["element_id"].values) [[2] [2] [6] [6] [6]]
Create
SedimentPulserAtLinks
.- Parameters:
grid (ModelGrid) – landlab
ModelGrid
to place sediment parcels on.time_to_pulse (function, optional) – The condition when a pulse occurs using the
_pulse_characteristics
method. If not specified, a pulse occurs whenever the instance is runparcels (landlab DataRecord) – Tracks parcel location and variables.
D50 (float, optional) – Median grain size [m].
D84_D50 (float, optional) – Ratio of 84th percentile grain size to the median grain size.
rho_sediment (float, optional) – Sediment grain density [kg / m^3].
parcel_volume (float) – Parcel volume [m^3]
abrasion_rate (float) – Volumetric abrasion exponent [1 / m]
- __call__(time, links=None, n_parcels_at_link=None, D50=None, D84_D50=None, rho_sediment=None, parcel_volume=None, abrasion_rate=None)[source]¶
specify the time, link(s) and attributes of pulses added to a
NetworkModelGrid
at stochastically determined locations within the link(s).- Parameters:
time (integer or datetime64) – Time that the pulse is occurs.
n_parcels_at_link (list of int) – Number of parcels added to each link listed in links
D50 (list of float, optional) – Median grain size of parcels added to each link listed in links [m].
D84_D50 (list of float, optional) – Ratio of 84th percentile grain size to the median grain size.
rho_sediment (list of float, optional) – Density of grains [kg / m^3].
parcel_volume (list of float, optional) – Volume of each parcel added to link listed in links [m^3].
abrasion_rate (list of float, optional) – Rate that grain size decreases with distance along channel [mm / km?].
- Returns:
DataRecord
containing all information on each individual parcel.- Return type:
parcels
- __init__(grid, time_to_pulse=None, parcels=None, D50=0.05, D84_D50=2.1, rho_sediment=2650.0, parcel_volume=0.5, abrasion_rate=0.0, rng=None)[source]¶
Create
SedimentPulserAtLinks
.- Parameters:
grid (ModelGrid) – landlab
ModelGrid
to place sediment parcels on.time_to_pulse (function, optional) – The condition when a pulse occurs using the
_pulse_characteristics
method. If not specified, a pulse occurs whenever the instance is runparcels (landlab DataRecord) – Tracks parcel location and variables.
D50 (float, optional) – Median grain size [m].
D84_D50 (float, optional) – Ratio of 84th percentile grain size to the median grain size.
rho_sediment (float, optional) – Sediment grain density [kg / m^3].
parcel_volume (float) – Parcel volume [m^3]
abrasion_rate (float) – Volumetric abrasion exponent [1 / m]
- 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 = ()¶
- 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 = ()¶
- name = 'SedimentPulserAtLinks'¶
- optional_var_names = ()¶
- output_var_names = ()¶
- property shape¶
Return the grid shape attached to the component, if defined.
- unit_agnostic = False¶
- units = ()¶
- 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 = ()¶