Skip to main content
Visit Hydrofunctions on PyPI Unit Testing Status Code Coverage Status Documentation Status MIT license

A suite of convenience functions for exploring water data in Python.

Features

  • Retrieves stream data from the USGS NWIS service

  • Select data using multiple site numbers, by state, county codes, or a boundary box

  • Preserves NWIS metadata, including NoData values

  • Helpful error messages to help you write valid requests

  • Extracts data into a Pandas dataframe, json, or dict

  • Plot beautiful graphs in Jupyter Notebooks
    • hydrographs (or time series of any data)

    • flow duration charts

    • cycle plots to illustrate annual or diurnal cycles

    • Interactive map for finding stream gauge ID numbers

  • Plotting and manipulation through Pandas dataframes

  • Retrieve USGS rating curves, peak discharges, field notes, and site files for gauging stations

  • Retrieve USGS daily, monthly, and annual statistics for gauging stations

  • Saves data in compact, easy-to-use parquet files instead of requesting the same dataset repeatedly

  • Massive Users Guide that makes Hydrology AND Data Science easy!

Still in active development! Let me know what features you want!

Read the Users Guide for more details.

Basic Usage

First, import hydrofunctions into your project. If you plan to work with Jupyter notebooks, then go ahead and enable automatic chart display:

In  [1]: import hydrofunctions as hf
         %matplotlib inline

Create an NWIS data object to hold our request and the data we will retrieve. We will request the instantaneous values (‘iv’) for site ‘01585200’ for the past 55 days:

In  [2]: herring = hf.NWIS('01585200', 'iv', period='P55D')
Requested data from https://waterservices.usgs.gov/nwis/iv/?format=json%2C1.1&sites=01585200&period=P55D

You can check that the request went smoothly:

In  [3]: herring.ok
Out [3]: True

Find out what data we received:

In  [4]: herring
Out [4]: USGS:01585200: WEST BRANCH HERRING RUN AT IDLEWYLDE, MD
             00060: <5 * Minutes>  Discharge, cubic feet per second
             00065: <5 * Minutes>  Gage height, feet
         Start: 2019-05-25 01:05:00+00:00
         End:   2019-07-19 19:05:00+00:00

This tells us the name of our site and gives a list of the parameters that we have. For each parameter it lists how frequently the data were collected, and it shows the common name of the parameter and its units.

Create a dataframe using only our discharge data, and list the first five items:

In  [5]: herring.df('discharge').head()
Out [5]:

–a table with our data appears–

datetimeUTC

USGS:01585200:00060:00000

2019-05-25 01:05:00+00:00

1.57

2019-05-25 01:10:00+00:00

1.57

2019-05-25 01:15:00+00:00

1.51

2019-05-25 01:20:00+00:00

1.57

2019-05-25 01:25:00+00:00

1.57

If we’re using Jupyter Lab, we can plot a graph of the data using built-in methods from Pandas and mathplotlib:

In  [6]: herring.df('q').plot()
Out [6]:

–a stream hydrograph appears–

a stream hydrograph for Herring Run

Learn more:

Easy Installation

The easiest way to install Hydrofunctions is by typing this from your command line:

$ pip install hydrofunctions

Hydrofunctions depends upon Pandas and numerous other scientific packages for Python. Anaconda is an easy, safe, open-source method for downloading everything and avoiding conflicts with other versions of Python that might be running on your computer.

Visit the Installation Page in the Users Guide to learn how to install Anaconda, or if you have problems using the Easy Installation method above.

Metadata

Release files for hydrofunctions 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hydrofunctions 0.2.4
File Size Uploaded
hydrofunctions-0.2.4.tar.gz 4.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for hydrofunctions 0.2.4
File Interpreter ABI Platform
hydrofunctions-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 4.6 MB

Release files / hydrofunctions-0.2.4.tar.gz

Download URL hydrofunctions-0.2.4.tar.gz
Size 4.6 MB
Tags Source
SHA-256 checksum
How to use checksums
4cfd7ef59d62206d71c36309020a201e3a37d0604e9f41a991880310be4cc0d6
BLAKE2b-256 checksum
How to use checksums
e1fa56308ce64ea14bee1aa9d75d8a3d0f4aaaf940e07dd0e9d5b868476b9de4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.4

Release files / hydrofunctions-0.2.4-py3-none-any.whl

Download URL hydrofunctions-0.2.4-py3-none-any.whl
Size 40.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8ff9c3d6aa737634472a3e01116b876aba031c5e2d62232af0d51f921698d12
BLAKE2b-256 checksum
How to use checksums
ed79f855b9f26e57da1a0978d28c3412e64e8a09cee13e505bfc6022186fcf8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.7

3 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.0.1

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page