Skip to content

docs: Python ports of the new USGS Water Data API vignettes#291

Merged
thodson-usgs merged 2 commits into
DOI-USGS:mainfrom
thodson-usgs:waterdata-vignettes
May 28, 2026
Merged

docs: Python ports of the new USGS Water Data API vignettes#291
thodson-usgs merged 2 commits into
DOI-USGS:mainfrom
thodson-usgs:waterdata-vignettes

Conversation

@thodson-usgs
Copy link
Copy Markdown
Collaborator

Summary

Ports the five new USGS Water Data API vignettes from the R
dataRetrieval package to the
Python dataretrieval.waterdata module as executable demo notebooks, and wires
them into the Sphinx docs under a new "USGS Water Data API vignettes" section.

New notebook (demos/) R source vignette Key functions
USGS_WaterData_Introduction_Examples read_waterdata_functions.Rmd the whole get_* family + CQL filters
USGS_WaterData_DiscreteSamples_Examples samples_data.Rmd get_samples, get_samples_summary, get_codes
USGS_WaterData_DailyStatistics_Examples daily_data_statistics.Rmd get_stats_por, get_stats_date_range, get_daily
USGS_WaterData_ContinuousData_Examples continuous_pr.Rmd get_continuous, get_combined_metadata
USGS_WaterData_ReferenceLists_Examples Reference_Lists.Rmd get_reference_table

Notes

  • Each notebook was executed end-to-end against the live USGS Water Data API
    during development (0 errors). Outputs are cleared per the repo convention
    — the sphinx-docs workflow re-executes notebooks at build time
    (nbsphinx_execute = auto).
  • Notebook filenames follow the existing USGS_WaterData_<Topic>_Examples
    convention; code cells are formatted with black-jupyter (23.3.0, matching
    .pre-commit-config.yaml).
  • The full Sphinx build (make html) succeeds and renders all five pages with
    their plots; no new build warnings.

R → Python adaptations worth a look

  • CQL queries use filter= / filter_lang="cql-text"; the library deliberately
    rejects unquoted numeric comparisons (the API types everything as strings), so
    the drainage-area example uses a pandas-side numeric reduction instead.
  • read_waterdata_metadataget_reference_table; read_waterdata_parameter_codes
    get_reference_table(collection="parameter-codes"); check_OGC_requests has no
    Python equivalent, so the properties= argument is demonstrated directly.
  • get_stats_* use computation_type= (vs R computation=) and have no
    normal_type / interval_type args yet, so those filters are applied in pandas;
    their string value column is coerced to numeric for plotting/aggregation.

🤖 Generated with Claude Code

@thodson-usgs thodson-usgs force-pushed the waterdata-vignettes branch 4 times, most recently from 3045148 to dfe96dd Compare May 27, 2026 14:04
@thodson-usgs thodson-usgs added the enhancement New feature or request label May 27, 2026
Port five new R dataRetrieval Water Data API vignettes to the Python
`waterdata` module as executable demo notebooks, wired into the Sphinx
docs under a new "USGS Water Data API vignettes" section:

- USGS_WaterData_Introduction_Examples  (read_waterdata_functions.Rmd)
- USGS_WaterData_DiscreteSamples_Examples  (samples_data.Rmd)
- USGS_WaterData_DailyStatistics_Examples  (daily_data_statistics.Rmd)
- USGS_WaterData_ContinuousData_Examples  (continuous_pr.Rmd)
- USGS_WaterData_ReferenceLists_Examples  (Reference_Lists.Rmd)

Each notebook was executed end-to-end against the live USGS Water Data
API during development; outputs are cleared per the repo convention
(the Sphinx docs build re-executes notebooks at build time).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@thodson-usgs thodson-usgs force-pushed the waterdata-vignettes branch from dfe96dd to 1783f2c Compare May 27, 2026 15:15
- Rename `daily_modern`/`field_modern` → `daily_data`/`field_data` (the
  "_modern" suffix was a leftover NWIS-vs-modern comparison artifact)
- Rename `what_huc_sites` → `huc_sites`, `sites_information` → `sites_info`,
  `site_1`/`site_2` → `renamed`/`raw_id`, and `site1` → `site` in the daily
  statistics notebook (no `site2` ever existed)
- Fix broken intra-notebook anchor `#General-retrieval-and-CQL2`
  → `#general-retrieval-and-cql2`
- Simplify the daily-values facet plot by dropping the unnecessary
  `squeeze=False` + axes-indexing workaround
- Clean up the `map_sites` helper in the samples notebook to use the
  conventional `fig, ax = plt.subplots(...)` unpacking and a docstring

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@thodson-usgs thodson-usgs marked this pull request as ready for review May 28, 2026 15:15
@thodson-usgs thodson-usgs merged commit 569ff38 into DOI-USGS:main May 28, 2026
8 checks passed
@thodson-usgs thodson-usgs deleted the waterdata-vignettes branch May 28, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant