swn.modflow.SwnModflow.from_swn_flopy#

classmethod SwnModflow.from_swn_flopy(swn, model, ibound_action='freeze', reach_include_fraction=0.2)#

Create a MODFLOW SFR structure from a surface water network.

Parameters:
swnswn.SurfaceWaterNetwork

Instance of a SurfaceWaterNetwork.

modelflopy.modflow.Modflow

Instance of a flopy MODFLOW model with DIS and BAS6 packages.

ibound_actionstr, optional
Action to handle IBOUND:
  • freeze : Freeze IBOUND, but clip streams to fit bounds.

  • modify : Modify IBOUND to fit streams, where possible.

reach_include_fractionfloat or pandas.Series, optional

Fraction of cell size used as a threshold distance to determine if reaches outside the active grid should be included to a cell. Based on the furthest distance of the line and cell geometries. Default 0.2 (e.g. for a 100 m grid cell, this is 20 m).

Returns:
objswn.SwnModflow object

Examples

>>> import flopy
>>> import geopandas
>>> import swn
>>> lines = geopandas.GeoSeries.from_wkt([
...    "LINESTRING (60 100, 60  80)",
...    "LINESTRING (40 130, 60 100)",
...    "LINESTRING (70 130, 60 100)"])
>>> lines.index += 100
>>> n = swn.SurfaceWaterNetwork.from_lines(lines)
>>> m = flopy.modflow.Modflow(version="mf2005")
>>> _ = flopy.modflow.ModflowDis(
...     m, nrow=3, ncol=2, delr=20.0, delc=20.0, xul=30.0, yul=130.0,
...     top=15.0, botm=10.0)
>>> _ = flopy.modflow.ModflowBas(m)
>>> nm = swn.modflow.SwnModflow.from_swn_flopy(n, m)
>>> print(nm)
<SwnModflow: flopy mf2005 'modflowtest'
  7 in reaches (reachID): [1, 2, ..., 6, 7]
  1 stress period with perlen: [1.0] />
>>> print(nm.reaches[["segnum", "i", "j", "iseg", "ireach", "rchlen"]])
         segnum  i  j  iseg  ireach     rchlen
reachID
1           101  0  0     1       1  18.027756
2           101  0  1     1       2   6.009252
3           101  1  1     1       3  12.018504
4           102  0  1     2       1  21.081851
5           102  1  1     2       2  10.540926
6           100  1  1     3       1  10.000000
7           100  2  1     3       2  10.000000