Skip to main content

NextGen-compatible δHBV2.0 rainfall-runoff module.

Project description

δHBV2.0: Differentiable Rainfall-Runoff Module

Python PyPI version PyTorch

Ruff Build License


δHBV 2.0 is a state-of-the-art, distributed differentiable HBV model leveraging intelligent parameterization, big data, and highly-parallelized GPU compute with PyTorch to deliver CONUS-scale, high-resolution inference of parameters and fluxes.

This repository serves as an operations-level module for NOAA-OWP’s Next Generation National Water Modeling Framework (NextGen). It provides Basic Model Interface (BMI) adapters for two modeling modalities:

  1. δHBV 2.0: Daily timestep simulation.
  2. δHBV 2.0 MTS: Hourly timestep simulation using a Multi-TimeScale (MTS) architecture.

Installation

uv pip install dhbv2

For operational deployment and NextGen setup, see docs.


Model Descriptions

Models are built on the generic differentiable modeling framework δMG.

1. δHBV 2.0 (Daily)

First introduced by Song et al. (2024) [1].

The daily model uses an LSTM and MLP to learn parameters for the differentiable physical model HBV 2.0. Weather forcings (precipitation, temperature, PET) and static catchment attributes are used as inputs to simulate hydrological states and fluxes:

$$ \begin{align} \theta_{d, m}^{1:t} &= \text{LSTM}( x_m^{1:t}, A_m ) \ \theta_{s, m} &= \text{MLP}( A_m ) \ Q_k^{1:t}, S_k^{1:t} &= \text{HBV}(x_m^{1:t}, \theta_{d, m}^{1:t}, \theta_{s, m}) \end{align} $$

where:

  • $\theta$: Learned dynamic ($d$) and static ($s$) parameters.
  • $x_m, A_m$: Forcings and attributes for unit basin $m$.
  • $Q, S$: Model fluxes (e.g., streamflow) and states (e.g., snowpack).

2. δHBV 2.0 MTS (Hourly)

Introduced by Yang et al. (2025) [2].

The Multi-TimeScale (MTS) variant adapts the architecture for hourly simulation. It incorporates a rolling window input caching mechanism to bridge the gap between long-term hydrologic memory and high-frequency forcing:

  • Caching: Caches ~351 days of aggregated daily inputs and ~7 days of hourly inputs.
  • Warmup: Performs warmup steps using the cache to prime low-frequency (daily) and high-frequency (hourly) model states before generating hourly predictions.
  • Rolling Window: After 7 days of hourly simulation, the cache window shifts forward 7 days and the warmup is repeated.

Note: To run a simulation in NextGen for a given time period, the prior 358 days of forcing data must be included in the input to satisfy warmup described above.

E.g., simulations starting 01/01/2009 01:00 require an input dataset timeseries starting at 01/08/2008 01:00.


NextGen Configuration

To use these models in NextGen, reference the specific class in your realization configuration.

Daily Simulation

Use dhbv2.bmi.DeltaModelBmi.

{
    "time_step": 86400,
    "tag": "ngen_dhbv",
    "formulation": {
        "params": {
            "python_type": "dhbv2.bmi.DeltaModelBmi",
            "model_type_name": "dhbv2.0",
            "init_config": "/path/to/bmi_config.yaml"
        }
    }
}

Hourly (MTS) Simulation

Use dhbv2.mts_bmi.MtsDeltaModelBmi.

{
    "time_step": 3600,
    "tag": "ngen_dhbv_mts",
    "formulation": {
        "params": {
            "python_type": "dhbv2.mts_bmi.MtsDeltaModelBmi",
            "model_type_name": "dhbv2.0 mts",
            "init_config": "/path/to/mts_bmi_config.yaml"
        }
    }
}

Operational Deployment

See docs for installation and runtime instructions.


Repository Organization

This package is designed to be installed as a Python dependency or placed in NextGen's extern/ directory.

src/dhbv2/
├── bmi.py          # Daily BMI adapter
├── mts_bmi.py      # Hourly (MTS) BMI adapter
├── pet.py          # Utility for PET calculations
└── utils.py        # Shared utilities

Publications

  1. Song, Y., Bindas, T., Shen, C., Ji, H., Knoben, W. J. M., Lonzarich, L., Clark, M. P., et al. "High-resolution national-scale water modeling is enhanced by multiscale differentiable physics-informed machine learning." Water Resources Research (2025). https://doi.org/10.1029/2024WR038928

    BibTeX
    @article{shen2023differentiable,
    title = {High-Resolution National-Scale Water Modeling Is Enhanced by Multiscale Differentiable Physics-Informed Machine Learning},
    author = {Song, Yalan and Bindas, Tadd and Shen, Chaopeng and Ji, Haoyu and Knoben, Wouter J. M. and Lonzarich, Leo and Clark, Martyn P. and Liu, Jiangtao and van Werkhoven, Katie and Lamont, Sam and Denno, Matthew and Pan, Ming and Yang, Yuan and Rapp, Jeremy and Kumar, Mukesh and Rahmani, Farshid and Thébault, Cyril and Adkins, Richard and Halgren, James and Patel, Trupesh and Patel, Arpita and Sawadekar, Kamlesh Arun and Lawson, Kathryn},
    journal = {Water Resources Research},
    volume = {61},
    number = {4},
    pages = {e2024WR038928},
    year={2025},
    doi = {https://doi.org/10.1029/2024WR038928},
    url = {https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2024WR038928}
    }
    

  2. Yang, W., Ji, H., Lonzarich, L., Song, Y., Lawson, K., Shen, C. (2025). [In Review]

Contributing

We welcome contributions! See CONTRIBUTING.md for details.


Please submit an issue to report any questions, concerns, or bugs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dhbv2-0.5.0.tar.gz (8.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dhbv2-0.5.0-py3-none-any.whl (32.0 kB view details)

Uploaded Python 3

File details

Details for the file dhbv2-0.5.0.tar.gz.

File metadata

  • Download URL: dhbv2-0.5.0.tar.gz
  • Upload date:
  • Size: 8.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dhbv2-0.5.0.tar.gz
Algorithm Hash digest
SHA256 71020b6d34d8692e17058d2547ff89d2a99862ffbfdf9c22743e57b49985571c
MD5 72179cb5ccd138f4841b7fd66b017d89
BLAKE2b-256 70d986814a75c8eac362068fad4f597f02337958b7348bb34167c66edd3ef9ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for dhbv2-0.5.0.tar.gz:

Publisher: build-wheels.yaml on mhpi/dhbv2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dhbv2-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: dhbv2-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 32.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dhbv2-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 62bc5c37fce224f86b0b289f5e215e152ff7823a17f66ee8dff4e0645ae4d857
MD5 6a13c8d79ffb261e34d422ad742a9012
BLAKE2b-256 b34f1251ce4d2ef52804a07c2c2363d012bf60672b80fecdc7332a5e94920cec

See more details on using hashes here.

Provenance

The following attestation bundles were made for dhbv2-0.5.0-py3-none-any.whl:

Publisher: build-wheels.yaml on mhpi/dhbv2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page