Add source parameter to CONUS hydrology + arctic hydrology endpoints#720
Conversation
…oggle between datasets
… add notes about future work
…w choice of source for that endpoint; add notes to variable metadata indicating source
There was a problem hiding this comment.
Pull request overview
This PR updates the CONUS hydrology API to support a new Rasdaman “source” dimension by exposing it as a ?source= query parameter, while simplifying hydroviz logic by moving Maurer-adjustment math out of inline endpoint code and into shared processing.
Changes:
- Add
?source=support for/conus_hydrology/stats/{stream_id}and/conus_hydrology/modeled_climatology/{stream_id}(withgcm_diff_applied_to_maureras default). - Update Rasdaman stats coverage wiring to
conus_hydro_segments_stats_combinedand add WCS subsetting for the source axis. - Add “source notes” into JSON variable descriptions and CSV metadata output; remove client-side
ma99derivation.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| templates/documentation/conus_hydrology.html | Documents ?source= options for stats and modeled climatology endpoints. |
| routes/conus_hydrology.py | Implements source handling, updates stats coverage, adds Maurer adjustment helper, and simplifies hydroviz aggregation. |
| generate_requests.py | Adds optional SUBSET=source(...) to CONUS hydrology WCS request generation. |
| csv_functions.py | Adds source-specific notes to CSV metadata and adds None-skipping in CSV row construction. |
| application.py | Adds global marshmallow validation for source query parameter values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ua-snap/data-api/sessions/3db7f7c2-1e57-4578-a221-88bb2156d8ec Co-authored-by: Joshdpaul <99696041+Joshdpaul@users.noreply.github.com>
…t mirroring conus hydrology endpoint structure; add source dimension support; Cheng-baseline delta adjustment for GCM models (PGW models ignored, use original_gcm values); add source notes to CSV output.
cstephen
left a comment
There was a problem hiding this comment.
I kicked the tires on this quite a bit, downloading the JSON data for each source from each endpoint, doing a diff of the different source values to make sure they differed in the way I expected. I also tested the hydroviz webapp against this endpoint and made a few tweaks in PR #722 to make this more compatible with the webapp. The documentation and CSVs look great, too! Approved!
Summary
Both the CONUS hydrology and arctic hydrology stats coverages in Rasdaman have been updated (
conus_hydro_segments_stats_combinedandak_hydro_segments_stats_combined) to include a source dimension encoding three variants of the data. This branch wires up that new dimension as a?source=query parameter and simplifies theconus_hydrology/stats/{stream_id}andarctic_hydrology/stats/{stream_id}endpoints by moving the historical baseline adjustment math out of inline application code and into the coverage itself.Changes:
?source=parameter on/conus_hydrology/stats/{stream_id},arctic_hydrology/stats/{stream_id},/conus_hydrology/modeled_climatology/{stream_id}, and/arctic_hydrology/modeled_climatology/{stream_id}. Accepted values are:/conus_hydrology/hydroviz/{stream_id}and/arctic_hydrology/hydroviz/{stream_id}endpoints are simplified: the historical baseline adjustment calculation previously done inline is now handled bycalculate_and_apply_gcm_diffs_to_maurer_climatology()orcalculate_and_apply_gcm_diffs_to_cheng_climatology(), and is called from the modeled climatology endpoint when source is "gcm_diff_applied_to_maurer" (the conus default) or "gcm_diff_applied_to_cheng" (the arctic default). Note that this math is now optional depending on the choice of source: the user can get an un-adjusted hydrograph too by using source="original_gcm", if that's what they want.ma99removed from client-side calculation: annual mean flow is now stored in the coverage, socalculate_and_populate_annual_mean_flow()is deleted.?source=values are validated via marshmallow inapplication.py.?source=options and parameter chaining documented for both endpoints.Note that the source notes (in variable metadata descriptions and CSV headers) and their documentation wording are first drafts. The language describing what each source mode means should be revised if there is a better way to clearly communicate the data provenance. Any ideas here are welcome, or we could workshop it with the rest of the team later.
XREF: ua-snap/hydroviz#184
XREF: ua-snap/rasdaman-ingest#157
XREF: ua-snap/arctic_rivers#4
XREF: ua-snap/rasdaman-ingest#158