gwsource
Where does the water pumped by a well come from? Where does recharge under a polluted site end up? gwsource answers such questions from the output of a MODFLOW 6 groundwater-flow model. It reads the binary grid file and the cell-by-cell budget file that the model saves. For every cell it then works out what fraction and volume of the cell's water reaches a chosen destination (backward tracing, or capture) and what fraction came from a chosen source (forward tracing, or fate).
The water in each cell is treated as fully mixed. This is the cell-mixing flow-tracing method of Foley & Black (2013) and Black & Foley (2013). gwsource writes the trace as one sparse system of linear equations and solves it for many destinations or sources at once. Flow loops, weak sinks and package networks are therefore handled exactly, and every result is checked against the model's water budget.
What it does
- Backward (capture) and forward (fate) tracing of steady flow, on DIS, DISV and DISU grids.
- Optional strong sinks: chosen packages take all the water of their cells, as particles stop in a strong sink.
- Transient flow: each time step as a snapshot, or true tracking of tagged water through storage, forward and backward in time.
- Eulerian mean travel time and water age.
- Multi-model simulations, exchanges and advanced-package networks (SFR, LAK, MAW, UZF and the water mover).
- Budget-closure and forward/backward duality checks.
- An ensemble driver for many model realisations, and a helper that compares results with MODFLOW 6 particle tracking (PRT).
- Export to npz, netCDF, GeoPackage and CSV.
Installation
pip install gwsource
Optional extras: gwsource[export] for netCDF and GeoPackage export, and gwsource[notebooks] for the tutorial tools. To build and run MODFLOW 6 models you also need the mf6 executable, for example from FloPy's get-modflow :flopy.
The tests and tutorials use a development environment with FloPy from its develop branch and the MODFLOW 6 nightly build. CONTRIBUTING.md explains how to set it up.
Quick example
import gwsource as gs
step = gs.read_step("model_ws", boundnames=True) # one time step of a GWF model
well = gs.select(step, boundnames=["supply_well"]) # the destination: a well
res = gs.backward(step, {"supply_well": well})
capture = res.fraction_through["supply_well"] # per cell: share of its water that reaches the well
gs.export.to_netcdf("supply_well.nc", step, res)
Documentation and tutorials
The documentation, with the API reference and the tutorials, is at https://rhugman.github.io/gw-source/. The tutorials are Jupyter notebooks in tutorials/. They go from a first capture zone to transient tracking and parameter ensembles. Each builds its own small MODFLOW 6 model.
Citing
If you use gwsource, please cite it. The citation details are in CITATION.cff, and GitHub's "Cite this repository" button formats them. Please also cite the method:
- Foley, C., and Black, A. (2013). Efficiently delineating volumetric capture areas and flow pathways using directed acyclic graphs and MODFLOW. In Proceedings of MODFLOW and More 2013: Translating Science into Practice, Golden, Colorado, 571–581.
Contributing
Bug reports, questions and pull requests are welcome. See CONTRIBUTING.md.
Licence
MIT; see LICENSE.
Metadata
Release files for gwsource 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gwsource-0.1.0.tar.gz | 177.9 kB | With provenance | Details for gwsource-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gwsource-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for gwsource-0.1.0-py3-none-any.whl |
Total release size: 299.7 kB
Release files / gwsource-0.1.0.tar.gz
| Download URL | gwsource-0.1.0.tar.gz |
|---|---|
| Size | 177.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b59e221d78c043422be180c013a195e640190b35e423e59d6122ca469dc9bd02
|
|
BLAKE2b-256 checksum How to use checksums |
1fd973609c543358aab190e5e50b9fc38c360cb90dcf9369f055d9dfc5384be8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logRelease files / gwsource-0.1.0-py3-none-any.whl
| Download URL | gwsource-0.1.0-py3-none-any.whl |
|---|---|
| Size | 121.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f583fa17a8ec148f933b85ca576e0bd4f58f77f52a36b7f4fda9ff00753f33eb
|
|
BLAKE2b-256 checksum How to use checksums |
505d3ae353b43779f63662731f55024de22b25843f517d6328b347904067ef6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logSecurity for gwsource 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for gwsource-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.