Welcome to hydromodel¶
A lightweight Python package for hydrological model calibration and evaluation, featuring the XinAnJiang (XAJ) model.
hydromodel is a Python implementation of conceptual hydrological models, with a focus on the XinAnJiang (XAJ) model - one of the most widely-used rainfall-runoff models, especially in China and Asian regions. The package provides comprehensive tools for model calibration, evaluation, and simulation with a unified API design.
Key Features¶
🏞️ Hydrological Models¶
- XAJ Model Variants: Standard XAJ, xaj_mz (mizuRoute routing), xaj_slw (Songliao basin variant)
- GR Models: GR1A, GR2M, GR3J, GR4J, GR5J, GR6J
- Other Models: HYMOD, DHF(Dahuofang model)
- Extensible Framework: Easy to add custom models
🔧 Calibration Algorithms¶
- SCE-UA: Shuffled Complex Evolution (robust, recommended for global optimization)
- GA: Genetic Algorithm with DEAP (flexible, handles complex parameter landscapes)
- scipy: L-BFGS-B, SLSQP, and other gradient-based methods (fast for smooth objectives)
📊 Evaluation & Analysis¶
- Comprehensive Metrics: NSE, KGE, RMSE, PBIAS, FHV, FLV, FMS
- Multi-Basin Support: Efficient calibration and evaluation for multiple basins simultaneously
- Time Series Analysis: Flood event extraction and characterization
- Visualization: Automated plotting of simulation results and metrics
🗄️ Data Integration¶
- CAMELS Datasets: Seamless support for 11 CAMELS variants via hydrodataset
- Custom Data: Flexible support for user data via hydrodatasource
- Flood Event Data: Specialized support for discrete flood event datasets
- Standardized Format: Unified data interface across all data sources
🚀 Developer-Friendly¶
- Unified API:
calibrate(config)andsimulate(config)— two functions for all models - Configuration-Based: YAML configuration for reproducibility
- Progress Tracking: Real-time progress display and intermediate results saving
- Standardized Results: All algorithms save results in unified JSON + CSV format
Quick Start¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
Or use command-line scripts:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Installation¶
Quick Installation¶
1 | |
Or using uv (faster):
1 | |
From Source¶
1 2 3 | |
For detailed installation instructions, see the Installation Guide.
Why hydromodel?¶
For Researchers: - Battle-tested XAJ implementations used in published research - Configuration-based workflow ensures reproducibility - Easy to extend with new models or calibration algorithms - Lightweight and fast - perfect for parameter sensitivity studies
For Practitioners: - Simple YAML configuration, minimal coding required - Handles multi-basin calibration efficiently - Integration with global public datasets (27 registered datasets) - Clear documentation and examples
Compared to other packages: - vs. SWAT/VIC: Lighter weight, Python-native, faster iteration - vs. pySTREPS: Focus on conceptual rainfall-runoff models - vs. custom scripts: Well-tested with unified interfaces
Documentation Structure¶
- Installation Guide - Detailed installation instructions for all platforms
- Quick Start - Get started in 5 minutes
- Usage Guide - Comprehensive tutorials and examples
- Data Guide - How to prepare and use different data sources
- API Reference - Complete API documentation
- Model Documentation - Detailed model descriptions (XAJ, DHF)
- Contributing - How to contribute to the project
- FAQ - Frequently asked questions
- Changelog - Version history and updates
Use Cases¶
1. Model Calibration¶
Calibrate hydrological models on CAMELS datasets or custom data with various algorithms:
1 2 3 4 5 6 7 | |
2. Multi-Basin Evaluation¶
Efficiently calibrate and evaluate multiple basins:
1 2 3 | |
3. Parameter Sensitivity Analysis¶
Run simulations with custom parameter sets:
1 2 3 4 5 6 7 8 | |
4. Flood Event Analysis¶
Extract and calibrate on flood events:
1 2 3 4 5 6 7 8 9 10 | |
Supported Models¶
| Model | Description | Parameters | Routing |
|---|---|---|---|
| xaj | Standard XinAnJiang model | 15 | Linear reservoir |
| xaj_mz | XAJ with mizuRoute routing | 15 | Gamma unit hydrograph (mizuRoute) |
| xaj_slw | XAJ for Songliao basin (SLW) | 26 | SMS3 + LAG3 |
| gr1a / gr2m / gr3j | GR rainfall-runoff models | 1 / 2 / 3 | Unit hydrograph |
| gr4j | GR4J rainfall-runoff model | 4 | Unit hydrograph |
| gr5j / gr6j | GR rainfall-runoff models | 5 / 6 | Unit hydrograph |
| hymod | HYMOD model | 5 | Nash cascade |
| dhf | Dahuofang model | 18 | Custom |
| semi_xaj | Semi-distributed XAJ variant | - | Custom |
| unit_hydrograph / categorized_unit_hydrograph | Unit hydrograph models | - | Unit hydrograph |
For detailed model documentation, see XAJ Model and DHF Model.
Calibration Algorithms¶
| Algorithm | Type | Strengths | Best For |
|---|---|---|---|
| SCE-UA | Global | Robust, reliable convergence | General purpose, recommended |
| GA | Global | Flexible, handles discontinuities | Complex parameter landscapes |
| scipy | Local | Fast, gradient-based | Smooth objectives, refinement |
Data Sources¶
CAMELS Datasets¶
27 public datasets are registered in hydrodataset, including the CAMELS series (camels_us, camels_aus, camels_br, camels_ch, camels_cl, camels_col, camels_de, camels_dk, camels_fi, camels_pe, camels_fr, camels_gb, camels_ind, camels_lux, camels_nz, camels_se), CAMELSH, CARAVAN, LamaH, and others. See the Data Guide for the full list and local/cloud configuration.
Custom Data¶
Use your own data with a uri + reader alias (e.g. selfmade), or a registered custom dataset id such as songliao_event:
1 2 3 4 5 6 7 8 9 10 | |
See Data Guide for complete specifications.
Performance¶
- Fast calibration: Optimized algorithms with numba JIT compilation
- Memory efficient: Handles large datasets with chunked processing
- Parallel support: Multi-basin calibration runs independently
- Progress tracking: Real-time monitoring of long-running calibrations
References¶
XAJ Model: - Zhao, R.J., 1992. The Xinanjiang model applied in China. Journal of Hydrology, 135(1-4), pp.371-381.
Calibration Algorithms: - Duan, Q., et al., 1992. Effective and efficient global optimization for conceptual rainfall-runoff models. Water Resources Research, 28(4), pp.1015-1031. (SCE-UA)
Related Projects: - hydrodataset - CAMELS and other datasets - hydrodatasource - Data preparation utilities - torchhydro - PyTorch-based hydrological models
Citation¶
If you use hydromodel in your research, please cite:
1 2 3 4 5 6 | |
License & Credits¶
- License: GNU General Public License v3.0
- Author: Wenyu Ouyang
- Documentation: https://OuyangWenyu.github.io/hydromodel
- Source Code: https://github.com/OuyangWenyu/hydromodel
Getting Help¶
- Documentation: Browse the complete documentation
- Issues: Report bugs or request features at GitHub Issues
- Discussions: Ask questions at GitHub Discussions
- Email: wenyuouyang@outlook.com
Contributing¶
Contributions are welcome! See the Contributing Guide for details on:
- Reporting bugs
- Suggesting features
- Submitting pull requests
- Code style and testing guidelines
Community¶
Join our growing community:
- ⭐ Star the project on GitHub
- 🐛 Report issues and bugs
- 💡 Suggest new features
- 📖 Improve documentation
- 🔧 Contribute code
Ready to get started? Head to the Quick Start Guide or Installation Guide!