gsflow.builder.flow_accumulation Module

class gsflow.builder.flow_accumulation.FlowAccumulation(data, xcenters, ycenters, acc_type='d8', hru_type=None, closed_basin=False, flow_dir_array=None, verbose=False)[source]

Class to perform flow accumulation on a DEM (raster) or resampled to a model grid

Parameters
datanp.ndarray

two dimensional numpy array of dem data

xcentersnp.ndarray

a two dimensional array of x coordinate cell centers

ycentersnp.ndarray

two dimensional array of y coordinate cell centers

acc_typestr

flow accumulation type, currently supported options are “d8”

hru_typenp.array

optional numpy array of hru type numbers that can be used as a masking array to exclude lakes, swales, etc… 0 == inactive 1 == land (included in flow accumulation) 2 == lake (excluded from flow accumulation) 3 == swale (excluded from flow accumulation)

closed_basinbool

method to indicate that basin is closed without considering lake flow. If true hru_type 2 is used in the flow direction calculations. False ignores hru_type 2.

flow_dir_arraynp.ndarray

previously calculated flow direction array of dimension nrow, ncol that can be supplied to FlowAccumulation

verbosebool

flag to print verbose output

Attributes
get_vectors

Method to get flow vectors array

Methods

define_subbasins(self, pour_points, modelgrid)

Method to perform sub-basin delineation on the flow direction array

define_watershed(self, pour_point, modelgrid)

Method to perform watershed delineation on the flow direction array

flow_accumulation(self)

NIDP method to calculate the flow accumulation array using

flow_directions(self[, dijkstra, breach])

Method to get flow directions array

get_cascades(self, streams[, pour_point, …])

Method to calculate cascade parameters for PRMS

get_dem_data(self)

Method to get processed DEM data after flow accumulation

load_cascades(f)

Method to load a saved binary cascades file

load_streams(f)

Method to load a saved binary streams file

make_streams(self, fdir_array, fa_array, …)

Method to make streams for both PRMS and MODFLOW SFR

get_hru_type

define_subbasins(self, pour_points, modelgrid, fmt='rowcol')[source]

Method to perform sub-basin delineation on the flow direction array

Parameters
pour_pointsstr, tuple

pour point can be supplied as either a shapefile, a list with an [(x, y)] tuple of coordinates, or as the model zero based [(row, column)] location.

modelgridflopy.discretization.StructuredGrid

structured grid instance from flopy

fmtstr

format of the pour point information. Acceptable types include “xy”, “rowcol”, and “shp”

Returns
np.ndarraydelinated array of the watershed (1 is active,
0 is inactive)
define_watershed(self, pour_point, modelgrid, fmt='rowcol')[source]

Method to perform watershed delineation on the flow direction array

Parameters
pour_pointstr, tuple

pour point can be supplied as either a shapefile, a list with an [(x, y)] tuple of coordinates, or as the model zero based [(row, column)] location.

modelgridflopy.discretization.StructuredGrid

structured grid instance from flopy

fmtstr

format of the pour point information. Acceptable types include “xy”, “rowcol”, and “shp”

Returns
np.ndarraydelinated array of the watershed (1 is active,
0 is inactive)
flow_accumulation(self)[source]

NIDP method to calculate the flow accumulation array using

Returns
np.ndarray of flow directions
flow_directions(self, dijkstra=False, breach=0.0)[source]

Method to get flow directions array

Parameters
dijkstrabool

method to use a modified dijkstra algorithmn to solve tricky flat areas. Default is False and uses a distance based topology method to solve flat areas.

breachfloat

absolute value of breaching tolerance for digital dams. Use caution while applying breaching values. These should be small numbers.

Returns
np.ndarray of flow directions
get_cascades(self, streams, pour_point=None, modelgrid=None, fmt='rowcol')[source]

Method to calculate cascade parameters for PRMS

Parameters
streams_StreamsObj

Stream information object returned from the FlowAccumulation.make_streams method

pour_pointlist, str

optional, but required if watershed deliniation has not been run prior to running get_cascades. pour point can be supplied as either a shapefile, a list with an [(x, y)] tuple of coordinates, or as the model zero based [(row, column)] location.

modelgridflopy.discretization.StructuredGrid
fmtstr

format of the pour point information. Acceptable types include “xy”, “rowcol”, and “shp”

Returns
_Cascades object
get_dem_data(self)[source]

Method to get processed DEM data after flow accumulation

Returns
np.ndarray
property get_vectors

Method to get flow vectors array

Returns
(u, v): tuple (np.ndarray of flow vectors)
static load_cascades(f)[source]

Method to load a saved binary cascades file

Parameters
fstr

file name

Returns
_Cascades
static load_streams(f)[source]

Method to load a saved binary streams file

Parameters
fstr

file name

Returns
_StreamsObj
make_streams(self, fdir_array, fa_array, threshold, min_stream_len=None, max_reach=None, default_slope=0.001, min_slope=0.0001, max_slope=1.0)[source]

Method to make streams for both PRMS and MODFLOW SFR

Parameters
fdir_arraynp.ndarray

flow direction array

fa_arraynp.ndarray

flow accumulation array

thresholdfloat

accumulated area threshold for defining streams

min_stream_lenint

optional minimum stream length in number of cells

max_reachint

optional maximum number of reach cells per segment

default_slopefloat

default slope value for setting SFR slope of all cells

min_slopefloat

minimum slope calculated by make streams for SFR

max_slopefloat

maximum SFR slope calculated by make streams

Returns
_StreamsObjobject containing SFR and PRMS stream information