Skip to main content

Extract, analyze, and plot hydrological timeseries for a site or watershed using the Google Earth Engine and USGS APIs

Project description

waterpyk

open in colab readthedocs badge PyPi badge Follow me on Twitter badge MIT license badge

A python package to analyze hydrological timeseries for a site or watershed using the Google Earth Engine and USGS APIs.

waterpyk is a simple package for extracting data from the Google Earth Engine (GEE) and USGS APIs and performing simple water-balance analyses. All you need to begin is a lat/long or a USGS gauge ID to start.

For more information on the root-zone water storage capacity and deficit, see Dralle et al., 2021, McCormick et al., 2021, and Rempe, McCormick et al. (in prep).

Check out the tutorial for basic waterpyk usage in GoogleColab here.

Get Started

waterpyk requires geopandas and ee. Read the workflow to install and authenticate ee (GEE) for Google Colab, pip, or conda. You will need to sign up for a GEE account if it is your first time.

Install waterpyk:

pip install waterpyk

To get all of the available data and plots for a site, simply supply a list of coordinates (such as [lat, long] or [gaugeID]).:

from waterpyk install main

coords = [LAT/LONG] # or
gage = [USGS_gage_ID]
yoursitename = main.StudyArea(COORDS_or_GAGE, layers = 'all')

A note on the layers parameter: Two default options are available for extracting data.:

layers = 'all'
layers = 'minimal'

‘All’ will extract precipitation (P), evapotranspiration (ET) from MODIS and PML, MODIS snow cover, MODIS landcover class, and SRTM elevation, including all relevant bands.

‘Minimal’ is the fastest option and extracts only the necessary data for the deficit (P, ET, and snow without extra MODIS products).

Alternatively, layers can also take a dataframe containing a row for each desired GEE asset. See the main and/or gee module docs for more information.

Note that most GEE assets should be extracted with no errors, however not all date formats have been tested, so new assets may throw errors and require manual extraction outside of waterpyk. For these cases, I suggest using the geemap package, which has many fantastic GEE tools and inspired some of this code as well!

Now that you’ve initialized your StudyArea object, all of the dataframes of extracted data will now be available in the form of:

yoursitename.daily_df_wide # includes deficit, wateryear deficit, and cumulative wateryear timeseries
yoursitename.streamflow
yoursitename.wateryear_totals
yoursitename.stats

Some single values are also available as attributes in this way, such as root-zone water storage capacity (Smax, mm) and and mean annual precipitation (MAP, mm):

yoursite.smax
yoursite.MAP

To plot, supply a string for which kind of plot (see below for the 5 options), such as:

yoursitename.plot(kind = 'timeseries')

Extra keyword arguments are available for the plots to change the color, line types, or included data for each kind. See the plots module for default kwargs.

Docs

For full documentation, see full documentation.

What Waterpyk Can Do

  • Download timeseries of GEE assets and:

    • Combining bands

    • Applying a scaling factor

    • Interpolating to daily

  • Download streamflow for gauged watersheds

  • Download watershed information, such as:

    • Boundary and flowline geometry (as GEE or geopandas format)

    • Metadata (such as CRS, name, and gauge ID)

    • Daily discharge (in native units, and converted to mm)

    • Centroid latitude (for calculation of Hargreaves PET)

    • URLs necessary to access all of the above directly

  • Calculate cumulative and total wateryear timeseries

  • Calculate the root-zone water storage (RWS) deficit

  • Create 4 figures, out of the box, with P, ET, Q, and deficit data, including:

    • Wateryear cumulative timeseries (kind = 'wateryear')

    • Daily timeseries, with options (kind = 'timeseries')

    • Plot & calculate Spearman correlation coefficient for summer ET and wateryear P (kind = 'spearman')

    • RWS capacity (Smax) relative to P distribution (kind = 'distribution')

    • RWS timeseries (kind = 'RWS')

Contact

This is a work in progress and is primarily intended for the Rempe Lab Group and co-authors. Feel free to report bugs, and note that major version updates may not be backwards compatible. For more information, contact Erica McCormick at erica.elmstead@gmail.com or the email address given on her homepage.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

waterpyk-1.0.2.tar.gz (36.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

waterpyk-1.0.2-py3-none-any.whl (36.8 kB view details)

Uploaded Python 3

File details

Details for the file waterpyk-1.0.2.tar.gz.

File metadata

  • Download URL: waterpyk-1.0.2.tar.gz
  • Upload date:
  • Size: 36.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/0.0.0 CPython/3.9.13

File hashes

Hashes for waterpyk-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c7d4f54b192d9942f25969d04c193711f11f61bea8035a4d1f7ff85b314752dc
MD5 f4fd69766b880b43e8176a4aca3bf2b7
BLAKE2b-256 d1c91db11f10b501582586b5ba046b2db8246a56433e564be8c2e984a57f4286

See more details on using hashes here.

File details

Details for the file waterpyk-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: waterpyk-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 36.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/0.0.0 CPython/3.9.13

File hashes

Hashes for waterpyk-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e6929d25a2c0e52164cedb3051540caebcee151d096f32ab1362613b4d4b3a6c
MD5 b21e2474682cb08910c737d3bb67290b
BLAKE2b-256 365840a5a2403525e018a3e26f6c6a1f97eabb03cad87155e5abcb415acd347b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page