Skip to content

Add SiteTypeCode and StatisticCode enums for waterdata parameters#234

Draft
thodson-usgs wants to merge 1 commit intoDOI-USGS:mainfrom
thodson-usgs:fix-enums-site-type
Draft

Add SiteTypeCode and StatisticCode enums for waterdata parameters#234
thodson-usgs wants to merge 1 commit intoDOI-USGS:mainfrom
thodson-usgs:fix-enums-site-type

Conversation

@thodson-usgs
Copy link
Copy Markdown
Collaborator

Summary

  • Adds SiteTypeCode and StatisticCode as str-based enums in dataretrieval/waterdata/enums.py
  • Exports both from dataretrieval.waterdata public API
  • Both enums extend str, so existing callers passing plain strings are unaffected — the enums are purely additive
  • SiteTypeCode covers all 56 site types from get_reference_table("site-types")
  • StatisticCode covers the 17 named statistic codes (excluding the 90+ numeric percentile entries)

Usage example:

from dataretrieval.waterdata import SiteTypeCode, StatisticCode, get_monitoring_locations, get_daily

df, _ = get_monitoring_locations(site_type_code=SiteTypeCode.WELL)
df, _ = get_daily(statistic_id=StatisticCode.MEAN)

Closes #98

Test plan

  • python -m pytest tests/waterdata_test.py — all 26 tests pass
  • Live smoke test: get_monitoring_locations(state_name="Connecticut", site_type_code=SiteTypeCode.WELL) returns only GW sites
  • Verified requests serializes enum values correctly (uses native string value, not __repr__)

Exposes discoverable constants for the `site_type_code` and `statistic_id`
parameters so callers get IDE autocompletion without breaking any existing
string-based usage (both enums extend `str`).

Closes DOI-USGS#98

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

enums for site type, county, etc.

1 participant