docs/Reference_Manual_EflowStats.md

Vignettes

Function Reference

September 22, 2023

DESCRIPTION

Package: EflowStats
Type: Package
Title: Hydrologic Indicator and Alteration Stats
Version: 5.2.0
Date: 2017-08-04
Authors@R: c( person("Joe", "Mills", role = c("aut"),
    email = "jmills@ucar.edu"),
              person("David", "Blodgett", role = c("aut","cre"),
    email = "dblodgett@usgs.gov"),
              person("Jared", "Smith", role = c("aut"),
    email = "jsmith@usgs.gov"),
              person("Jens", "Kiesel", role = c("ctb"),
    email = "jkiesel@hydrology.uni-kiel.de")
    )
Depends:
    R (>= 3.3)
Imports:
    lmom,
    dplyr,
    lubridate,
    RcppRoll,
    imputeTS
Suggests:
    xtable,
    knitr,
    testthat,
    rmarkdown,
    DT,
    dataRetrieval,
    readr
Description: A reimplementation of the Hydrologic Index Tool 
        (HIT; Henriksen et al, 2006) for calculating 171 hydrologic indices 
        for stream classification analysis. EflowStats also calculates 7 
        additional statistics used for streamflow classification reffered 
        to as the "Magnificent Seven" (MAG7, Archfield et al., 2013). 
        Unlike the original HIT, EflowStats has been redesigned to injest 
        general hydrologic timeseries data and is not restricted to data 
        formats used by the USGS National Water Information System.
License: CC0
LazyLoad: yes
LazyData: yes
VignetteBuilder: knitr
BuildVignettes: true
Copyright: This software is in the public domain because it contains materials
    that originally came from the United States Geological Survey, an agency of
    the United States Department of Interior. For more information, see the
    official USGS copyright policy at
    http://www.usgs.gov/visual-id/credit_usgs.html#copyright
RoxygenNote: 7.2.3
Encoding: UTF-8

calc_allHIT

Function to calculate all 171 biologically relevant hydrologic indice statistics described in the USGS Hydrologic Index Tool

Description

Function to calculate all 171 biologically relevant hydrologic indice statistics described in the USGS Hydrologic Index Tool

Usage

calc_allHIT(
  x,
  yearType = "water",
  wyMonth = 10L,
  stats = "all",
  digits = 3,
  pref = "mean",
  drainArea = NULL,
  floodThreshold = NULL
)

Arguments

Argument |Description ------------- |---------------- x | A dataframe containing a vector of date values in the first column and vector of numeric flow values in the second column. yearType | A character of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth. stats | Character vector statistic groups. Choices are "all","calc_magAverage", "calc_magLow", "calc_magHigh", "calc_frequencyLow", "calc_frequencyHigh", "calc_durationLow", "calc_durationHigh", "calc_timingAverage", "calc_timingLow", "calc_timingHigh", "calc_rateChange" digits | A numeric. Number of digits to round indice values pref | A character of either "mean" or "median", indicating whether to use mean or median. See details. drainArea | Numeric drainage area. Only required for some statistics. Typically units of square miles, see details of specific statistics for more. floodThreshold | Numeric flood threshold as the flow equivalent for a flood recurrence of 1.67 years

Details

This function is a wrapper for the lower level functions to calculate groups of indice statistics. Desired groups of indices can be specified using the stats argument. Different arguments are required depending on indices selected and are described below. Detailed descriptions of the indices and pref argument behavior are provided in the documentation for individual indice group functions

Examples

x <- sampleData[c("date","discharge")]
calc_allHIT(x=x,yearType="water",stats="all",pref="mean",drainArea=50)

calc_ar1

calc_ar1 correlation coefficient

Description

Function to compute the AR(1) correlation coefficient for a given timeseries of discharge

This function accepts a data frame containing daily streamflow data and returns the AR(1) correlation coefficient

Usage

calc_ar1(x, yearType = "water", wyMonth = 10L, digits = 3)

Arguments

Argument |Description ------------- |---------------- x | A dataframe containing a vector of date values in the first column and vector of numeric flow values in the second column. yearType | A character of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth. digits | A numeric. Number of digits to round indice values

Value

calc_ar1 AR(1) correlation coefficient

Examples

x <- sampleData[c("date","discharge")]
calc_ar1(x)

calc_bfi

Function to return the base flow index for a given data frame

Description

This function accepts a vector of daily mean discharge values and calculates the base flow index of the daily flow values for the entire record

Usage

calc_bfi(x)

Arguments

Argument |Description ------------- |---------------- x | A numeric vector of consecutive daily mean discharge values

Details

The mean for a 7 day right-aligned moving window is calculated for the supplied flow vector. The baseflow index is calculated as the minimum 7day average flow divided by the mean flow

Value

calc_bfi numeric value of the base flow index for the given data frame

Examples

x<-sampleData$discharge
calc_bfi(x)

calc_durationHigh

Indices describing duration of high flow events.

Description

Calculates 24 indices used to describe the duration of high flow conditions. See Table X in the EflowStats package vignette for a full description of indices.

Usage

calc_durationHigh(
  x,
  yearType = "water",
  wyMonth = 10L,
  digits = 3,
  pref = "mean",
  floodThreshold = NULL,
  ...
)

Arguments

Argument |Description ------------- |---------------- x | A dataframe containing a vector of date values in the first column and vector of numeric flow values in the second column. yearType | A character of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth. digits | A numeric. Number of digits to round indice values pref | A character of either "mean" or "median", indicating whether to use mean or median. See details. floodThreshold | Numeric value of flood threshold as the flow equivalent for a flood recurrence of 1.67 years. Can be calculated using the get_peakThreshold function. ... | Optional arguments needed for calc_allHIT function

Details

Descriptions of indices.

Value

A data.frame of flow statistics

Examples

x <- sampleData[c("date","discharge")]
yearType = "water"
calc_durationHigh(x=x,yearType=yearType)

calc_durationLow

Indices describing duration of low flow events.

Description

Calculates 24 indices used to describe the duration of low flow conditions. See Table X in the EflowStats package vignette for a full description of indices.

Usage

calc_durationLow(
  x,
  yearType = "water",
  wyMonth = 10L,
  digits = 3,
  pref = "mean",
  ...
)

Arguments

Argument |Description ------------- |---------------- x | A dataframe containing a vector of date values in the first column and vector of numeric flow values in the second column. yearType | A character of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth. digits | A numeric. Number of digits to round indice values pref | A character of either "mean" or "median", indicating whether to use mean or median. See details. ... | Optional arguments needed for calc_allHIT function

Details

Descriptions of indices.

Value

A data.frame of flow statistics

Examples

x <- sampleData[c("date","discharge")]
yearType = "water"
calc_durationLow(x=x,yearType=yearType)

calc_frequencyHigh

Indices describing frequency of high flow events.

Description

Calculates 11 indices used to describe the frequency of high flow conditions. See Table X in the EflowStats package vignette for a full description of indices.

Usage

calc_frequencyHigh(
  x,
  yearType = "water",
  wyMonth = 10L,
  digits = 3,
  pref = "mean",
  floodThreshold = NULL,
  ...
)

Arguments

Argument |Description ------------- |---------------- x | A dataframe containing a vector of date values in the first column and vector of numeric flow values in the second column. yearType | A character of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth. digits | A numeric. Number of digits to round indice values pref | A character of either "mean" or "median", indicating whether to use mean or median. See details. floodThreshold | Numeric flood threshold as the flow equivalent for a flood recurrence of 1.67 years ... | Optional arguments needed for calc_allHIT function

Details

Descriptions of indices.

Value

A data.frame of flow statistics

Examples

x <- sampleData[c("date","discharge")]
yearType = "water"
floodThreshold = 1158
calc_frequencyHigh(x=x,yearType=yearType,floodThreshold = 1158)

calc_frequencyLow

Indices describing frequency of low flow events.

Description

Calculates 3 indices used to describe the frequency of low flow conditions. See Table X in the EflowStats package vignette for a full description of indices.

Usage

calc_frequencyLow(
  x,
  yearType = "water",
  wyMonth = 10L,
  digits = 3,
  pref = "mean",
  ...
)

Arguments

Argument |Description ------------- |---------------- x | A dataframe containing a vector of date values in the first column and vector of numeric flow values in the second column. yearType | A character of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth. digits | A numeric. Number of digits to round indice values pref | A character of either "mean" or "median", indicating whether to use mean or median. See details. ... | Optional arguments needed for calc_allHIT function

Details

Descriptions of indices.

Value

A data.frame of flow statistics

Examples

x <- sampleData[c("date","discharge")]
yearType = "water"
calc_frequencyLow(x=x,yearType=yearType)

calc_magAverage

Indices describing magnitude of the average flow condition.

Description

Calculates 45 indices used to describe the magnitude of the average flow condition. See Table X in the EflowStats package vignette for a full description of indices.

Usage

calc_magAverage(
  x,
  yearType = "water",
  wyMonth = 10L,
  digits = 3,
  drainArea = NULL,
  pref = "mean",
  ...
)

Arguments

Argument |Description ------------- |---------------- x | A dataframe containing a vector of date values in the first column and vector of numeric flow values in the second column. yearType | A charcter of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth. digits | A numeric. Number of digits to round indice values drainArea | A numeric specifying the drainage area. Only required for ma41 statistic. Typically square miles, see details. pref | A character of either "mean" or "median", indicating whether to use mean or median. See details. ... | Optional arguments needed for calc_allHIT function

Details

Descriptions of indices.

Value

A data.frame flow statistics

Examples

x <- sampleData[c("date","discharge")]
drainArea <- 50
yearType = "water"
calc_magAverage(x=x,yearType=yearType,drainArea=drainArea)

calc_magHigh

Indices describing magnitude of the peak flow condition.

Description

Calculates 27 indices used to describe the magnitude of the peak flow condition. See Table X in the EflowStats package vignette for a full description of indices.

Usage

calc_magHigh(
  x,
  yearType = "water",
  wyMonth = 10L,
  digits = 3,
  drainArea = NULL,
  pref = "mean",
  ...
)

Arguments

Argument |Description ------------- |---------------- x | A dataframe containing a vector of date values in the first column and vector of numeric flow values in the second column. yearType | A charcter of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth. digits | A numeric. Number of digits to round indice values drainArea | A numeric specifying the drainage area. Only required for mh20 statistic. Typically squiare miles, see details. pref | A character of either "mean" or "median", indicating whether to use mean or median. See details. ... | Optional arguments needed for calc_allHIT function

Details

Descriptions of indices.

Value

A data.frame of flow statistics

Examples

x <- sampleData[c("date","discharge")]
drainArea <- 50
yearType = "water"
calc_magHigh(x=x,yearType=yearType,drainArea=drainArea)

calc_magLow

Indices describing magnitude of the low flow condition.

Description

Calculates 27 indices used to describe the magnitude of the peak flow condition. See Table X in the EflowStats package vignette for a full description of indices.

Usage

calc_magLow(
  x,
  yearType = "water",
  wyMonth = 10L,
  digits = 3,
  drainArea = NULL,
  pref = "mean",
  ...
)

Arguments

Argument |Description ------------- |---------------- x | A dataframe containing a vector of date values in the first column and vector of numeric flow values in the second column. yearType | A character of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth. digits | A numeric. Number of digits to round indice values drainArea | A numeric specifying the drainage area. Only required for ml22 statistic. Typically squiare miles, see details. pref | A character of either "mean" or "median", indicating whether to use mean or median. See details. ... | Optional arguments needed for calc_allHIT function

Details

Descriptions of indices.

Value

A data.frame of flow statistics

Examples

x <- sampleData[c("date","discharge")]
drainArea <- 50
yearType = "water"
calc_magLow(x=x,yearType=yearType,drainArea=drainArea)

calc_magnifSeven

Function to return the magnificent seven statistics for a given data series

Description

Function to return the magnificent seven statistics for a given data series

Usage

calc_magnifSeven(x, yearType = "water", wyMonth = 10L, digits = 3)

Arguments

Argument |Description ------------- |---------------- x | A dataframe containing a vector of date values in the first column and vector of numeric flow values in the second column. yearType | A charcter of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth. digits | A numeric. Number of digits to round indice values

Details

This is a function to compute the 7 statistics of daily streamflow used by Archfield et al., under revision (June 2013).

Value

data.frame of calculated statistics

Examples

x<-sampleData[c("date","discharge")]
magSeven <- calc_magnifSeven(x)

calc_rateChange

Indices describing rate of change of flow.

Description

Calculates 9 indices used to describe the rate of change of flow conditions. See Table X in the EflowStats package vignette for a full description of indices.

Usage

calc_rateChange(
  x,
  yearType = "water",
  wyMonth = 10L,
  digits = 3,
  pref = "mean",
  ...
)

Arguments

Argument |Description ------------- |---------------- x | A dataframe containing a vector of date values in the first column and vector of numeric flow values in the second column. yearType | A charcter of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth. digits | A numeric. Number of digits to round indice values pref | A character of either "mean" or "median", indicating whether to use mean or median. See details. ... | Optional arguments needed for calc_allHIT function

Details

Descriptions of indices.

Value

A data.frame of flow statistics

Examples

x <- sampleData[c("date","discharge")]
yearType = "water"
calc_rateChange(x=x,yearType=yearType)

calc_timingAverage

Indices describing timing of average flow events.

Description

Calculates 3 indices used to describe the timing of average flow conditions. See Table X in the EflowStats package vignette for a full description of indices.

Usage

calc_timingAverage(
  x,
  yearType = "water",
  wyMonth = 10L,
  digits = 3,
  pref = "mean",
  floodThreshold = NULL,
  ...
)

Arguments

Argument |Description ------------- |---------------- x | A dataframe containing a vector of date values in the first column and vector of numeric flow values in the second column. yearType | A charcter of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth. digits | A numeric. Number of digits to round indice values pref | A character of either "mean" or "median", indicating whether to use mean or median. See details. floodThreshold | Numeric flood threshold as the flow equivalent for a flood recurrence of 1.67 years ... | Optional arguments needed for calc_allHIT function

Details

Descriptions of indices.

Value

A data.frame of flow statistics

Examples

x <- sampleData[c("date","discharge")]
yearType = "water"
floodThreshold = 1158
calc_timingAverage(x=x,yearType = yearType,floodThreshold =floodThreshold)

calc_timingHigh

Indices describing timing of high flow events.

Description

Calculates 3 indices used to describe the timing of high flow conditions. See Table X in the EflowStats package vignette for a full description of indices.

Usage

calc_timingHigh(
  x,
  yearType = "water",
  wyMonth = 10L,
  digits = 3,
  pref = "mean",
  floodThreshold = NULL,
  ...
)

Arguments

Argument |Description ------------- |---------------- x | A dataframe containing a vector of date values in the first column and vector of numeric flow values in the second column. yearType | A charcter of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth. digits | A numeric. Number of digits to round indice values pref | A character of either "mean" or "median", indicating whether to use mean or median. See details. floodThreshold | Numeric flood threshold as the flow equivalent for a flood recurrence of 1.67 years ... | Optional arguments needed for calc_allHIT function

Details

Descriptions of indices.

Value

A data.frame of flow statistics

Examples

x <- sampleData[c("date","discharge")]
yearType = "water"
floodThreshold = 1158
calc_timingHigh(x=x,yearType=yearType,floodThreshold=floodThreshold)

calc_timingLow

Indices describing timing of low flow events.

Description

Calculates 3 indices used to describe the timing of high flow conditions. See Table X in the EflowStats package vignette for a full description of indices.

Usage

calc_timingLow(
  x,
  yearType = "water",
  wyMonth = 10L,
  digits = 3,
  pref = "mean",
  floodThreshold = NULL,
  ...
)

Arguments

Argument |Description ------------- |---------------- x | A dataframe containing a vector of date values in the first column and vector of numeric flow values in the second column. yearType | A charcter of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth. digits | A numeric. Number of digits to round indice values pref | A character of either "mean" or "median", indicating whether to use mean or median. See details. floodThreshold | Numeric flood threshold as the flow equivalent for a flood recurrence of 1.67 years ... | Optional arguments needed for calc_allHIT function

Details

Descriptions of indices.

Value

A data.frame of flow statistics

Examples

x <- sampleData[c("date","discharge")]
yearType = "water"
floodThreshold = 1161.38
calc_timingLow(x=x,yearType=yearType,floodThreshold=floodThreshold)

cut_dataToWaterYear

Cuts the discharge time series to full water years

Description

Cuts the discharge time series to full water years

Usage

cut_dataToWaterYear(x, yearType, wyMonth = 10L)

Arguments

Argument |Description ------------- |---------------- x | data.frame containing a vector of date values in the first column and vector of numeric flow values in the second column. yearType | A character of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth.

Details

To ensure the input data is valid for use with other EflowStats functions. #'

Value

data.frame in original structure, but cut to full water years

Examples

x <- sampleData[, c('date', 'discharge')]
cut_dataToWaterYear(x,10L)

find_changeEvents

Function to decompose a flow series into flow direction change events

Description

Function to decompose a flow series into flow direction change events

Usage

find_changeEvents(x)

Arguments

Argument |Description ------------- |---------------- x | A vector of flow values, should be sorted chronologically.

Details

This function accepts a vector of flow values, tests if each value in the flow vector is greater or less than the preceding value of flow, and classifies the flow vector into events. An event is defined as when a change in flow from one day to the next changes direction, e.g. rising limb to falling limb. If there is no change in flow from one day to the next it is considered part of the preceding event. If there is no change in flow for the whole timeseries, the timeseries is assigned event 0.

Value

A dataframe with columns "flow" and "event"

Examples

x <- sampleData$discharge
find_changeEvents(x)

find_eventDuration

Function to decompose a flow series into high flow events defined as flows above a given threshold.

Description

This function accepts a vector of flow values, tests if each value in the flow vector is above or below a defined threshold, classifies the flow vector into events, and returns the average event duration or all event durations if average = FALSE. An event is defined as consecutive entries above the given threshold.

Usage

find_eventDuration(
  x,
  threshold,
  aggType = "average",
  type = "high",
  pref = "mean",
  trim = FALSE
)

Arguments

Argument |Description ------------- |---------------- x | A vector of numeric flow values threshold | Numeric threshold value for high flow events aggType | Character vector indicating type of aggregation to use, if any. Choices are "average", "min", "max" or "none". If "average", mean or median of events is returned depending on "pref" setting If "none", returns the duration for each individual event type | Character of either "high" or "low" indicating if events are defined as flows below or above the given threshold, respectively pref | A character of either "mean" or "median", indicating whether to use mean or median. See details. trim | Logical. Events that start or end at the beginning or end of the record are dropped if TRUE because an accurate duration can't be calculated if teh start or end time is unknown.

Value

A numeric of the mean event duration in units of number of rows if average = TRUE. Otherwise, returns a datafarme of durations for each event.

Examples

x <- sampleData$discharge
threshold <- median(x,na.rm=TRUE)
find_eventDuration(x,threshold)

find_events

Function to decompose a flow series into high or low flow events.

Description

This function accepts a vector of flow values, tests if each value in the flow vector is above or below a defined threshold, and classifies the flow vector into events. An event is defined as consecutive values above or below the given threshold.

Usage

find_events(x, threshold, type = "high")

Arguments

Argument |Description ------------- |---------------- x | A numeric vector of flow values threshold | Numeric threshold value defining event type | character indicating type of event. High flags events above threshold, low flags events below threshold.

Value

A dataframe with columns "flow" and "event"

Examples

x <- sampleData$discharge
threshold <- median(x,na.rm=TRUE)
find_events(x,threshold)

get_peakThreshold

Function to return a specified flood threshold

Description

This function calculates flood thresholds for specified recurrence intervals.

Usage

get_peakThreshold(x, peakValues, perc = 0.6, yearType = "water", wyMonth = 10L)

Arguments

Argument |Description ------------- |---------------- x | A dataframe containing a vector of date values in the first column and vector of numeric flow values in the second column. peakValues | A dataframe containing a vector of date values in the first column and vector of numeric annual peak flow values in the second column. perc | value containing the desired percentile to be calculated yearType | A charcter of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth.

Details

Compute the log10 of the daily flows for the peak annual flow days. Calculate the coefficients for a linear regression equation for logs of peak annual flow versus logs of average daily flow for peak days. Using the log peak flow for the 1.67-year recurrence interval (60th percentile, perc=0.6 ) as input to the regression equation, predict the log10 of the average daily flow. The threshold is 10 to the log10 (average daily flow) power (cubic feet per second). for the 5-year recurrence interval (80th percentile, perc=0.8 ), used by indices TL3 and TL4, follow the same process, inputing a different 'perc' value.

Value

thresh numeric containing the flood threshold for recurence interval specified by perc

Examples

library(dataRetrieval)
x <- sampleData[c("date","discharge")]
sites<-"02178400"
peakValues <- readNWISpeak(sites)
peakValues <- peakValues[c("peak_dt","peak_va")]
get_peakThreshold(x,peakValues,.6,yearType="water")

get_seasonality

Function to compute the seasonal factors (amplitude and phase) for a given data series

Description

This function accepts a data frame containing daily streamflow data, then computes get_seasonality variables by first standardizing flows, the fitting relation Acos(2pit) + Bsin(2pit)1) Get decimal yearand returns the amplitude and phase

Usage

get_seasonality(x, yearType = "water", wyMonth = 10L)

Arguments

Argument |Description ------------- |---------------- x | A dataframe containing a vector of date values in the first column and vector of numeric flow values in the second column. yearType | A charcter of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth.

Value

get_seasonality vector of seasonal factors (amplitude and phase)

Examples

x <- sampleData[c("date","discharge")]
get_seasonality(x=x)

get_waterYear

Function to return the water year for a given date

Description

Function to return the water year for a given date

Usage

get_waterYear(x, wyMonth = 10L, numeric = TRUE)

Arguments

Argument |Description ------------- |---------------- x | A date vector wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth. numeric | Logical. Return values are numeric vector or vector of ordered factors

Value

A vector of numeric water years for each date if numeric = TRUE otherwise an ordered factor of water years if numeric = FALSE

Examples

get_waterYear(sampleData$date)

get_waterYearDay

Day of water year

Description

Given a vector of dates, calculates day of water year accounting for leap years.

Usage

get_waterYearDay(x, wyMonth = 10L)

Arguments

Argument |Description ------------- |---------------- x | A vector of class date. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth.

Value

A numeric vector of day of water year

Examples

x <- seq(from=as.Date("2010-01-01"),to=as.Date("2016-01-01"),by="1 days")
year_day <- get_waterYearDay(x, 2L)

sampleData

Sample Streamflow data.frame

Description

A dataset with a few years of complete water year based data.

Format

A data frame with 731 rows and 7 variables: list("\n", " ", list(list("wy_val"), list("integer of the water year")), "\n", " ", list(list("date"), list("Date of the complete day")), "\n", " ", list(list("discharge"), list("Discharge values")), "\n", " ", list(list("month_val"), list("integer month value")), "\n", " ", list(list("year_val"), list("integer year value")), "\n", " ", list(list("day_val"), list("integer day value")), "\n", " ", list(list("jul_val"), list("day of year")), "\n")

validate_data

validate_data Discharge timeseries screening

Description

Function to check dataframe inputs for appropriate data classes and screen for missing values.

Usage

validate_data(x, yearType, wyMonth = 10L)

Arguments

Argument |Description ------------- |---------------- x | A dataframe containing a vector of date values in the first column and vector of numeric flow values in the second column. yearType | A character of either "water" or "calendar" indicating whether to use water years or calendar years, respectively. wyMonth | A numeric. The month of the year in which the water year starts (1=January, 12=December). The water year begins on the first day of wyMonth.

Details

Checks performed ensure the data is valid for use with other EflowStats functions. #'

Value

data.frame with rows sorted by date. Boolean FALSE if data is not found to be valid. (See details)

Examples

x <- sampleData[c("date","discharge")]
yearType = "water"
validate_data(x=x,yearType=yearType)


USGS-R/EflowStats documentation built on Sept. 30, 2023, 9:31 p.m.