Theanalysis
API
analysis
API Reference¶
Top-level functions for propagator
.
This contains main functions use propagate and accumlate catchment properties in a larger watershed.
- Geosyntec Consultants, 2015.
Released under the BSD 3-clause license (see LICENSE file for more info)
Written by Paul Hobson (phobson@geosyntec.com)
-
propagator.analysis.
trace_upstream
(*args, **kwargs)¶ Recursively traces an upstream path of subcatchments through a watetershed.
Parameters: subcatchment_array : numpy.recarry
A record array of all of the subcatchments in the watershed. This array must have a “downstrea ID” column in which each subcatchment identifies as single, downstream neighbor.
subcatchment_ID : str
The ID of the downstream catchment from which the trace originates.
id_col : str, optional
The name of the column that specifies the current subcatchment.
ds_col : str, optional
The name of the column that identifies the downstream subcatchment.
downstream : list, optional
A list of already known downstream catchments in the trace.
Warning
This is only used in the recursive calls to this function. You should never provide this value.
Returns: upstream : numpy.recarry
A record array of all of the upstream subcatchments. This will have the same schema as
subcatchment_array
-
propagator.analysis.
find_edges
(*args, **kwargs)¶ Finds the lowest, non-ocean subcatchments in a watershed.
Parameters: subcatchment_array : numpy.recarry
A record array of all of the subcatchments in the watershed. This array must have a “downstrea ID” column in which each subcatchment identifies as single, downstream neighbor.
edge_ID : str, optional
The subcatchment ID of the pseudo-catchments in the Ocean.
ds_col : str, optional
The name of the column that identifies the downstream subcatchment.
Returns: bottoms : numpy.recarry
A record array of all of subcatchments that drain into the ocean.
-
propagator.analysis.
find_tops
(*args, **kwargs)¶ Finds the the subcatchments in a watershed that do not accept any upstrea tributary flow.
Parameters: subcatchment_array : numpy.recarry
A record array of all of the subcatchments in the watershed. This array must have a “downstrea ID” column in which each subcatchment identifies as single, downstream neighbor.
subcatchment_ID : str
The ID of the downstream catchment from which the trace originates.
id_col : str, optional
The name of the column that specifies the current subcatchment.
ds_col : str, optional
The name of the column that identifies the downstream subcatchment.
Returns: top : numpy.recarry
A record array of all of the upper most subcatchments.
-
propagator.analysis.
propagate_scores
(*args, **kwargs)¶ Propagate values into upstream subcatchments through a watershed.
Parameters: subcatchment_array : numpy.recarry
A record array of all of the subcatchments in the watershed. This array must have a “downstrea ID” column in which each subcatchment identifies as single, downstream neighbor.
id_col : str, optional
The name of the column that specifies the current subcatchment.
ds_col : str, optional
The name of the column that identifies the downstream subcatchment.
value_column : str
Name of a representative water quality column that can be used to indicate if the given subcatchment has or has not been populated with water quality data.
ignored_value : float, optional
The values representing unpopulated records in the array of subcatchment and water quality data.
edge_ID : str, optional
The subcatchment ID of the pseudo-catchments in the Ocean.
Returns: propagated : numpy.recarry
A copy of
subcatchment_array
with all of the water quality records populated.
-
propagator.analysis.
mark_edges
(*args, **kwargs)¶ Mark of all of the subcatchments on the edges of the study area (i.e., flow out of the study area). In this case “mark” means that the downstream subcatchment ID is set to a constant value.
Parameters: subcatchment_array : numpy.recarray
Record array of subcatchments with at least
id_col
andds_col
columns.id_col, ds_col : str, optional
Label of the subcatchment ID and downstream subcatchment ID columns, respectively
edge_ID : str, optional
The downstream subcatchment ID that will given to the subcatchments that flow out of the study area.
Returns: array : numpy.recarray
An array with the same schema as
subcatchment_array
, but without the orphans.
-
propagator.analysis.
preprocess_wq
(*args, **kwargs)¶ Preprocess the water quality data to have to averaged score for each subcatchment.
Parameters: monitoring_locations : str
Path to the feature class containing the monitoring locations and their water quality scores.
subcatchments : str
Path to the feature class containing the subcatchment boundaries.
id_col : str, ds_col
Name of the column in
subcatchments
that contains the (ds = downstream) subcatchment IDs.output_path : str
Path of the new feature class where the preprocessed data should be saved.
value_columns : list of str
A list of the names of the fields containing water quality scores that need to be analyzed.
aggfxn : callable, optional
A function, lambda, or class method that reduces arrays into scalar values. By default, this is
numpy.mean
.ignored_value : int, optional
The values in
monitoring_locations
that should be ignored. Given the default input datasets, zero has been chosen to signal that a value is missing.cleanup : bool, optional
Toggles the deletion of temporary files.
Returns: array : numpy.recarray
A numpy record array of the subcatchments with their aggregated water quality scores.
-
propagator.analysis.
prepare_data
(*args, **kwargs)¶ Assigns water quality ranking from monitoring locations to the subcatchments. If multiple monitoring locations are present in one subcatchment, water quality rankings are aggregated prior to assignment.
Parameters: mon_locations : str
File path to the monitoring locations feature class.
subcatchments : str
File path to the subcatchments feature class.
subcatch_id_col : str
Field name of the subcatchment ID column in
subcatchments
.sort_id: str
Arbituary field name for sorting purpose. Default value is ‘FID’
header_fields : list
List of header field names to be retained in the output feature class.
wq_fields : list
List of water quality field names to be analyzed
outputfile : str
Filename where the output should be saved.
Returns: subcatchment_wq : arcpy.Layer
A subcatchment class that inherited water quality rankings from respective monitoring locations.
-
propagator.analysis.
split_streams
(*args, **kwargs)¶