Usage Guide¶
Document Purpose: This guide provides a concise overview of hydromodel's unified API architecture. For detailed examples and workflows, see the Examples section.
Overview¶
Unified API Design¶
hydromodel provides a completely unified interface for all hydrological models:
1 | |
Core Design Principles:
- Unified Interfaces: All models (XAJ, GR series, etc.) use the same API
- Configuration-Based: YAML configs for reproducibility
- Decoupled Components: Calibration, evaluation, and simulation are independent
- Flexible Integration: Works with CAMELS datasets and custom data
Key Components¶
| Component | Purpose | Module |
|---|---|---|
UnifiedDataLoader |
Load and preprocess data | datasets.unified_data_loader |
calibrate() |
Model calibration | trainers.unified_calibrate |
evaluate() |
Model evaluation | trainers.unified_evaluate |
simulate() |
Model simulation (new) | trainers.unified_simulate |
UnifiedSimulator |
Direct model simulation | trainers.unified_simulate |
Architecture¶
Code Structure¶
1 2 3 4 5 6 7 8 9 10 11 12 | |
Data Flow¶
1 2 3 4 5 | |
Configuration System¶
All APIs use a consistent configuration format:
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 | |
Core APIs¶
Calibration¶
1 2 3 4 | |
Output: {output_dir}/{experiment_name}/calibration_results.json
For detailed examples, see Calibration Examples.
Evaluation¶
1 2 3 4 | |
For detailed examples, see Simulation Examples.
Simulation¶
1 2 3 4 | |
Return format:
| Key | Type | Description |
|---|---|---|
simulation |
dict |
Model output arrays (usually {"qsim": array}) |
qobs |
ndarray |
Observed streamflow (if available) |
parameters |
dict |
The parameter values used |
model_name |
str |
Model name |
basin_ids |
list |
Basin IDs simulated |
For detailed examples, see Simulation Examples.
Supported Models¶
| Model | Name | Parameters | Notes |
|---|---|---|---|
| xaj | Standard XAJ | 15 | Recession constant + lag time routing |
| xaj_mz | XAJ with MizuRoute routing | 15 | Gamma unit hydrograph (MizuRoute) |
| xaj_slw | XAJ for Songliao basin | 26 | SMS3 + LAG3 routing |
| gr4j | GR4J | 4 | Daily lumped model |
| gr5j | GR5J | 5 | Extended GR4J |
| gr6j | GR6J | 6 | Extended GR5J |
| hymod | HYMOD | 5 | Nash cascade |
| dhf | Dahuofang model | 18 | Custom |
For detailed model documentation, see Models.
Supported Datasets¶
The authoritative runtime registry lives in hydrodataset (public datasets) and
hydrodatasource (custom datasets), not in hydromodel. You can extend or override
entries with a project-level configs/datasets.yml.
Public datasets (27, via hydrodataset):
- CAMELS series (16): 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 series (2): camelsh, camelsh_kr
- CARAVAN series (3): caravan, caravan_dk, grdc_caravan
- LamaH series (2): lamah_ce, lamah_ice
For custom data, see Data Guide.
Command-Line Scripts¶
Calibration¶
1 2 3 4 5 6 7 8 | |
Simulation¶
1 2 3 4 5 | |
Evaluation¶
1 2 3 4 | |
Visualization¶
1 2 3 | |
Best Practices¶
- Use YAML configs for reproducibility
- Always use warmup (typically 365 days for daily data)
- Evaluate on independent test period after calibration
- Set random seeds for reproducible results
- Version control your config files
Summary¶
Key Takeaways¶
- Unified Design: All models, algorithms, and data sources use the same API
- Configuration-Based: YAML configs ensure reproducibility
- Decoupled Components: Calibration, evaluation, and simulation are independent
- Flexible Integration: Works with CAMELS and custom data
- Extensible: Easy to add new models, algorithms, and metrics
Core APIs¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
Additional Resources¶
- Quick Start: quickstart.md - End user guide for quick setup
- Data Guide: data_guide.md - Data preparation and management
- FAQ: faq.md - Common questions and solutions
- Examples: Examples - Detailed examples and workflows
- API Reference: Full API documentation (auto-generated)
- GitHub: https://github.com/OuyangWenyu/hydromodel
- Issues: https://github.com/OuyangWenyu/hydromodel/issues
Contributing¶
For developers interested in contributing:
- Fork the repository
- Create a feature branch
- Follow the unified API design principles
- Add tests for new features
- Update documentation
- Submit a pull request
See contributing.md for detailed guidelines.