Learn R Programming

lfstat (version 0.9.4)

find_droughts: Identifying Low Flow Periods

Description

A streamflow deficit is defined as an event where discharges are below a given threshold.

Usage

find_droughts(x, threshold = vary_threshold, varying = "constant", ...)

Arguments

x
an object which can be coerced to class xts. Either with a single column or with a column named 'discharge'. Units of x are retrieved from the attributes. If it fails, an error is raised.
threshold
The threshold can either be a constant value, a time series with the same length as x or a function (taking a single argument) returning either of these. Furthermore threshold can be a character vector of length one specifying a quantile of x like threshold = 'Q80' as a shortcut of threshold = function(x) quantile(x, 0.2, na.rm = TRUE). See vary_threshold for varying a threshold in time.
varying
if varying is a character vector of length one, values of "constant", "daily", "weekly" and "monthly" are allowed. If a vector of class POSIX is provided, a seasonal varying threshold is computed, where the times provided define the start of the season. Only the day of the year is taken, the year itself doesn't have a meaning.
...
if threshold is a function, these additional arguments are passed on to the function

Value

an object of class 'deficit', which is basically an xts object with the columns an object of class 'deficit', which is basically an xts object with the columns

See Also

There are summary and plot methods, see summary.deficit and plot.deficit.

pooling, summary.deficit, plot.deficit

Examples

Run this code
data(ray)
ray <- as.xts(ray)["1970::1979", ]
r <- find_droughts(ray)
head(r)
summary(r)


plot(r)


# threshold is to low, because there are many days with
# zero flow observations
# provide threshold as a constant value
r <- find_droughts(ray, threshold = 0.02)
head(r)
summary(r)

plot(r)



# provide threshold as a function
r <- find_droughts(ray,
                   threshold = function(x) quantile(x, 0.2, na.rm = TRUE))
head(r)
summary(r)

Run the code above in your browser using DataLab