Skip to content

Add stream temp endpoints#727

Merged
cstephen merged 2 commits into
mainfrom
add_stream_temp
Jun 16, 2026
Merged

Add stream temp endpoints#727
cstephen merged 2 commits into
mainfrom
add_stream_temp

Conversation

@Joshdpaul

Copy link
Copy Markdown
Contributor

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. Supports source parameter (gcm_diff_applied_to_cheng default, original_gcm, gcm_diff) and format=csv.
  • /arctic_hydrology/wt_modeled_climatology/<stream_id> — daily water temperature climatologies (min/mean/max per day of year) for all models. Supports source parameter (gcm_diff_applied_to_cheng default, original_gcm) and format=csv. gcm_diff is 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 stats and modeled_climatology endpoints. PGW models are included under original_gcm and 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 new calculate_and_apply_gcm_diffs_to_cheng_wt_climatology helper (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 endpoints
  • templates/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 model

Known issues / follow-up needed

@Joshdpaul Joshdpaul requested a review from Copilot June 15, 2026 23:18
@Joshdpaul Joshdpaul marked this pull request as ready for review June 15, 2026 23:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_csv to 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.

Comment thread routes/arctic_hydrology.py
Comment thread routes/arctic_hydrology.py
@Joshdpaul Joshdpaul requested a review from cstephen June 15, 2026 23:25

@cstephen cstephen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@cstephen cstephen merged commit 8c4ab98 into main Jun 16, 2026
1 of 2 checks passed
@cstephen cstephen deleted the add_stream_temp branch June 16, 2026 23:38
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.

3 participants