jHBV
Dual-backend (JAX + NumPy) implementation of the HBV-96 rainfall–runoff model — usable standalone or as a SYMFLUENCE plugin.
Part of the SYMFLUENCE JAX-native model family — self-contained packages that run standalone (NumPy fallback, no JAX required) and register automatically with SYMFLUENCE when installed alongside it.
Features
- Differentiable: automatic differentiation through the full simulation (JAX)
- Fast: JIT compilation via
lax.scan;vmapfor ensembles; GPU-capable - Dependency-light: pure-NumPy fallback when JAX is not installed
- Plugin architecture: auto-registers with SYMFLUENCE via entry points
Installation
pip install jhbv # NumPy backend
pip install 'jhbv[jax]' # with JAX (differentiable, JIT)
Quickstart
import numpy as np
from jhbv import simulate
# daily forcing: precipitation (mm/d), temperature (degC), PET (mm/d)
runoff, state = simulate(precip, temp, pet) # default parameters
params = {"FC": 250.0, "BETA": 2.0, "K1": 0.1} # override any subset
runoff, state = simulate(precip, temp, pet, params=params)
# hourly simulation (parameters stay in daily units)
runoff_h, _ = simulate(precip_h, temp_h, pet_h, timestep_hours=1)
Gradient-based calibration
The JAX backend makes the full simulation differentiable end-to-end, so model parameters can be calibrated with gradient descent:
import jax
from jhbv import kge_loss, get_kge_gradient_fn
grad_fn = get_kge_gradient_fn(precip, temp, pet, observed)
value, grads = grad_fn(params) # dKGE/dparam for every parameter
nse_loss / kge_loss and their gradient factories are JIT-compatible and work
with any optax optimizer. Within SYMFLUENCE the same interface powers the
ADAM and L-BFGS calibration options.
Use with SYMFLUENCE
jhbv registers with SYMFLUENCE
through the symfluence.plugins entry point — installation is the integration:
pip install symfluence jhbv
# config.yaml (excerpt)
model:
hydrological_model: HBV
SYMFLUENCE then handles forcing preparation, calibration, evaluation, and benchmarking for the model with no further wiring.
Model structure
HBV-96 (Lindström et al., 1997) consists of four routines, all implemented with smooth, differentiable formulations:
- Snow — degree-day accumulation and melt with refreezing
- Soil moisture — beta-function recharge and evapotranspiration reduction
- Response — two-box (upper/lower zone) storage with percolation
- Routing — triangular transfer-function convolution
15 calibration parameters (jhbv.PARAM_BOUNDS), with defaults in jhbv.DEFAULT_PARAMS.
Daily and sub-daily timesteps are supported; parameters are specified in daily units
and scaled internally (timestep_hours argument).
Testing
pip install -e '.[dev]'
pytest
How to cite
If you use jHBV in your research, please cite the SYMFLUENCE companion papers, which describe the design of the JAX-native model family (registry integration, differentiability, and the calibration experiments they enable):
Eythorsson, D., et al. (2026). The registry as social contract: Architectural patterns for community hydrological modeling. Water Resources Research (submitted).
Eythorsson, D., et al. (2026). From configuration to prediction: Multi-model, multi-basin experiments with SYMFLUENCE. Water Resources Research (submitted).
Citation metadata for this package is provided in CITATION.cff;
a version-specific DOI is minted via Zenodo for each GitHub release.
References
- Lindström, G., Johansson, B., Persson, M., Gardelin, M., & Bergström, S. (1997). Development and test of the distributed HBV-96 hydrological model. Journal of Hydrology, 201(1–4), 272–288. https://doi.org/10.1016/S0022-1694(97)00041-3
- Bergström, S. (1995). The HBV model. In V. P. Singh (Ed.), Computer Models of Watershed Hydrology (pp. 443–476). Water Resources Publications.
License
Apache-2.0. See LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jhbv-0.2.5.tar.gz.
File metadata
- Download URL: jhbv-0.2.5.tar.gz
- Upload date:
- Size: 107.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
725df783f2fe95f599aa0a78913e61a20c52ee4b1c34b9fa29a527c3334ad98b
|
|
| MD5 |
ce1c7cb0972bc090f2b47b9ba12bad86
|
|
| BLAKE2b-256 |
f435fb711731a8194dad252a0fa2f5850c06c8c4803ffbac72b1c7fc4a9486ba
|
File details
Details for the file jhbv-0.2.5-py3-none-any.whl.
File metadata
- Download URL: jhbv-0.2.5-py3-none-any.whl
- Upload date:
- Size: 113.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61bb1ea3c001216dd3d9118fdcf8a4cad7391b4d36e9b3b4b5dcd4f7544c5cd2
|
|
| MD5 |
a289f0814178d0de9c08dd57d1f2c016
|
|
| BLAKE2b-256 |
b69ebb248d785d1176a55cde866b8add2888688978d65b398b11f6c6008ed7b2
|