jXAJ
Dual-backend (JAX + NumPy) implementation of the Xinanjiang (XAJ) saturation-excess rainfall–runoff model, with optional Snow-17 coupling — 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 jxaj # NumPy backend
pip install 'jxaj[jax]' # with JAX (differentiable, JIT)
Quickstart
from jxaj.model import simulate
# snow-free basin: precipitation and PET only
flow, state = simulate(precip, pet)
# snow-affected basin: couple Snow-17 by passing temperature and day-of-year
flow, state = simulate(precip, pet, temp=temp, day_of_year=doy, latitude=51.17)
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 jxaj.losses 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
jxaj registers with SYMFLUENCE
through the symfluence.plugins entry point — installation is the integration:
pip install symfluence jxaj
# config.yaml (excerpt)
model:
hydrological_model: XINANJIANG
SYMFLUENCE then handles forcing preparation, calibration, evaluation, and benchmarking for the model with no further wiring.
Model structure
The Xinanjiang model (Zhao, 1992) is a saturation-excess model with four components, implemented clean-room from the published equations:
- Evapotranspiration — three-layer (upper/lower/deep) with PET correction
- Runoff generation — saturation excess with parabolic storage-capacity curve
- Source separation — free-water storage partitioning into surface flow, interflow, and groundwater
- Routing — linear reservoirs for interflow and groundwater
13 calibration parameters (jxaj.parameters.PARAM_BOUNDS). For snow-affected
basins the model couples to Snow-17 (snow17_params, temp, day_of_year
arguments; see also simulate_coupled_jax).
Testing
pip install -e '.[dev]'
pytest
How to cite
If you use jXAJ 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
- Zhao, R.-J. (1992). The Xinanjiang model applied in China. Journal of Hydrology, 135(1–4), 371–381. https://doi.org/10.1016/0022-1694(92)90096-E
- Anderson, E. A. (2006). Snow Accumulation and Ablation Model — SNOW-17. NOAA Technical Report NWS HYDRO-17.
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 jxaj-0.2.4.tar.gz.
File metadata
- Download URL: jxaj-0.2.4.tar.gz
- Upload date:
- Size: 41.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb4438296a53cb95d58bf937dc00b054258a4ce6683ffab46f8c749d86c096f2
|
|
| MD5 |
7298c33bcd901cc79adcd69830165050
|
|
| BLAKE2b-256 |
afcaa5e7f238299b545405bbf1f366ac6c7e8ffa4fe2065c82ad4c2146e9a176
|
File details
Details for the file jxaj-0.2.4-py3-none-any.whl.
File metadata
- Download URL: jxaj-0.2.4-py3-none-any.whl
- Upload date:
- Size: 45.7 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 |
782fb8f322cbe4e3317cf25823b8fcf6e6247fbe09ef6c50af7e1bf5ad313ed6
|
|
| MD5 |
c907304f87c01cc1822cb01b3414bde6
|
|
| BLAKE2b-256 |
fa0b58c9a7e87402151b4a812c080b0551480510ddb49ca93a550bd3da07fe75
|