Add stream temp endpoints#727
Conversation
…eed to update clim coverage to fix units and stats coverage to fix NaN issue
There was a problem hiding this comment.
Pull request overview
This PR adds modeled water temperature support to the existing Arctic Hydrology API patterns by introducing stream-ID endpoints for water temperature statistics and daily climatologies, alongside corresponding CSV metadata and documentation updates.
Changes:
- Added
/arctic_hydrology/wt_stats/<stream_id>and/arctic_hydrology/wt_modeled_climatology/<stream_id>route handlers, including a helper to apply additive GCM deltas to the historical baseline for temperature climatologies. - Extended
arctic_hydrology_csvto emit water-temperature-specific CSV metadata blocks for the new endpoints. - Updated the Arctic Hydrology documentation page to describe the new endpoints, output schemas, variable tables, and additional source citations.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
routes/arctic_hydrology.py |
Adds new WT endpoints + additive Cheng-adjustment helper; extends metadata packaging call sites for WT climatologies. |
csv_functions.py |
Adds WT statistics/climatology CSV comment headers and source-note handling. |
templates/documentation/arctic_hydrology.html |
Documents new WT endpoints, response examples, and supporting citations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cstephen
left a comment
There was a problem hiding this comment.
I kicked the tires on this to make sure the endpoints work, the optional source parameter works as expected, CSV exports work and have the correct metadata for each endpoint, the documentation looks good, the numbers appear sane, and the code is followable. Approved!
Summary
This branch adds two new endpoints to the Arctic Hydrology API for water temperature data:
/arctic_hydrology/wt_stats/<stream_id>— water temperature statistics (era-level summary stats) for all models. Supportssourceparameter (gcm_diff_applied_to_chengdefault,original_gcm,gcm_diff) andformat=csv./arctic_hydrology/wt_modeled_climatology/<stream_id>— daily water temperature climatologies (min/mean/max per day of year) for all models. Supportssourceparameter (gcm_diff_applied_to_chengdefault,original_gcm) andformat=csv.gcm_diffis not valid for this endpoint (returns 400), consistent with the streamflow climatology endpoint.Both endpoints follow the same structure and parameter conventions as the existing
statsandmodeled_climatologyendpoints. PGW models are included underoriginal_gcmand excluded from the Cheng-adjusted and diff sources. CSV output includes full variable comment headers.Files changed
routes/arctic_hydrology.py— new route handlers and a newcalculate_and_apply_gcm_diffs_to_cheng_wt_climatologyhelper (additive delta, vs. multiplicative ratio used for streamflow). We use additive here since temperature is not zero bounded like flow.csv_functions.py— water temperature CSV metadata blocks for both new endpointstemplates/documentation/arctic_hydrology.html— documentation for both endpoints, output schema examples, variable reference table, and four new source citations to provide more info about inputs to the stream flow modelKnown issues / follow-up needed
arctic_hydrology/hydrovizendpoint here yet