Add waterdata.get_peaks for the annual peak-streamflow OGC collection#267
Merged
thodson-usgs merged 1 commit intoDOI-USGS:mainfrom May 7, 2026
Merged
Add waterdata.get_peaks for the annual peak-streamflow OGC collection#267thodson-usgs merged 1 commit intoDOI-USGS:mainfrom
thodson-usgs merged 1 commit intoDOI-USGS:mainfrom
Conversation
Collaborator
Author
|
Tracked in the v1.1.4 release-staging issue: #270. |
ldecicco-USGS
approved these changes
May 6, 2026
Collaborator
ldecicco-USGS
left a comment
There was a problem hiding this comment.
Do you have deprecation messages in all the NWIS modules? I think with peaks and ratings, all NWIS functions should now have a waterdata replacement.
Collaborator
Author
|
Here's Claude's survey:
So once #267 (peaks) and #269 (ratings) merge, every NWIS function has a waterdata replacement (except I'll follow up with the warnings in a separate PR |
6 tasks
Wraps the new /ogcapi/v0/collections/peaks collection. Returns the annual peak record for a monitoring location — one row per (location, parameter, water year) — which is the standard input to flood- frequency analysis (log-Pearson Type III etc). The collection covers stage (parameter 00065) and discharge (00060); typical streamgages have a series for each. Implementation reuses the existing get_ogc_data infrastructure: - service = "peaks" - output_id = "peak_id" (the API's `id` field is renamed for users, matching the project's other get_* functions) R has no equivalent yet; the docstring was written from scratch following the project's existing get_* style. Two live tests cover the happy path (single-site, both parameters present) and a water-year filter. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
thodson-usgs
added a commit
to thodson-usgs/dataretrieval-python
that referenced
this pull request
May 7, 2026
…oval The module-level "use waterdata instead" warning has been firing on import for a while; this PR makes the migration guidance actionable by emitting a per-function DeprecationWarning that names the specific waterdata replacement the user should switch to. Once peaks (DOI-USGS#267) and ratings (DOI-USGS#269) land, every active nwis function has a waterdata replacement, so all nine of them are deprecated here: nwis.get_dv -> waterdata.get_daily() nwis.get_iv -> waterdata.get_continuous() nwis.get_info -> waterdata.get_monitoring_locations() nwis.what_sites -> waterdata.get_monitoring_locations() nwis.get_stats -> waterdata.get_stats_por() / waterdata.get_stats_date_range() nwis.get_discharge_peaks -> waterdata.get_peaks() nwis.get_ratings -> waterdata.get_ratings() nwis.get_record -> the appropriate waterdata.get_*() nwis.query_waterdata -> a high-level waterdata.get_*() helper nwis.query_waterservices -> a high-level waterdata.get_*() helper (get_qwdata, get_discharge_measurements, get_gwlevels, get_pmcodes, and get_water_use are already defunct and raise NameError.) Implementation follows the nadp deprecation template (DOI-USGS#243): a small _REPLACEMENTS dict + a _warn_deprecated(func_name) helper called as the first line of each public function. stacklevel=3 makes the warning point at the caller's code, not the helper's frame. 11 new parametrized tests pin the warning text — that the function name appears, the replacement helper appears, and the removal date appears — plus one end-to-end test that get_iv() actually fires its warning when called. Removal date is set to 2027-05-06, one full year out (vs. the six months used for nadp), since nwis is much more widely used and most users will need migration time. Maintainer can adjust if desired. This depends on DOI-USGS#267 (waterdata.get_peaks) and DOI-USGS#269 (waterdata.get_ratings) being merged: until then the deprecation messages for get_discharge_peaks and get_ratings point at functions users can't yet call. Hold this PR draft until those land. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
thodson-usgs
added a commit
to thodson-usgs/dataretrieval-python
that referenced
this pull request
May 7, 2026
Addresses Copilot review on DOI-USGS#271: `_REPLACEMENTS` points `get_discharge_peaks` -> `waterdata.get_peaks()` and `get_ratings` -> `waterdata.get_ratings()`. If this PR merged before its dependencies landed, users following the migration guidance would hit AttributeError. Adds a parametrized test that imports `dataretrieval.waterdata` and asserts every concrete callable named in the deprecation messages exists. The test currently fails on `get_peaks` (still on PR DOI-USGS#267, not yet on main) — exactly the desired behavior: this PR cannot merge before DOI-USGS#267. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
thodson-usgs
added a commit
to thodson-usgs/dataretrieval-python
that referenced
this pull request
May 7, 2026
…oval The module-level "use waterdata instead" warning has been firing on import for a while; this PR makes the migration guidance actionable by emitting a per-function DeprecationWarning that names the specific waterdata replacement the user should switch to. Once peaks (DOI-USGS#267) and ratings (DOI-USGS#269) land, every active nwis function has a waterdata replacement, so all nine of them are deprecated here: nwis.get_dv -> waterdata.get_daily() nwis.get_iv -> waterdata.get_continuous() nwis.get_info -> waterdata.get_monitoring_locations() nwis.what_sites -> waterdata.get_monitoring_locations() nwis.get_stats -> waterdata.get_stats_por() / waterdata.get_stats_date_range() nwis.get_discharge_peaks -> waterdata.get_peaks() nwis.get_ratings -> waterdata.get_ratings() nwis.get_record -> the appropriate waterdata.get_*() nwis.query_waterdata -> a high-level waterdata.get_*() helper nwis.query_waterservices -> a high-level waterdata.get_*() helper (get_qwdata, get_discharge_measurements, get_gwlevels, get_pmcodes, and get_water_use are already defunct and raise NameError.) Implementation follows the nadp deprecation template (DOI-USGS#243): a small _REPLACEMENTS dict + a _warn_deprecated(func_name) helper called as the first line of each public function. stacklevel=3 makes the warning point at the caller's code, not the helper's frame. 11 new parametrized tests pin the warning text — that the function name appears, the replacement helper appears, and the removal date appears — plus one end-to-end test that get_iv() actually fires its warning when called. Removal date is set to 2027-05-06, one full year out (vs. the six months used for nadp), since nwis is much more widely used and most users will need migration time. Maintainer can adjust if desired. This depends on DOI-USGS#267 (waterdata.get_peaks) and DOI-USGS#269 (waterdata.get_ratings) being merged: until then the deprecation messages for get_discharge_peaks and get_ratings point at functions users can't yet call. Hold this PR draft until those land. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
thodson-usgs
added a commit
to thodson-usgs/dataretrieval-python
that referenced
this pull request
May 7, 2026
Addresses Copilot review on DOI-USGS#271: `_REPLACEMENTS` points `get_discharge_peaks` -> `waterdata.get_peaks()` and `get_ratings` -> `waterdata.get_ratings()`. If this PR merged before its dependencies landed, users following the migration guidance would hit AttributeError. Adds a parametrized test that imports `dataretrieval.waterdata` and asserts every concrete callable named in the deprecation messages exists. The test currently fails on `get_peaks` (still on PR DOI-USGS#267, not yet on main) — exactly the desired behavior: this PR cannot merge before DOI-USGS#267. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a thin wrapper around the new
/ogcapi/v0/collections/peakscollection. Returns the annual peak record for a monitoring location — one row per (location, parameter, water year) — which is the standard input to flood-frequency analysis (log-Pearson Type III, etc.).The collection covers stage (parameter
00065) and discharge (00060); typical streamgages have a series for each.Implementation
A thin parameter declaration plus a single call to the existing service-agnostic
get_ogc_data(args, output_id, service):service = "peaks"output_id = "peak_id"— the API'sidfield is renamed for users, matching the project's otherget_*functions.R has no equivalent yet; the docstring was written from scratch following the project's existing
get_*style.Live API examples (verified)
Test plan
test_get_peaks— single-site happy path; assertspeak_id,value,water_yearcolumns and a clean parameter-code subset.test_get_peaks_water_year_filter— exercises thewater_yearfilter.monitoring_location_id="USGS-02238500"returns 135 rows, parameter codes{"00060", "00065"}.Related
Part of the v1.1.4 release-staging series; will be linked from a tracking issue.