Prepare Observation Data
Choose source: Manual CSV, GRQA database extraction, or Copernicus synthetic generation
β’ Calibration Framework Overview
β’ Parameter Categories (106+)
Section 01: Sensitivity Analysis
β’ Morris Screening
β’ Sobol Sensitivity Analysis
Section 02: DDS Optimization
β’ DDS Algorithm
β’ Objective Functions
β’ Temporal Resolution
Section 03: Calibration Workflow
β’ Step-by-Step Workflow
β’ Observation Data Sources
β’ GRQA Database Integration
β’ CSV Format
Section 04: Implementation
β’ Priority-Based Calibration
β’ Running Calibration
β’ Calibration Output
β’ Best Practices
Section 05: Post-Calibration Reporting
β’ Interactive HTML Reports
β’ Basin Maps & Spatial Analysis
β’ Multi-Variant Basin Reports
OpenWQ includes a comprehensive calibration framework with:
βββββββββββββββββββββββββββββββββββββββ
β Calibration Workflow β
βββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββββββββββββββββββ β
β β 1. Morris Screening (~200) β β
β β β Identify sensitive β β
β ββββββββββββββββ¬βββββββββββββββ β
β βΌ β
β βββββββββββββββββββββββββββββββ β
β β 2. Sobol Analysis (~1000) β β
β β β Rank top parameters β β
β ββββββββββββββββ¬βββββββββββββββ β
β βΌ β
β βββββββββββββββββββββββββββββββ β
β β 3. DDS Optimization (~300) β β
β β β Optimize top 10-15 β β
β ββββββββββββββββ¬βββββββββββββββ β
β βΌ β
β βββββββββββββββββββββββββββββββ β
β β 4. Validation β β
β β β Independent period β β
β βββββββββββββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββ
| Category | Count | Examples | Typical Range |
|---|---|---|---|
| BGC (NATIVE_BGC_FLEX) | 26 | k_nitrification, k_denitrification, theta | 0.001 - 1.0 /day |
| PHREEQC | 22 | Initial concentrations, pCO2, SI | Varies |
| Sorption | 16 | Kfr, qmax, KL, bulk_density | 0.01 - 100 L/kg |
| Sediment Transport | 14 | erosion_index, erodibility, cohesion | 0.1 - 10 |
| Transport | 5 | dispersion_x/y/z, characteristic_length | 0.1 - 100 mΒ²/s |
| Lateral Exchange | 4 | k_exchange (river-soil, soil-GW) | 0.0001 - 0.1 /s |
| Source/Sink | 21 | Load scaling, export coefficients | 0.1 - 5.0Γ |
Efficient method to identify influential parameters with minimal model runs.
r = 10-20 trajectories, k = parameters
Example: 30 params Γ 15 trajectories = ~465 runs
| ΞΌ* (mu-star) | Mean absolute effect β Overall influence |
| Ο (sigma) | Standard deviation β Non-linearity |
| ΞΌ* | Ο | Meaning |
|---|---|---|
| High | Low | Linear influence β Calibrate |
| High | High | Non-linear β Calibrate carefully |
| Low | Low | Non-influential β Fix at default |
| Low | High | Interactive β Investigate |
Variance-based method for detailed sensitivity ranking.
N = 1000-5000 samples, k = parameters
Example: 30 params Γ 2000 samples = ~124,000 runs
| S1 | First-order: Direct parameter effect |
| ST | Total-order: Including interactions |
Derivative-free optimization designed for expensive models.
DDS Behavior Over Iterations
Early (exploration)
ββββββββββββββββββββββββββββββββ
β ββββββββββββββββββββββββββββ β Many params
β ββββββββββββββββββ β perturbed
β ββββββββββββ β
ββββββββββββββββββββββββββββββββ
Late (exploitation)
ββββββββββββββββββββββββββββββββ
β βββ β Few params
β ββ β refined
β β β
ββββββββββββββββββββββββββββββββ
Probability of perturbation:
P(i) = 1 - ln(i)/ln(max_iter)
Root Mean Square Error
Nash-Sutcliffe Efficiency
Kling-Gupta Efficiency
Percent Bias
Aggregate observations and model outputs to a common temporal scale before computing objective functions.
| Option | Use Case |
|---|---|
| native | Original timestamps (no aggregation) |
| daily | Daily patterns matter |
| weekly | Smooth day-to-day noise |
| monthly | Seasonal patterns, sparse obs |
| yearly | Long-term trends, budgets |
mean (default) | sum | median | min | max
Use mean for concentrations, sum for loads/fluxes
# Configuration in calibration file temporal_resolution = "monthly" aggregation_method = "mean" # How it works: # 1. Group obs by reach, species, month # 2. Extract model outputs for same periods # 3. Aggregate both to monthly means # 4. Compute KGE/NSE/RMSE on aggregated data
monthly for sparse grab samples β ensures fair comparison with continuous model output
Choose source: Manual CSV, GRQA database extraction, or Copernicus synthetic generation
Test all 100+ parameters β identify ~30-40 influential ones
Detailed SA on 30 params β rank and select top 10-15
Optimize top 10-15 parameters, fix others at defaults
Test calibrated parameters on independent time period
Two options for preparing observation data:
observation_data_source = "csv"
Best for: Custom datasets, local monitoring networks
observation_data_source = "grqa"
Best for: Large-scale studies, data-rich regions
grqa_config = {
# Local or download from Zenodo
"local_data_path": "/data/GRQA",
"river_network_shapefile": "rivers.shp",
"max_station_distance_m": 500,
"species_mapping": {
"NO3": "NO3-N",
"NH4": "NH4-N"
}
}
| GRQA | Model Species |
|---|---|
| NO3 | NO3-N |
| NH4 | NH4-N |
| TN | TN |
| PO4 | PO4-P |
| TP | TP |
| TSS | TSS |
| DOC | DOC |
python my_calibration.py --prepare-obs-only
# observations.csv (all sources produce this format)
datetime,reach_id,species,value,units,source,uncertainty,quality_flag
2018-01-15 10:00:00,1200014181,NO3-N,2.50,mg/l,USGS_station_A,0.25,GOOD
2018-01-15 10:00:00,1200014181,NH4-N,0.15,mg/l,USGS_station_A,0.02,GOOD
2018-02-01 10:00:00,1200014181,NO3-N,3.10,mg/l,USGS_station_A,0.31,GOOD
2018-02-01 10:00:00,1200014181,TP,0.08,mg/l,USGS_station_A,0.01,GOOD
...
| datetime | YYYY-MM-DD HH:MM:SS |
| reach_id | Matching model output |
| species | Case-sensitive name |
| value | Measured concentration |
| units | mg/l, ug/l, etc. |
| source | Data provider ID |
| uncertainty | Measurement error |
| quality_flag | GOOD, SUSPECT, BAD |
When resources are limited, focus on the most influential parameters:
5-8 parameters
Next 5-8 parameters
Remaining parameters
Copy the template to your working directory, configure parameters, then run:
# 1) Copy and edit the template cp calibration_config_template.py my_calibration.py # 2) Run in different modes: python my_calibration.py # Full calibration python my_calibration.py --sensitivity-only # SA only python my_calibration.py --prepare-obs-only # Obs data only python my_calibration.py --dry-run # Validate config python my_calibration.py --resume # Resume from checkpoint
| --sensitivity-only | Run Morris/Sobol only |
| --prepare-obs-only | Prepare observations (GRQA/CSV) |
| --dry-run | Validate without running |
| --resume | Continue from checkpoint |
run_sensitivity_first = True
β Auto SA β Calibration pipeline
best_parameters.json | Optimal values |
calibration_history.json | All evaluations |
parameter_definitions.json | Parameter metadata & bounds |
matched_data.csv | Obs-model matched pairs |
calibration_report.html | Interactive HTML report |
basin_report.html | Per-basin multi-variant report |
sensitivity_results.json | SA results (if run) |
| Model Runtime | 300 Evals |
|---|---|
| 5 min | ~25 hours |
| 15 min | ~75 hours |
| 30 min | ~150 hours |
Calibration automatically generates self-contained HTML reports with interactive Plotly.js charts.
| Plotly.js | Zoom, pan, hover tooltips |
| Dark/Light mode | Theme toggle included |
| Parameter table | Best values + bounds + position bar |
| Species metrics | Per-species KGE/NSE/RMSE |
| Sidebar nav | Jump to any section |
Reports are created automatically when calibration completes β no extra steps needed.
Calibration reports include interactive Leaflet.js maps showing the basin spatial context.
3 selectable basemaps: CARTO Light, OpenTopoMap, Esri Satellite
*_basinHru.gpkg, *_riverNetwork.gpkg)
| Total HRUs | Count from GeoPackage |
| River reaches | Network segments |
| Total area | kmΒ² from HRU polygons |
| Network length | km of river network |
| Max Strahler order | Stream hierarchy |
| Obs stations | Matched monitoring sites |
Layer toggle, zoom, scale bar, legend, click-for-info popups
When running multiple variants (A/B/C/D), a consolidated basin report is auto-generated comparing all variants.
workspace_{basin}_{variant}) are detected automatically
Calibration completes β βΌ parameter_definitions.json β saved matched_data.csv β saved β βΌ calibration_report.html β per-variant β βΌ Detect sibling workspaces β βΌ basin_report.html β multi-variant
Morris screening to identify influential parameters (106 β 30)
Sobol analysis for detailed sensitivity ranking (30 β 10-15)
DDS calibration of top parameters (200-500 evaluations)
Auto-generated interactive HTML reports with maps & charts
Calibration scripts: supporting_scripts/Calibration/
Observation data: CSV | GRQA Database | Reports: HTML with interactive maps & charts