gsflow.utils.sfr_renumber Module¶
-
class
gsflow.utils.sfr_renumber.
SfrRenumber
(model=None, sfr=None, dis=None, gage=None, lak=None, ag=None, scheme='topology', user_scheme=None)[source]¶ Class method that facilitates SFR package renumbering based on topology trees, discretization elevations, STRTOP elevation, or a user defined scheme. This class can be used to renumber SFR file or it can be used to renumber all SFR associated files in a model ex. SFR, LAK, GAGE, AG…
- Parameters
- model<flopy.modflow.Modflow> object or <gsflow.modflow.Modflow> object
Modflow model object from FloPy or pyGSFLOW
- sfr<flopy.modflow.ModflowSfr1> object
optional and not needed if model is provided
- dis<flopy.modflow.ModflowDis> object
optional and not needed if model is provided
- gage<flopy.modflow.ModflowGage> object
optional and not needed if model is provided
- lak<flopy.modflow.ModflowLak> object
optional and not needed if model is provided
- ag<gsflow.modflow.ModflowAwu> object
optional and not needed if <gsflow.modflow.Modflow> model is provided
- schemestr
renumbering scheme, can be “dis” to renumber by land surface elevation, “sfr” to renumber by stream bed elevation or “user” to renumber by a user supplied scheme.
- user_schemedict
used only if “user” is specified for scheme. Dictionary of {current segment : new segment} numbers example
- {1: 6,
2: 1, 3: 2 ….}
Examples
Renumber a model based on the topology of the SFR network connections (Recommended method)
>>> import gsflow >>> ml = gsflow.modflow.Modflow.load("sagehen.nam") >>> sfr_renumber = SfrRenumber(model=ml) # default scheme="topology" >>> sfr_renumber.renumber_all()
Renumber a model based on the elevation of TOP in the dis file
>>> import gsflow >>> ml = gsflow.modflow.Modflow.load("sagehen.nam") >>> sfr_renumber = SfrRenumber(model=ml, scheme="dis") >>> sfr_renumber.renumber_all()
Renumber a model based on the elevation of STRTOP in the sfr file
>>> import gsflow >>> gsf = gsflow.GsflowModel.load_from_file('gsflow.control') >>> ml = gsf.ml >>> sfr_renumber = SfrRenumber(model=ml, scheme="sfr") >>> sfr_renumber.renumber_all()
or
>>> import gsflow >>> ml = gsflow.modflow.Modflow.load("sagehen.nam") >>> sfr_renumber = SfrRenumber(model=ml, scheme="sfr") >>> sfr_renumber.renumber_all()
Renumber a model using a user defined renumbering scheme
>>> import gsflow >>> ml = gsflow.modflow.Modflow.load("sagehen.nam") >>> # create and apply a segment inversion scheme >>> t = range(50, 0, -1) >>> my_scheme = {ix: i for ix, i in enumerate(t)} >>> sfr_renumber = SfrRenumber(model=ml, scheme="user", user_scheme=my_scheme) >>> # to renumber only SFR package >>> sfr_renumber.renumber_sfr() >>> # to renumber all packages that reference SFR segments >>> sfr_renumber.renumber_all()
- Attributes
all_sfr_segments
Method to get a recarray of all SFR segments within a simulation,
renumbering
Returns a dictionary of the SFR renumbering graph
scheme
Returns the scheme name
Methods
renumber_all
(self)User method to renumber SFR and all SFR related packages attached to a modflow model
renumber_sfr
(self)Method to renumber only the Sfr Package.
-
property
all_sfr_segments
¶ Method to get a recarray of all SFR segments within a simulation, since all segments do not have to be active in a given stress period
- Returns
- ra(np.recarray)
recarray contains a single entry of segment data for each stream segment
-
renumber_all
(self)[source]¶ User method to renumber SFR and all SFR related packages attached to a modflow model
-
renumber_sfr
(self)[source]¶ Method to renumber only the Sfr Package. Using renumber_all() is recommended over this method in most cases
-
property
renumbering
¶ Returns a dictionary of the SFR renumbering graph
-
property
scheme
¶ Returns the scheme name
-
class
gsflow.utils.sfr_renumber.
Topology
(nss=None)[source]¶ A topological sort method that uses a modified Khan algorithm to sort the SFR network
- Parameters
- n_segmentsint
number of sfr segments in network
Methods
add_connection
(self, iseg, ioutseg)Method to add a topological connection
sort
(self)Method to perform a topological sort on the streamflow network