Skip to content

Revamp custom endpoint for hydroviz webapp#715

Merged
Joshdpaul merged 16 commits intomainfrom
hydroviz_webapp_endpoint
Apr 22, 2026
Merged

Revamp custom endpoint for hydroviz webapp#715
Joshdpaul merged 16 commits intomainfrom
hydroviz_webapp_endpoint

Conversation

@cstephen
Copy link
Copy Markdown
Contributor

@cstephen cstephen commented Apr 21, 2026

This PR revamps the API endpoint for the hydroviz webapp. It:

  • Taps into existing functions in the conus_hydrology.py route to fetch relevant data
  • Immediately adjusts all fetched data using the following math: Maurer * (GCM projected / GCM historical)
  • Performs the modulo year rollover trick on stats with Julian date units
  • Clamps "number of days" stats above 366 to 366 in the (unlikely) event that this is necessary
  • Packages and computes the data needed to populate all of the charts and tables in the hydroviz webapp

To test, just run this API from this branch and kick the tires a bit on a variety of steam segments using URLs like the following, for example:

http://localhost:5000/conus_hydrology/hydroviz/50101

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new CONUS hydrology “hydroviz” API endpoint that aggregates existing stats + modeled climatology outputs into a single response tailored for the hydroviz webapp, including Maurer-adjusted projections and derived chart/table structures.

Changes:

  • Replace the prior .../hydroviz/<stream_id>/<model> route with .../hydroviz/<stream_id> and expand the response payload (hydrograph, monthly flow, max-flow dates, table stats).
  • Apply Maurer scaling to projected stats/climatology using Maurer * (GCM projected / GCM historical), plus Julian-day rollover and day-count clamping logic.
  • Enable CONUS hydrology routes by importing conus_hydrology in routes/__init__.py.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
routes/conus_hydrology.py Implements the new hydroviz endpoint and supporting data transforms/aggregation.
routes/__init__.py Exposes CONUS hydrology endpoints by importing the module into the routes blueprint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread routes/conus_hydrology.py Outdated
Comment thread routes/conus_hydrology.py Outdated
Comment thread routes/conus_hydrology.py
Comment thread routes/conus_hydrology.py
@cstephen cstephen force-pushed the hydroviz_webapp_endpoint branch from 0f7b466 to 2dd7dd8 Compare April 21, 2026 21:26
@Joshdpaul
Copy link
Copy Markdown
Contributor

Great work here Craig! Works just as expected, and I think the math matches exactly what we described in the past few meetings.

During this review, I created 2 new issues that are worth noting for future improvements:

#717
#718

We might combine these with #712 in a new PR?

@Joshdpaul Joshdpaul merged commit f6996b7 into main Apr 22, 2026
1 check failed
@Joshdpaul Joshdpaul deleted the hydroviz_webapp_endpoint branch April 22, 2026 20:32
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.

5 participants