A convenient interface to the USGS NWIS Instantaneous Values (IV) REST Service API.
Project description
OWPHydroTools :: NWIS Client
This subpackage implements an interface to the USGS NWIS Instantaneous Values Web Service. The primary use for this tool is to populate pandas.Dataframe
objects with USGS streamflow data. See the NWIS Client Documentation for a complete list and description of the currently available methods. To report bugs or request new features, submit an issue through the OWPHydroTools Issue Tracker on GitHub.
Installation
In accordance with the python community, we support and advise the usage of virtual
environments in any workflow using python. In the following installation guide, we
use python's built-in venv
module to create a virtual environment in which the
tool will be installed. Note this is just personal preference, any python virtual
environment manager should work just fine (conda
, pipenv
, etc. ).
# Create and activate python environment, requires python >= 3.8
$ python3 -m venv venv
$ source venv/bin/activate
$ python3 -m pip install --upgrade pip
# Install nwis_client
$ python3 -m pip install hydrotools.nwis_client
Usage
The following example demonstrates how one might use hydrotools.nwis_client
to retrieve USGS streamflow observations.
Code
# Import the NWIS IV Client
from hydrotools.nwis_client.iv import IVDataService
# Retrieve data from a single site
service = IVDataService(
value_time_label="value_time"
)
observations_data = service.get(
sites='01646500',
startDT='2019-08-01',
endDT='2020-08-01'
)
# Look at the data
print(observations_data.head())
Output
value_date variable_name usgs_site_code measurement_unit value qualifiers series
0 2019-08-01 04:00:00 streamflow 01646500 ft3/s 4170.0 [A] 0
1 2019-08-01 04:15:00 streamflow 01646500 ft3/s 4170.0 [A] 0
2 2019-08-01 04:30:00 streamflow 01646500 ft3/s 4170.0 [A] 0
3 2019-08-01 04:45:00 streamflow 01646500 ft3/s 4170.0 [A] 0
4 2019-08-01 05:00:00 streamflow 01646500 ft3/s 4170.0 [A] 0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for hydrotools.nwis_client-3.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14450c6a5d45639fafb836fa66b0699d0eb7f0b442302642deda6212d234855b |
|
MD5 | 013ba86de192d35e273c80288dd55488 |
|
BLAKE2b-256 | 8d7ec761918d8f4b96b92372fc34b63f3b07e396e972689345f8b624ead00b0f |
Hashes for hydrotools.nwis_client-3.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fb0e68f8ee9cefa634c69f84391b50d8785c43bafe6e9bab0dc69c6d3d56ae1 |
|
MD5 | 82f895fa4227f21e2ea00c7906b9a14a |
|
BLAKE2b-256 | c1f5c65ffaea4333276b6cb9f2d01c9562ba982a8913004de0708397279e63ed |