Skip to content

Geometry predictor script with global KAN + slope floor fix#184

Merged
taddyb merged 2 commits into
DeepGroundwater:masterfrom
taddyb:slope_change
Apr 3, 2026
Merged

Geometry predictor script with global KAN + slope floor fix#184
taddyb merged 2 commits into
DeepGroundwater:masterfrom
taddyb:slope_change

Conversation

@taddyb
Copy link
Copy Markdown
Collaborator

@taddyb taddyb commented Apr 3, 2026

Summary

  • New scripts/geometry_predictor.py — Hydra script that predicts KAN parameters (n, p, q) for all 2.9M global MERIT reaches and computes trapezoidal geometry statistics (min/max/median/mean for depth, top_width, bottom_width, side_slope, hydraulic_radius, discharge) for 346K CONUS reaches with streamflow data. Non-CONUS reaches get KAN params with NaN geometry stats.
  • New src/ddr/geometry/statistics.py — Pure compute_geometry_statistics() function (no I/O) that takes KAN params + daily accumulated discharge and returns per-reach temporal statistics.
  • Slope minimum raised from 0.0001 to 0.001 — The old floor caused 200m+ depth predictions on flat high-Q reaches (Mississippi delta). Updated across configs.py, predictor.py, and all test fixtures. Model will need retraining with the new floor.
  • Simplified example notebooks — Both geometry_predictor.ipynb and plot_parameter_map.ipynb are now thin consumers that load the script's .nc output and plot. All inline routing code removed.
  • New config/merit_geometry_config.yaml — Hydra config for WY2000 (1999/10/01–2000/09/30) with 30-day batches.

Files changed

File Change
scripts/geometry_predictor.py New Hydra script
src/ddr/geometry/statistics.py New pure computation module
src/ddr/geometry/__init__.py Export compute_geometry_statistics
src/ddr/validation/configs.py Slope minimum 0.0001 → 0.001
src/ddr/geometry/predictor.py Slope fallback 0.0001 → 0.001
config/merit_geometry_config.yaml New Hydra config
examples/merit/geometry_predictor.ipynb Simplified to load .nc + plot
examples/merit/plot_parameter_map.ipynb Simplified to load .nc + plot
tests/geometry/test_geometry_stats.py 4 unit tests for statistics
tests/geometry/test_predictor.py Updated slope fixture
tests/routing/test_utils.py Updated slope fixture
tests/validation/test_configs.py Updated slope default test
tests/benchmarks/conftest.py Updated slope fixture

Test plan

  • uv run pytest tests/geometry/test_geometry_stats.py — 4 pass
  • uv run pytest tests/geometry/ tests/validation/test_configs.py tests/routing/test_utils.py — 53 pass
  • Full script run produces 353 MB NetCDF with 2.9M reaches (2.5 min on CPU)
  • Retrain model with new slope floor (0.001) before production use

🤖 Generated with Claude Code

@taddyb taddyb merged commit c501d66 into DeepGroundwater:master Apr 3, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant