Skip to content

Commit

Permalink
Adjust gwlevels URL services (#147)
Browse files Browse the repository at this point in the history
* add gwlevels to waterdata services

* add state code conversion

* get rid of usa piece

* adjust mock requests, but still errors

* one correction

* switch format in urls to get tests to work

* Update dataretrieval/nwis.py

keep API consistent

Co-authored-by: Timothy Hodson <34148978+thodson-usgs@users.noreply.github.com>

---------

Co-authored-by: Timothy Hodson <34148978+thodson-usgs@users.noreply.github.com>
  • Loading branch information
ehinman and thodson-usgs authored Aug 2, 2024
1 parent 64a575d commit d3865a2
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 147 deletions.
22 changes: 17 additions & 5 deletions dataretrieval/nwis.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
PARAMCODES_URL = 'https://help.waterdata.usgs.gov/code/parameter_cd_nm_query?'
ALLPARAMCODES_URL = 'https://help.waterdata.usgs.gov/code/parameter_cd_query?'

WATERSERVICES_SERVICES = ['dv', 'iv', 'site', 'stat', 'gwlevels']
WATERSERVICES_SERVICES = ['dv', 'iv', 'site', 'stat']
WATERDATA_SERVICES = [
'qwdata',
'gwlevels',
'measurements',
'peaks',
'pmcodes',
Expand Down Expand Up @@ -434,12 +435,23 @@ def get_gwlevels(
"""
_check_sites_value_types(sites)

kwargs['startDT'] = kwargs.pop('startDT', start)
kwargs['endDT'] = kwargs.pop('endDT', end)
kwargs['sites'] = kwargs.pop('sites', sites)
# Make kwargs backwards compatible with waterservices
# vocabulary
if 'startDT' in kwargs:
kwargs['begin_date'] = kwargs.pop('startDT')
if 'endDT' in kwargs:
kwargs['end_date'] = kwargs.pop('endDT')
if 'sites' in kwargs:
kwargs['site_no'] = kwargs.pop('sites')
if 'stateCd'in kwargs:
kwargs['state_cd'] = kwargs.pop('stateCd')

kwargs['begin_date'] = kwargs.pop('begin_date', start)
kwargs['end_date'] = kwargs.pop('end_date', end)
kwargs['site_no'] = kwargs.pop('site_no', sites)
kwargs['multi_index'] = multi_index

response = query_waterservices('gwlevels', ssl_check=ssl_check, **kwargs)
response = query_waterdata('gwlevels', format = 'rdb', ssl_check=ssl_check, **kwargs)

df = _read_rdb(response.text)

Expand Down
Loading

0 comments on commit d3865a2

Please sign in to comment.