Skip to content

Commit

Permalink
Stat Service (#92)
Browse files Browse the repository at this point in the history
* fix links

* stat service to get_record
  • Loading branch information
elbeejay authored Mar 30, 2023
1 parent 5a45c76 commit 7416a72
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 15 deletions.
10 changes: 10 additions & 0 deletions dataretrieval/nwis.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@ def get_record(sites=None, start=None, end=None,
- 'pmcodes': get parameter codes
- 'water_use': get water use data
- 'ratings': get rating table
- 'stat': get statistics
**kwargs: optional
If supplied, will be used as query parameters
Expand Down Expand Up @@ -988,6 +989,11 @@ def get_record(sites=None, start=None, end=None,
>>> df = dataretrieval.nwis.get_record(
... sites='01585200', service='ratings')
>>> # Get annual statistics for USGS station 01646500
>>> df = dataretrieval.nwis.get_record(
... sites='01646500', service='stat', statReportType='annual',
... statYearType='water')
"""
if service not in WATERSERVICES_SERVICES + WATERDATA_SERVICES:
raise TypeError('Unrecognized service: {}'.format(service))
Expand Down Expand Up @@ -1041,6 +1047,10 @@ def get_record(sites=None, start=None, end=None,
df, _ = get_ratings(site=sites, **kwargs)
return df

elif service == 'stat':
df, _ = get_stats(sites=sites, **kwargs)
return df

else:
raise TypeError('{} service not yet implemented'.format(service))

Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ project repository.

.. _Hydroshare: https://www.hydroshare.org/resource/c97c32ecf59b4dff90ef013030c54264/

.. _demos/hydroshare: https://github.com/USGS-python/dataretrieval/tree/master/demos/hydroshare
.. _demos/hydroshare: https://github.com/DOI-USGS/dataretrieval-python/tree/master/demos/hydroshare

.. toctree::
:maxdepth: 1
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/siteinfo_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ the resulting column names for the output dataframes (example prompted by

.. _NWIS water services documentation: https://nwis.waterservices.usgs.gov/rest/Site-Service.html

.. _GitHub Issue #34: https://github.com/USGS-python/dataretrieval/issues/34
.. _GitHub Issue #34: https://github.com/DOI-USGS/dataretrieval-python/issues/34

.. doctest::

Expand Down
4 changes: 2 additions & 2 deletions docs/source/meta/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Ways to contribute
Reporting Bugs:
^^^^^^^^^^^^^^^

Report bugs at https://github.com/USGS-python/dataretrieval/issues
Report bugs at https://github.com/DOI-USGS/dataretrieval-python/issues

When reporting a bug, please include:

Expand Down Expand Up @@ -44,7 +44,7 @@ Submitting Feedback:
^^^^^^^^^^^^^^^^^^^^

The best way to send feedback is to file an issue at
https://github.com/USGS-python/dataretrieval/issues
https://github.com/DOI-USGS/dataretrieval-python/issues

If you are proposing a feature:

Expand Down
8 changes: 4 additions & 4 deletions docs/source/meta/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ or ``conda``. Package dependencies are listed in the `requirements.txt`_ file,
a full list of dependencies necessary for development are listed in the
`requirements-dev.txt`_ file.

.. _requirements.txt: https://github.com/USGS-python/dataretrieval/blob/master/requirements.txt
.. _requirements.txt: https://github.com/DOI-USGS/dataretrieval-python/blob/master/requirements.txt

.. _requirements-dev.txt: https://github.com/USGS-python/dataretrieval/blob/master/requirements-dev.txt
.. _requirements-dev.txt: https://github.com/DOI-USGS/dataretrieval-python/blob/master/requirements-dev.txt


User Installation
Expand Down Expand Up @@ -51,7 +51,7 @@ The first step is to clone your fork of the repository:

.. code-block:: bash
$ git clone https://github.com/USGS-python/dataretrieval.git
$ git clone https://github.com/DOI-USGS/dataretrieval-python.git
Then, set the cloned repository as your current working directory in your
terminal and run the following commands to get an "editable" installation of
Expand All @@ -74,7 +74,7 @@ defining the main repository as a remote `upstream` repository:

.. code-block:: bash
$ git remote add upstream https://github.com/USGS-python/dataretrieval.git
$ git remote add upstream https://github.com/DOI-USGS/dataretrieval-python.git
You can also build the documentation locally by running the following commands:

Expand Down
4 changes: 2 additions & 2 deletions docs/source/meta/license.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ States Geological Survey, an agency of the United States Department of
Interior. For more information, see the `LICENSE.md`_ file. See the
`Disclaimer.md`_ file for more information about the disclaimer.

.. _LICENSE.md: https://github.com/USGS-python/dataretrieval/blob/master/LICENSE.md
.. _LICENSE.md: https://github.com/DOI-USGS/dataretrieval-python/blob/master/LICENSE.md

.. _Disclaimer.md: https://github.com/USGS-python/dataretrieval/blob/master/Disclaimer.md
.. _Disclaimer.md: https://github.com/DOI-USGS/dataretrieval-python/blob/master/DISCLAIMER.md
2 changes: 1 addition & 1 deletion docs/source/userguide/timeconventions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ the exception to this is when incomplete datetime information is available, in
these cases integers are used as the dataframe index (see `PR#58`_ for more
details).

.. _PR#58: https://github.com/USGS-python/dataretrieval/pull/58
.. _PR#58: https://github.com/DOI-USGS/dataretrieval-python/pull/58


Inspecting Timestamps
Expand Down
4 changes: 0 additions & 4 deletions tests/waterservices_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ def test_get_record_validation():
get_record(sites=['01491000'], service='not_a_service')
assert 'Unrecognized service: not_a_service' == str(type_error.value)

with pytest.raises(TypeError) as type_error:
get_record(sites=['01491000'], service='stat')
assert 'stat service not yet implemented' == str(type_error.value)


def test_get_dv(requests_mock):
"""Tests get_dv method correctly generates the request url and returns the result in a DataFrame"""
Expand Down

0 comments on commit 7416a72

Please sign in to comment.