swn.modflow.SwnModflow.route_reaches#

SwnModflow.route_reaches(start, end, *, allow_indirect=False)#

Return a list of reach identifiers that connect a pair of reaches.

Parameters:
start, endany

Start and end reach identifiers (reachID) used by FloPy.

allow_indirectbool, default False

If True, allow the route to go downstream from start to a confluence, then route upstream to end. Defalut False allows only a direct route along a single direction up or down.

Returns:
list
Raises:
IndexError

If start and/or end reach identifiers are not valid.

ConnecionError

If start and end reach identifiers do not connect.

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)
>>> nm.reaches[["iseg", "ireach", "i", "j", "segnum"]]
         iseg  ireach  i  j  segnum
reachID
1           1       1  0  0     101
2           1       2  0  1     101
3           1       3  1  1     101
4           2       1  0  1     102
5           2       2  1  1     102
6           3       1  1  1     100
7           3       2  2  1     100
>>> sel = nm.route_reaches(1, 7)
>>> sel
[1, 2, 3, 6, 7]
>>> nm.reaches.loc[sel, ["iseg", "ireach", "i", "j", "rchlen"]]
         iseg  ireach  i  j     rchlen
reachID
1           1       1  0  0  18.027756
2           1       2  0  1   6.009252
3           1       3  1  1  12.018504
6           3       1  1  1  10.000000
7           3       2  2  1  10.000000