Skip to content

Commit 3ae36b3

Browse files
authored
Tutorial prep (#140)
* Update state codes * Link to WQP swagger doc
1 parent e8b508b commit 3ae36b3

File tree

2 files changed

+173
-62
lines changed

2 files changed

+173
-62
lines changed

dataretrieval/codes/states.py

Lines changed: 107 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,108 @@
11
"""List of 2-digit state codes with commented full names."""
2-
state_codes = [
3-
'al', # Alabama
4-
'ak', # Alaska
5-
'az', # Arizona
6-
'ar', # Arkansas
7-
'ca', # California
8-
'co', # Colorado
9-
'ct', # Connecticut
10-
'de', # Delaware
11-
'dc', # District of Columbia
12-
'fl', # Florida
13-
'ga', # Georgia
14-
'hi', # Hawaii
15-
'id', # Idaho
16-
'il', # Illinois
17-
'in', # Indiana
18-
'ia', # Iowa
19-
'ks', # Kansas
20-
'ky', # Kentucky
21-
'la', # Louisiana
22-
'me', # Maine
23-
'md', # Maryland
24-
'ma', # Massachusetts
25-
'mi', # Michigan
26-
'mn', # Minnesota
27-
'ms', # Mississippi
28-
'mo', # Missouri
29-
'mt', # Montana
30-
'ne', # Nebraska
31-
'nv', # Nevada
32-
'nh', # New Hampshire
33-
'nj', # New Jersey
34-
'nm', # New Mexico
35-
'ny', # New York
36-
'nc', # North Carolina
37-
'nd', # North Dakota
38-
'oh', # Ohio
39-
'ok', # Oklahoma
40-
'or', # Oregon
41-
'pa', # Pennsylvania
42-
'ri', # Rhode Island
43-
'sc', # South Carolina
44-
'sd', # South Dakota
45-
'tn', # Tennessee
46-
'tx', # Texas
47-
'ut', # Utah
48-
'vt', # Vermont
49-
'va', # Virginia
50-
'wa', # Washington
51-
'wv', # West Virginia
52-
'wi', # Wisconsin
53-
'wy', # Wyoming
54-
]
2+
state_codes = {
3+
"Alabama": "al",
4+
"Alaska": "ak",
5+
"Arizona": "az",
6+
"Arkansas": "ar",
7+
"California": "ca",
8+
"Colorado": "co",
9+
"Connecticut": "ct",
10+
"Delaware": "de",
11+
"District of Columbia": "dc",
12+
"Florida": "fl",
13+
"Georgia": "ga",
14+
"Hawaii": "hi",
15+
"Idaho": "id",
16+
"Illinois": "il",
17+
"Indiana": "in",
18+
"Iowa": "ia",
19+
"Kansas": "ks",
20+
"Kentucky": "ky",
21+
"Louisiana": "la",
22+
"Maine": "me",
23+
"Maryland": "md",
24+
"Massachusetts": "ma",
25+
"Michigan": "mi",
26+
"Minnesota": "mn",
27+
"Mississippi": "ms",
28+
"Missouri": "mo",
29+
"Montana": "mt",
30+
"Nebraska": "ne",
31+
"Nevada": "nv",
32+
"New Hampshire": "nh",
33+
"New Jersey": "nj",
34+
"New Mexico": "nm",
35+
"New York": "ny",
36+
"North Carolina": "nc",
37+
"North Dakota": "nd",
38+
"Ohio": "oh",
39+
"Oklahoma": "ok",
40+
"Oregon": "or",
41+
"Pennsylvania": "pa",
42+
"Rhode Island": "ri",
43+
"South Carolina": "sc",
44+
"South Dakota": "sd",
45+
"Tennessee": "tn",
46+
"Texas": "tx",
47+
"Utah": "ut",
48+
"Vermont": "vt",
49+
"Virginia": "va",
50+
"Washington": "wa",
51+
"West Virginia": "wv",
52+
"Wisconsin": "wi",
53+
"Wyoming": "wy",
54+
}
55+
56+
fips_codes = {
57+
"Alabama": "01",
58+
"Alaska": "02",
59+
"Arizona": "04",
60+
"Arkansas": "05",
61+
"California": "06",
62+
"Colorado": "08",
63+
"Connecticut": "09",
64+
"Delaware": "10",
65+
"District of Columbia": "11",
66+
"Florida": "12",
67+
"Georgia": "13",
68+
"Hawaii": "15",
69+
"Idaho": "16",
70+
"Illinois": "17",
71+
"Indiana": "18",
72+
"Iowa": "19",
73+
"Kansas": "20",
74+
"Kentucky": "21",
75+
"Louisiana": "22",
76+
"Maine": "23",
77+
"Maryland": "24",
78+
"Massachusetts": "25",
79+
"Michigan": "26",
80+
"Minnesota": "27",
81+
"Mississippi": "28",
82+
"Missouri": "29",
83+
"Montana": "30",
84+
"Nebraska": "31",
85+
"Nevada": "32",
86+
"New Hampshire": "33",
87+
"New Jersey": "34",
88+
"New Mexico": "35",
89+
"New York": "36",
90+
"North Carolina": "37",
91+
"North Dakota": "38",
92+
"Ohio": "39",
93+
"Oklahoma": "40",
94+
"Oregon": "41",
95+
"Pennsylvania": "42",
96+
"Rhode Island": "44",
97+
"South Carolina": "45",
98+
"South Dakota": "46",
99+
"Tennessee": "47",
100+
"Texas": "48",
101+
"Utah": "49",
102+
"Vermont": "50",
103+
"Virginia": "51",
104+
"Washington": "53",
105+
"West Virginia": "54",
106+
"Wisconsin": "55",
107+
"Wyoming": "56",
108+
}

dataretrieval/wqp.py

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
def get_results(ssl_check=True, **kwargs):
2020
"""Query the WQP for results.
2121
22+
Any WQP API parameter can be passed as a keyword argument to this function.
23+
More information about the API can be found at:
24+
https://www.waterqualitydata.us/#advanced=true
25+
or the Swagger documentation at:
26+
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
27+
2228
Parameters
2329
----------
2430
ssl_check: bool
@@ -94,6 +100,12 @@ def get_results(ssl_check=True, **kwargs):
94100
def what_sites(ssl_check=True, **kwargs):
95101
"""Search WQP for sites within a region with specific data.
96102
103+
Any WQP API parameter can be passed as a keyword argument to this function.
104+
More information about the API can be found at:
105+
https://www.waterqualitydata.us/#advanced=true
106+
or the Swagger documentation at:
107+
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
108+
97109
Parameters
98110
----------
99111
ssl_check: bool
@@ -134,6 +146,12 @@ def what_sites(ssl_check=True, **kwargs):
134146
def what_organizations(ssl_check=True, **kwargs):
135147
"""Search WQP for organizations within a region with specific data.
136148
149+
Any WQP API parameter can be passed as a keyword argument to this function.
150+
More information about the API can be found at:
151+
https://www.waterqualitydata.us/#advanced=true
152+
or the Swagger documentation at:
153+
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
154+
137155
Parameters
138156
----------
139157
ssl_check: bool
@@ -172,6 +190,12 @@ def what_organizations(ssl_check=True, **kwargs):
172190
def what_projects(ssl_check=True, **kwargs):
173191
"""Search WQP for projects within a region with specific data.
174192
193+
Any WQP API parameter can be passed as a keyword argument to this function.
194+
More information about the API can be found at:
195+
https://www.waterqualitydata.us/#advanced=true
196+
or the Swagger documentation at:
197+
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
198+
175199
Parameters
176200
----------
177201
ssl_check: bool
@@ -210,6 +234,12 @@ def what_projects(ssl_check=True, **kwargs):
210234
def what_activities(ssl_check=True, **kwargs):
211235
"""Search WQP for activities within a region with specific data.
212236
237+
Any WQP API parameter can be passed as a keyword argument to this function.
238+
More information about the API can be found at:
239+
https://www.waterqualitydata.us/#advanced=true
240+
or the Swagger documentation at:
241+
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
242+
213243
Parameters
214244
----------
215245
ssl_check: bool
@@ -252,6 +282,12 @@ def what_detection_limits(ssl_check=True, **kwargs):
252282
"""Search WQP for result detection limits within a region with specific
253283
data.
254284
285+
Any WQP API parameter can be passed as a keyword argument to this function.
286+
More information about the API can be found at:
287+
https://www.waterqualitydata.us/#advanced=true
288+
or the Swagger documentation at:
289+
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
290+
255291
Parameters
256292
----------
257293
ssl_check: bool
@@ -296,6 +332,12 @@ def what_detection_limits(ssl_check=True, **kwargs):
296332
def what_habitat_metrics(ssl_check=True, **kwargs):
297333
"""Search WQP for habitat metrics within a region with specific data.
298334
335+
Any WQP API parameter can be passed as a keyword argument to this function.
336+
More information about the API can be found at:
337+
https://www.waterqualitydata.us/#advanced=true
338+
or the Swagger documentation at:
339+
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
340+
299341
Parameters
300342
----------
301343
ssl_check: bool
@@ -334,6 +376,12 @@ def what_habitat_metrics(ssl_check=True, **kwargs):
334376
def what_project_weights(ssl_check=True, **kwargs):
335377
"""Search WQP for project weights within a region with specific data.
336378
379+
Any WQP API parameter can be passed as a keyword argument to this function.
380+
More information about the API can be found at:
381+
https://www.waterqualitydata.us/#advanced=true
382+
or the Swagger documentation at:
383+
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
384+
337385
Parameters
338386
----------
339387
ssl_check: bool
@@ -375,6 +423,12 @@ def what_project_weights(ssl_check=True, **kwargs):
375423
def what_activity_metrics(ssl_check=True, **kwargs):
376424
"""Search WQP for activity metrics within a region with specific data.
377425
426+
Any WQP API parameter can be passed as a keyword argument to this function.
427+
More information about the API can be found at:
428+
https://www.waterqualitydata.us/#advanced=true
429+
or the Swagger documentation at:
430+
https://www.waterqualitydata.us/data/swagger-ui/index.html?docExpansion=none&url=/data/v3/api-docs#/
431+
378432
Parameters
379433
----------
380434
ssl_check: bool
@@ -487,16 +541,19 @@ def _alter_kwargs(kwargs):
487541

488542
return kwargs
489543

544+
490545
def _warn_v3_profiles_outage():
491546
"""Private function for warning message about WQX 3.0 profiles
492547
"""
493548

494-
warnings.warn(('USGS discrete water quality data availability '
495-
'and format are changing. Beginning in March 2024 '
496-
'the data obtained from legacy profiles will not '
497-
'include new USGS data or recent updates to existing '
498-
'data. To view the status of changes in data '
499-
'availability and code functionality, visit: '
500-
'https://doi-usgs.github.io/dataRetrieval/articles/Status.html. '
501-
'If you have additional questions about these changes, '
502-
'email [email protected].'))
549+
warnings.warn(
550+
'USGS discrete water quality data availability '
551+
'and format are changing. Beginning in March 2024 '
552+
'the data obtained from legacy profiles will not '
553+
'include new USGS data or recent updates to existing '
554+
'data. To view the status of changes in data '
555+
'availability and code functionality, visit: '
556+
'https://doi-usgs.github.io/dataRetrieval/articles/Status.html. '
557+
'If you have additional questions about these changes, '
558+
559+
)

0 commit comments

Comments
 (0)