tsgettoolbox.tsgettoolbox.nwis_stat

tsgettoolbox.tsgettoolbox.nwis_stat(sites=None, parameterCd=None, period=None, startDT=None, endDT=None, siteType=None, modifiedSince=None, agencyCd=None, siteStatus=None, altMin=None, altMax=None, drainAreaMin=None, drainAreaMax=None, aquiferCd=None, localAquiferCd=None, wellDepthMin=None, wellDepthMax=None, holeDepthMin=None, holeDepthMax=None, statReportType=None, statType=None, missingData=None, statYearType=None)

US:station:::USGS NWIS Statistic

Detailed documentation is available at http://waterdata.usgs.gov/nwis.

Site local time is output, even if multiple sites are requested and sites are in different time zones. Note that the measurement time zone at a site may not be the same as the time zone actually in effect at the site.

Every query requires a major filter. Pick the major filter (’–sites’, ‘–stateCd’, ‘–huc’, ‘–bBox’, ‘–countyCd’) that best retrieves the data for the sites that you are interested in. You can have only one major filter per query. If you specify more than one major filter, you will get an error.

Major Filter

Select ONE of:

'--sites',
'--stateCd',
'--huc',
'--bBox', or
'--countyCd'

Minor Filters

Additional filters can be applied after specifying a major filter. This further reduces the set of expected results. Users are encouraged to use minor filters because it allows more efficient use of this service.

Use as many as desired to limit number of retrieved time series:

'--agencyCd',
'--altMax',
'--altMin',
'--aquiferCd',
'--drainAreaMax',
'--drainAreaMin',
'--holeDepthMax'
'--holeDepthMin',
'--localAquiferCd',
'--modifiedSince',
'--parameterCd',
'--siteStatus',
'--siteType',
'--wellDepthMax',
'--wellDepthMin',

Returns

This returns a pandas DataFrame if using the Python API, or a text table to standard out if using the command line interface. Both will have columns named according to the following table.

Column Name

statReportType

Description

agency_cd

all

Agency code

site_no

all

Site identification number

parameter_cd

all

Parameter code

station_nm

all

Site name

loc_web_ds

all

Additional measurement description

year_nu

monthly annual

The year for which the statistics apply.

month_nu

monthly daily

The month for which the statistics apply.

day_nu

daily

The day for which the statistics apply.

begin_yr

daily

First water year of data of daily mean values for this day.

end_yr

daily

Last water year of data of daily mean values for this day.

count_nu

all

Number of values used in the calculation.

max_va_yr

daily

Water year in which the maximum value occurred.

max_va

daily

Maximum of daily mean values for this day.

min_va_yr

daily

Water year in which the minimum value occurred.

min_va

daily

Minimum of daily mean values for this day.

mean_va

all

Mean of daily mean values for this day.

p05_va

daily

05 percentile of daily mean values for this day.

p10_va

daily

10 percentile of daily mean values for this day.

p20_va

daily

20 percentile of daily mean values for this day.

p25_va

daily

25 percentile of daily mean values for this day.

p50_va

daily

50 percentile (median) of daily mean values for this day.

p75_va

daily

75 percentile of daily mean values for this day.

p80_va

daily

80 percentile of daily mean values for this day.

p90_va

daily

90 percentile of daily mean values for this day.

p95_va

daily

95 percentile of daily mean values for this day.

Parameters:
  • sites (str) –

    [optional, default is None, major site filter]

    Want to only query one site? Use sites as your major filter, and put only one site number in the list. Sites are comma separated. Sites may be prefixed with an optional agency code followed by a colon. If you do not know the site numbers you need, you can find relevant sites with the NWIS Mapper (http://wdr.water.usgs.gov/nwisgmap/index.html) or on the USGS Water Data for the Nation site. (http://waterdata.usgs.gov/nwis/)

    Can have from 1 to 100 comma separated site numbers:

    --sites=USGS:01646500
    --sites=01646500,06306300
    

  • agencyCd

    [optional, default is None, minor site filter]

    The list of sites returned are filtered to return only those with the provided agency code. The agency code describes the organization that maintains the site. Only one agency code is allowed and is optional. An authoritative list of agency codes can be found here. Default is to return all sites regardless of agency code. List: http://help.waterdata.usgs.gov/code/agency_cd_query?fmt=html:

    --stateCd=il --agencyCd=USCE # Only US Army Corps
                                 # of Engineers sites
                                 # in Illinois
    

  • altMin (float) –

    [optional, default is None, minor site filter]

    These arguments allows you to select instantaneous values sites where the associated sites’ altitude are within a desired altitude, expressed in feet. Altitude is based on the datum used at the site. Providing a value to altMin (minimum altitude) means you want sites that have or exceed the altMin value. You may specify decimal feet if precision is critical If both the altMin and altMax are specified, sites at or between the minimum and maximum altitude are returned.

  • altMax (float) –

    [optional, default is None, minor site filter]

    Providing a value to altMax (maximum altitude) means you want sites that have or are less than the altMax value.:

    --altMin=1000 --altMax=5000
          # Return sites where the altitude is 1000 feet or
          # greater and 5000 feet or less.
    --altMin=12.5 --altMax=13
          # Return sites where the altitude is 12.5 feet or
          # greater and 13 feet or less.
    

  • aquiferCd

    [optional, default is None, minor site filter]

    Used to filter sites to those that exist in specified national aquifers. Note: not all sites have been associated with national aquifers. Enter one or more national aquifer codes, separated by commas. A national aquifer code is exactly 10 characters. You can have up to 1000 aquiferCd codes. Complete list: http://water.usgs.gov/ogw/NatlAqCode-reflist.html:

    --aquiferCd=S500EDRTRN,N100HGHPLN
                          # returns groundwater sites for the
                          # Edwards-Trinity aquifer system and
                          # the High Plains national
                          # aquifers.
    

  • endDT

    [optional, default is None]

    If endDT is present, startDt must also be present.:

    --startDT=2010-11-22 --endDT=2010-11-22  # Full day, 00:00 to 23:59
    --startDT=2010-11-22T12:00 --endDT=2010-11-22T18:00
    --startDT=2010-11-22 --endDT=2010-11-22
    --startDT=2010-11-22T12:00  # From "startDT" to most recent
                                # instantaneous value
    

  • localAquiferCd

    [optional, default is None, minor site filter]

    Used to filter sites to those that exist in specified local aquifers. Note: not all sites have been associated with local aquifers. Enter one or more local aquifer codes, separated by commas. A local aquifer code begins with a 2 character state abbreviation (such as TX for Texas) followed by a colon followed by the 7 character aquifer code. Can have 0 to 1000 comma delimited codes. Complete list: http://help.waterdata.usgs.gov/code/aqfr_cd_query?fmt=html To translate state codes associated with the local aquifer you may need this reference: http://www.itl.nist.gov/fipspubs/fip5-2.htm

    --localAquiferCd=AL:111RGLT,AL:111RSDM
            # returns sites for the Regolith and Saprolite local
            # aquifers in Alabama
    

  • modifiedSince

    [optional, default is None, minor site filter]

    Returns all values for sites and period of record requested only if any values have changed over the last modifiedSince period. modifiedSince is useful if you periodically need to poll a site but are only interested in getting data if some of it has changed. It is typically be used with period, or startDT/endDT but does not have to be. In the latter case, if any values were changed during the specified modifiedSince period, only the most recent values would be retrieved for those sites. This is a typical usage, since users typically are polling a site and only want data if there are new or changed measurements. ISO-8601 duration format is always used. There is no default. (http://en.wikipedia.org/wiki/ISO_8601#Durations):

    --modifiedSince=PT2H
           # Retrieves all values for sites and period of record
           # requested for any of the requested sites and
           # parameters, but only for sites where any of the
           # values changed during the last two hours.
    --modifiedSince=PT2H --period=P1D
           # Retrieve all values for sites and period of record
           # requested for the last 24 hours from now only for
           # sites and parameters that had any values that
           # changed or were added during the last two hours.
    --modifiedSince=PT2H --startDt=2010-11-01 --endDt=2010-11-02
           # Retrieve all values for sites and period of record
           # requested for sites and parameters that had values
           # change between midnight site local time on Nov 1st,
           # 2010 and 23:59 on Nov 2nd, 2010 site local time,
           # only if values were changed or added within the
           # last two hours.
    

  • parameterCd

    [optional, default is None, minor site filter]

    USGS time-series parameter code. All parameter codes are numeric and 5 characters in length. Parameter codes are used to identify the constituent measured and the units of measure. Popular codes include stage (00065), discharge in cubic feet per second (00060) and water temperature in degrees Celsius (00010). Can request from 1 to 100 “parameterCD”s. Default: returns all regular time-series for the requested sites.

    Complete list:

    http://help.waterdata.usgs.gov/codes-and-parameters/parameters::
    
    --parameterCd=00060       # discharge, cubic feet
                              # per second
    --parameterCd=00060,00065 # discharge,
                              # cubic feet per second
                              # and gage height in
                              # feet
    

  • period

    [optional, default is None]

    Get a range of values from now by specifying the period argument period must be in ISO-8601 Duration format. (http://en.wikipedia.org/wiki/ISO_8601#Durations) Negative periods (ex: P-T2H) are not allowed. Data are always returned up to the most recent value, which in the case of a predictive gage might be in the future. When specifying days from now, the first value will probably not be at midnight of the first day, but somewhat before exactly 24 hours from now.:

    --period=PT2H
          # Retrieve last two hours from now up to most recent
          # instantaneous value)
    --period=P7D
          # Retrieve last seven days up from now to most recent
          # instantaneous value)
    

  • siteStatus

    [optional, default is None, minor site filter]

    Selects sites based on whether or not they are active. If a site is active, it implies that it is being actively maintained. A site is considered active if: it has collected time-series (automated) data within the last 183 days (6 months), or it has collected discrete (manually collected) data within 397 days (13 months) If it does not meet these criteria, it is considered inactive. Some exceptions apply. If a site is flagged by a USGS water science center as discontinued, it will show as inactive. A USGS science center can also flag a new site as active even if it has not collected any data. The default is all (show both active and inactive sites). Chose between, ‘all’, ‘active’, or ‘inactive’. Default all - sites of any activity status are returned.:

    --siteStatus='active'
    

  • siteType

    [optional, default is None, minor site filter]

    Restricts sites to those having one or more major and/or minor site types. If you request a major site type (ex: &siteType=ST) you will get all sub-site types of the same major type as well (in this case, ST-CA, ST-DCH and ST-TS). Can have from 1 to an unlimited number of siteType codes. Default is to return all types. List of valid site types: http://help.waterdata.usgs.gov/site_tp_cd:

    --siteType=ST       # Streams only
    --siteType=ST,LA-OU # Streams and Land Outcrops only
    

  • startDT

    [optional, default is None]

    Get a range of values from an explicit begin or end date/time. Use the startDT and endDT arguments. Site local time is output, even if multiple sites are requested and sites are in different time zones. Note that the measurement time zone at a site may not be the same as the time zone actually in effect at the site.

    Both startDt and endDt must be in ISO-8601 Date/Time format. (http://en.wikipedia.org/wiki/ISO_8601#Dates) You can express the date and time in a timezone other than site local time if you want as long as it follows the ISO standard. For example, you can express the time in Universal time: 2014-03-20T00:00Z. If startDT is supplied and endDT is not, endDT ends with the most recent instantaneous value. startDT must be chronologically before endDT.

    If startDt shows the date and not the time of day (ex: 2010-09-01) the time of midnight site time is assumed (2010-09-01T00:00) If endDt shows the date and not the time of day (ex: 2010-09-02) the last minute before midnight site time is assumed (2010-09-02T23:59). Remember, only data from October 1, 2007 are currently available in the ‘iv’ database.

  • drainAreaMin (float) –

    [optional, default is None, minor site filter]

    SURFACE WATER SITE ATTRIBUTE

    These arguments allows you to select principally surface water sites where the associated sites’ drainage areas (watersheds) are within a desired size, expressed in square miles or decimal fractions thereof. Providing a value to drainAreaMin (minimum drainage area) means you want sites that have or exceed the drainAreaMin value. The values may be expressed in decimals. If both the drainAreaMin and drainAreaMax are specified, sites at or between the minimum and maximum drainage areas values specified are returned Caution: not all sites are associated with a drainage area. Caution: drainage area generally only applies to surface water sites. Use with other site types, such as groundwater sites, will likely retrieve no results.

  • drainAreaMax (float) –

    [optional, default is None, minor site filter]

    SURFACE WATER SITE ATTRIBUTE

    Providing a value to drainAreaMax (maximum drainage area) means you want sites that have or are less than the drainAreaMax value.:

    --drainAreaMin=1000 --drainAreaMax=5000
                         # Return sites where the drainage area
                         # is 1000 square miles or greater and
                         # is 5000 square miles or less.
    --drainAreaMin=10.5 --drainAreaMax=10.7
                         # Return sites where the drainage area
                         # is 10.5 square miles or greater and
                         # is 10.7 square miles or less.
    

  • holeDepthMin (float) –

    [optional, default is None, minor site filter]

    GROUNDWATER SITE ATTRIBUTE

    These arguments allows you to select groundwater sites serving data recorded automatically where the associated sites’ hole depth are within a desired depth, expressed in feet from the land surface datum. Express hole depth as a positive number. Providing a value to holeDepthMin (minimum hole depth) means you want sites that have or exceed the holeDepthMin value. The values may be expressed in decimals Caution: hole depth applies to groundwater sites only.

  • holeDepthMax (float) –

    [optional, default is None, minor site filter]

    GROUNDWATER SITE ATTRIBUTE

    Providing a value to holeDepthMax (maximum hole depth) means you want sites that have or are less than the holeDepthMax value.:

    --holeDepthMin=100 --holeDepthMax=500
            # Return daily values sites where the hole depth is
            # 100 feet or greater and 500 feet or less.
    
    --holeDepthMin=10.5 --holeDepthMax=10.7
            # Return daily value sites where the hole depth is
            # 10.5 feet or greater and 10.7 feet or less.
    

    If both the holeDepthMin and holeDepthMax are specified, sites at or between the minimum and maximum hole depth values specified are returned holeDepthMax should be greater than or equal to holeDepthMin.

  • wellDepthMin (float) –

    [optional, default is None, minor site filter]

    GROUNDWATER SITE ATTRIBUTE

    These arguments allows you to select groundwater sites serving data recorded automatically where the associated sites’ well depth are within a desired depth, expressed in feet from the land surface datum. Express well depth as a positive number. Providing a value to wellDepthMin (minimum well depth) means you want sites that have or exceed the wellDepthMin value. The values may be expressed in decimals Caution: well depth applies to groundwater sites only.:

    --wellDepthMin=100 --wellDepthMax=500
            # Return daily value sites where the well depth is
            # 100 feet or greater and 500 feet or less.
    

  • wellDepthMax (float) –

    [optional, default is None, minor site filter]

    GROUNDWATER SITE ATTRIBUTE

    Providing a value to wellDepthMax (maximum well depth) means you want sites that have or are less than the wellDepthMax value.:

    --wellDepthMin=10.5 --wellDepthMax=10.7
            # Return daily value sites where the well depth is
            # 10.5 feet or greater and 10.7 feet or less.
    

    If both the wellDepthMin and wellDepthMax are specified, sites at or between the minimum and maximum well depth values specified are returned wellDepthMax should be greater than or equal to wellDepthMin.

  • statReportType (str) –

    [optional, default is ‘daily’]

    The type of statistics desired. Valid statistic report types include:

    statReportType

    Description

    daily

    daily statistics (default) statistic across years

    monthly

    monthly statistics (monthly time-series)

    annual

    annual statistics, based on either calendar year or water year, as defined by statYearType. If statYearType is not provided, calendar year statistics are assumed. (annual time-series)

  • statType (str) –

    [optional, default is None, minor site filter]

    Selects sites based on the statistics type(s) desired, such as minimum, maximum or mean

    For all statReportType types include:

    mean - arithmetic mean or average
    all - selects all available statistics
    

    For daily statistics you can also specify:

    min - minimum, or smallest value found for the
          daily statistics
    max - maximum, or largest value found for the
          daily statistics
    median - the numerical value separating the higher
             half of a the data from the lower half,
             same as specifying P50. If used median
             will be represented by the column name
             p50_va.
    P05, P10, P20, P25, P50, P75, P80, P90, P95
        with the number indicating percentile. Note:
        the service can calculate only these
        percentiles.
    

  • missingData

    [optional, default is None]

    Used to indicate the rules to follow to generate statistics if there are gaps in the period of record during the requested statistics period. By default if there are any missing data for the report type, the statistic is left blank or null.

    This option does not apply to daily statistics, but optionally can be used with monthly and yearly statistics. If used with daily statistics, an error will occur.

    Missing data can happen for various reasons including there was a technical problem with the gage for part of the time period.

    Enabling this switch will attempt to provide a statistic if there is enough data to create one.

    Choice is ‘off’ or ‘on’.

  • statYearType

    [optional, default is None]

    Indicates which kind of year statistics should be created against. This only applies when requesting annual statistics, i.e. statReportType=annual. Valid year types codes include:

    calendar

    calendar year, i.e. January 1 through December 31

    water

    water year, i.e. a year begins October 1 of the previous year and ends September 30 of the current year. This is the same as a federal fiscal year.