Skip to main content

pwa-calibration

SPOTPY-driven calibration of Raven hydrological models, extracted from the PWA dev repo's src/py/setup_spotpy.py, 3_calibrate.py, and _notebooks/4_calibrate.ipynb (sections 1.1–1.3).

Layout

pwa_calibration/
  objectives.py    # KGE / NSE / NSE+PBIAS — pure functions, no Raven dependency
  setup.py         # SpotPySetup class (refactored spot_setup_rvn)
  prepare.py       # Stages files into the calibration directory
  runner.py        # Parallel calibration entrypoint (refactored 3_calibrate.py)

Installation

pip install -e .                 # core
pip install -e .[mpi]            # plus mpi4py (requires system MPI)
pip install -e .[dev]            # plus pytest

pwa-raven must be installable; install it from ../pwa_raven first.

Running calibration

See pwa_calibration.runner for the programmatic entry point and the CLI. The legacy mpirun -c 14 python 3_calibrate.py results invocation is preserved behaviorally by runner.run_calibration(config).

Running tests

This project uses pytest. From the repo root with the conda env activated:

python -m pytest -q

Useful flags during development:

  • -q — quiet output (one dot per test, summary at the end)
  • -k <pattern> — run only tests whose name matches the pattern
  • -x — stop on the first failure (fast feedback while iterating)
  • --tb=short — concise tracebacks
  • -p no:cacheprovider — skip the .pytest_cache/ write (useful in read-only checkouts)

Tests live in tests/unit/ and (where applicable) tests/regression/. All tests should pass before opening a pull request.

Contributing

Workflow for adding a feature or fixing a bug:

  1. Create a feature branch off the default branch. Use feat/<short-name> for features and fix/<short-name> for bug fixes — never commit directly to the default branch.
  2. Write a failing test first that describes the desired behavior. Run python -m pytest -q to confirm the new test fails. For bug fixes, the test should reproduce the bug.
  3. Write code to make the test pass. Run the suite again and confirm green.
  4. Commit incrementally with focused commit messages that explain why (the motivation, the problem, the trade-off) rather than just what (the diff is the what).
  5. Open a pull request against the default branch. Tag the relevant reviewer. The PR description should include a short summary, a test plan, and links to any related issues.

Practical notes:

  • New features should ship with corresponding tests. If a unit test is hard to write, that's often a signal the design needs refactoring.
  • Avoid disabling, skipping, or commenting out tests to make builds pass — investigate the root cause and fix it properly.
  • Keep commits small and atomic. If you find yourself making unrelated changes in the same commit, split them.
  • Don't add features beyond what the issue/PR scope requires. YAGNI — build for the current need, refactor later when a second use case emerges.

Metadata

Release files for pwa-calibration 0.1.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 pwa-calibration 0.1.0
File Size Uploaded
pwa_calibration-0.1.0.tar.gz 34.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pwa-calibration 0.1.0
File Interpreter ABI Platform
pwa_calibration-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 70.7 kB

Release files / pwa_calibration-0.1.0.tar.gz

Download URL pwa_calibration-0.1.0.tar.gz
Size 34.9 kB
Tags Source
SHA-256 checksum
How to use checksums
38947ab49bb11337cea65352a211bdd2a4361454a7e9de1973f33391eacdd240
BLAKE2b-256 checksum
How to use checksums
310aee07759bfdcb45b199fcf445a4a27bcadc474eded48098007bc8a11e17b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / pwa_calibration-0.1.0-py3-none-any.whl

Download URL pwa_calibration-0.1.0-py3-none-any.whl
Size 35.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f16a8c027b40c1d275be2f3a59469de6e058a822e8a3f925e8563c5198cf5481
BLAKE2b-256 checksum
How to use checksums
dd7ebc37757558992de684f1a816b9a1d9f9cc237f1936d458f1b4efc1b6c252
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.1.0 This release

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