Skip to main content

BasinForge

Lumped hydrological simulation, calibration and sensitivity analysis for single and multiple catchments.

Python tests Documentation PyPI

Documentation · Quick start · Case study · Release 0.2.0

Observed flow and calibrated GR4J simulations from the LuMod example 2 case study

First validation year for LuMod example 2: observed flow and fits from differential evolution, Latin-hypercube search and multi-start calibration. Explore the case study.

Features

  • 14 Python model implementations and 47 optional MARRMoT structures.
  • Single-basin, parallel multi-basin and shared-parameter calibration.
  • Differential evolution, Latin-hypercube search and multi-start fitting.
  • Chronological calibration and validation with NSE, KGE, RMSE and log NSE.
  • Morris and Sobol sensitivity analysis.
  • Saved parameters, simulations, hydrographs and HTML reports.
  • Daily surface/groundwater withdrawals, delayed returns and priority/LP allocation.
Time step Python models
Daily GR3J, GR4J, GR5J, GR6J, HYMOD, HYMOD_CLASSIC, HBV, MILC, XAJ, XAJ_MZ, SMART
Monthly GR2M, ABCD
Annual GR1A

The 47 optional daily MARRMoT structures require Octave and its optim package. See the model reference for equations, parameters and implementation details.

Install

Requires Python 3.11 or later. Install the 0.2.0 release with pip:

python -m pip install basinforge-hydro==0.2.0
basinforge doctor

For an editable installation:

git clone https://github.com/Barbhuiya12/basinforge-hydro.git
cd basinforge-hydro
python -m pip install -e .

The native water-use module includes equations, single/connected-basin accounting and calibration examples.

Try the example data

From the checkout above, run the three-catchment LuMod case study:

python -m pip install -e '.[reference]'
python examples/lumod_case_study.py --output lumod-case-study

This creates fitted parameters, simulations, hydrographs, sensitivity plots and reports for every supported calibration search. Choose a new output directory.

Quick start

Calibrate GR4J, analyze parameter sensitivity and export a hydrograph report in one call:

from basinforge import Basin, CalibrationConfig, run_experiment

basin = Basin.from_csv(
    "basin.csv",
    basin_id="A",
    area_km2=1200,
    q_unit="m3/s",
    timestep="daily",
)

study = run_experiment(
    basin,
    "GR4J",
    CalibrationConfig(warmup=365, calibration_fraction=0.7, seed=42),
    sensitivity="morris",
    output="study-A",
)

print(study["fit"].parameters)
print(study["fit"].validation_metrics)

Your results are saved together:

study-A/
├── fit/
│   ├── fit.json
│   └── simulation.csv
├── report/
│   ├── index.html
│   ├── diagnostics.png
│   └── summary.json
└── sensitivity.json

Open study-A/report/index.html to inspect the hydrograph, flow-duration curve and calibration/validation scores.

Supply your own CSV and catchment area. Use date, precipitation, pet, qobs columns; temperature-dependent models also need temperature. Precipitation and PET are mm per model step. Set the observed discharge unit explicitly and choose a warmup appropriate to the model's time step. Output directories must be new.

The same workflow is available from the command line:

basinforge experiment basin.csv --area 1200 --q-unit m3/s \
  --model GR4J --warmup 365 --calibration-fraction 0.7 \
  --sensitivity morris --output study-A

See the input guide, calibration guide and multi-basin guide for other workflows.

LuMod case study

The case study compares all supported calibration searches on three LuMod example catchments. It includes calibration and validation scores, observed and simulated hydrographs, Morris/Sobol sensitivity plots, and downloadable parameters and simulations.

License and credits

BasinForge is distributed under GPL-3.0-only. It incorporates scientific implementations from LuMod, hydromodel, SMARTpy and MARRMoT with retained licenses and attribution. See third-party credits for sources and model citations.

Metadata

Release files for basinforge-hydro 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for basinforge-hydro 0.2.0
File Size Uploaded
basinforge_hydro-0.2.0.tar.gz 5.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for basinforge-hydro 0.2.0
File Interpreter ABI Platform
basinforge_hydro-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.7 MB

Release files / basinforge_hydro-0.2.0.tar.gz

Download URL basinforge_hydro-0.2.0.tar.gz
Size 5.3 MB
Tags Source
SHA-256 checksum
How to use checksums
c8fa7e455cedea56b6c38a3f2877d50b7c7338d698c5c519d81870b407973f70
BLAKE2b-256 checksum
How to use checksums
109c9a82e4e1b4e4a098d4fe3b08b7d59e2425ad03f3285a4f405f2006e2a672
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 2, 2026.

Transparency log

Release files / basinforge_hydro-0.2.0-py3-none-any.whl

Download URL basinforge_hydro-0.2.0-py3-none-any.whl
Size 363.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf6e6abd8fbb269f61d3fdda2090cd93bfbd42ba6ab18489d1c7fed02391b3b5
BLAKE2b-256 checksum
How to use checksums
c5959fe4c8f5bdf22c809cfb62320bccc939b2f0f7067d8cfa14faf5b960cbcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 2, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page