ewatercycle.observation.usgs module

ewatercycle.observation.usgs.get_usgs_data(station_id, start_date, end_date, parameter='00060', cache_dir=None)

Get river discharge data from the USGS REST web service.

See U.S. Geological Survey Water Services (USGS)

Parameters
  • station_id (str) – The station id to get

  • start_date (str) – String for start date in the format: ‘YYYY-MM-dd’, e.g. ‘1980-01-01’

  • end_date (str) – String for start date in the format: ‘YYYY-MM-dd’, e.g. ‘2018-12-31’

  • parameter (str) – The parameter code to get, e.g. (‘00060’) discharge, cubic feet per second

  • cache_dir (str) – Directory where files retrieved from the web service are cached. If set to None then USGS_DATA_HOME env var will be used as cache directory.

Examples

>>> from ewatercycle.observation.usgs import get_usgs_data
>>> data = get_usgs_data('03109500', '2000-01-01', '2000-12-31', cache_dir='.')
>>> data
    <xarray.Dataset>
    Dimensions:     (time: 8032)
    Coordinates:
      * time        (time) datetime64[ns] 2000-01-04T05:00:00 ... 2000-12-23T04:00:00
    Data variables:
        Streamflow  (time) float32 8.296758 10.420501 ... 10.647034 11.694747
    Attributes:
        title:      USGS Data from streamflow data
        station:    Little Beaver Creek near East Liverpool OH
        stationid:  03109500
        location:   (40.6758974, -80.5406244)