Skip to content

Commit 3b509bd

Browse files
thodson-usgsclaude
andcommitted
Add SiteTypeCode and StatisticCode enums for waterdata parameters
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 #98 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c4d0f84 commit 3b509bd

2 files changed

Lines changed: 126 additions & 0 deletions

File tree

dataretrieval/waterdata/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
get_stats_por,
2626
get_time_series_metadata,
2727
)
28+
from .enums import SiteTypeCode, StatisticCode
2829
from .types import (
2930
CODE_SERVICES,
3031
PROFILE_LOOKUP,
@@ -37,6 +38,8 @@
3738
"PROFILES",
3839
"PROFILE_LOOKUP",
3940
"SERVICES",
41+
"SiteTypeCode",
42+
"StatisticCode",
4043
"get_channel",
4144
"get_codes",
4245
"get_continuous",

dataretrieval/waterdata/enums.py

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
"""Enumerations for constrained waterdata API parameters.
2+
3+
Using these enums is optional — plain strings are accepted everywhere — but
4+
they enable IDE autocompletion and make valid values discoverable without
5+
consulting the documentation.
6+
7+
Examples
8+
--------
9+
>>> from dataretrieval.waterdata import SiteTypeCode, StatisticCode
10+
>>> df, _ = get_monitoring_locations(site_type_code=SiteTypeCode.STREAM)
11+
>>> df, _ = get_daily(statistic_id=StatisticCode.MEAN)
12+
"""
13+
14+
from enum import Enum
15+
16+
17+
class SiteTypeCode(str, Enum):
18+
"""Site type codes for monitoring locations.
19+
20+
Codes correspond to the ``site_type_code`` parameter accepted by
21+
:func:`~dataretrieval.waterdata.get_monitoring_locations` and related
22+
functions. The full reference table is available via
23+
``get_reference_table("site-types")``.
24+
"""
25+
26+
# Primary site types
27+
AGGREGATE_GROUNDWATER_USE = "AG"
28+
AGGREGATE_SURFACE_WATER_USE = "AS"
29+
ATMOSPHERE = "AT"
30+
AGGREGATE_WATER_USE_ESTABLISHMENT = "AW"
31+
ESTUARY = "ES"
32+
GLACIER = "GL"
33+
WELL = "GW"
34+
LAND = "LA"
35+
LAKE = "LK"
36+
OCEAN = "OC"
37+
SUBSURFACE = "SB"
38+
SPRING = "SP"
39+
STREAM = "ST"
40+
WETLAND = "WE"
41+
42+
# Facility secondary types
43+
FA_ANIMAL_WASTE_LAGOON = "FA-AWL"
44+
FA_CISTERN = "FA-CI"
45+
FA_COMBINED_SEWER = "FA-CS"
46+
FA_DIVERSION = "FA-DV"
47+
FA_FIELD_PASTURE_ORCHARD_NURSERY = "FA-FON"
48+
FA_GOLF_COURSE = "FA-GC"
49+
FA_HYDROELECTRIC_PLANT = "FA-HP"
50+
FA_LANDFILL = "FA-LF"
51+
FA_OUTFALL = "FA-OF"
52+
FA_PAVEMENT = "FA-PV"
53+
FA_LABORATORY = "FA-QC"
54+
FA_WASTEWATER_SEWER = "FA-SEW"
55+
FA_SEPTIC_SYSTEM = "FA-SPS"
56+
FA_STORM_SEWER = "FA-STS"
57+
FA_THERMOELECTRIC_PLANT = "FA-TEP"
58+
FA_WATER_DISTRIBUTION_SYSTEM = "FA-WDS"
59+
FA_WASTE_INJECTION_WELL = "FA-WIW"
60+
FA_WATER_SUPPLY_TREATMENT_PLANT = "FA-WTP"
61+
FA_WATER_USE_ESTABLISHMENT = "FA-WU"
62+
FA_WASTEWATER_LAND_APPLICATION = "FA-WWD"
63+
FA_WASTEWATER_TREATMENT_PLANT = "FA-WWTP"
64+
65+
# Groundwater secondary types
66+
GW_COLLECTOR_WELL = "GW-CR"
67+
GW_EXTENSOMETER_WELL = "GW-EX"
68+
GW_HYPORHEIC_ZONE_WELL = "GW-HZ"
69+
GW_INTERCONNECTED_WELLS = "GW-IW"
70+
GW_MULTIPLE_WELLS = "GW-MW"
71+
GW_TEST_HOLE = "GW-TH"
72+
73+
# Land secondary types
74+
LA_EXCAVATION = "LA-EX"
75+
LA_OUTCROP = "LA-OU"
76+
LA_PLAYA = "LA-PLY"
77+
LA_SOIL_HOLE = "LA-SH"
78+
LA_SINKHOLE = "LA-SNK"
79+
LA_SHORE = "LA-SR"
80+
LA_VOLCANIC_VENT = "LA-VOL"
81+
82+
# Ocean secondary type
83+
OC_COASTAL = "OC-CO"
84+
85+
# Subsurface secondary types
86+
SB_CAVE = "SB-CV"
87+
SB_GROUNDWATER_DRAIN = "SB-GWD"
88+
SB_TUNNEL_SHAFT_MINE = "SB-TSM"
89+
SB_UNSATURATED_ZONE = "SB-UZ"
90+
91+
# Stream secondary types
92+
ST_CANAL = "ST-CA"
93+
ST_DITCH = "ST-DCH"
94+
ST_TIDAL = "ST-TS"
95+
96+
97+
class StatisticCode(str, Enum):
98+
"""Common statistic codes used by the waterdata time-series endpoints.
99+
100+
Used in the ``statistic_id`` parameter of
101+
:func:`~dataretrieval.waterdata.get_daily`,
102+
:func:`~dataretrieval.waterdata.get_continuous`, and similar functions.
103+
The full reference table is available via
104+
``get_reference_table("statistic-codes")``.
105+
"""
106+
107+
MAXIMUM = "00001"
108+
MINIMUM = "00002"
109+
MEAN = "00003"
110+
AM = "00004"
111+
PM = "00005"
112+
SUM = "00006"
113+
MODE = "00007"
114+
MEDIAN = "00008"
115+
STD = "00009"
116+
VARIANCE = "00010"
117+
INSTANTANEOUS = "00011"
118+
EQUIVALENT_MEAN = "00012"
119+
SKEWNESS = "00013"
120+
TIDAL_HIGH_HIGH = "00021"
121+
TIDAL_LOW_HIGH = "00022"
122+
TIDAL_HIGH_LOW = "00023"
123+
TIDAL_LOW_LOW = "00024"

0 commit comments

Comments
 (0)