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 and optimized versions (xaj_mz with Muskingum routing, xaj_slw)
- 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: Consistent interfaces for calibration, evaluation, and simulation
- 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 | |
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 CAMELS datasets (11 variants) - 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 Muskingum routing | 15 | Muskingum |
| xaj_slw | XAJ with SLW routing | 26 | Storage-lag-weighted |
| gr4j | GR4J rainfall-runoff model | 4 | Unit hydrograph |
| hymod | HYMOD model | 5 | Nash cascade |
| dhf | Dahuofang model | 18 | Custom |
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¶
Support for 11 CAMELS variants worldwide:
- CAMELS-US (671 basins)
- CAMELS-AUS (222 basins)
- CAMELS-BR (897 basins)
- CAMELS-CL (516 basins)
- CAMELS-GB (671 basins)
- And more...
Custom Data¶
Use your own data with selfmadehydrodataset format:
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!