Learn R Programming

UKFE (version 0.2.2)

POTextract: Peaks over threshold (POT) data extraction

Description

Extracts independent peaks over a threshold from a sample

Usage

POTextract(x, div = NULL, thresh = 0.975, Plot = TRUE)

Value

Prints the number of peaks per year and returns a data.frame with columns; Date and peak, with the option of a plot. Or a numeric vector of peaks is returned if only a numeric vector of the hydrological variable is input.

Arguments

x

either a numeric vector or dataframe with date (or POSIXct) in the first column and hydrological variable in the second

div

user chosen value, either side of which two peaks over the threshold are considered independent. Default is the mean of the sample

thresh

user chosen threshold. Default is 0.975

Plot

logical argument with a default of TRUE. When TRUE, the full hydrograph with the peaks over the threshold highlighted is plotted

Author

Anthony Hammond

Details

If the x argument is a numeric vector, the peaks will be extracted with no time information. x can instead be a data.frame with dates in the first column and the numeric vector in the second. In this latter case, the peaks will be timestamped and a hydrograph including POT will be plotted by default. The method of extracting independent peaks assumes that there is a value either side of which, events can be considered independent. For example, if two peaks above the chosen threshold are separated by the daily mean flow, they could be considered independent, but not if flow hasn't returned to daily mean at any time between the peaks. Daily mean flow may not always be appropriate, in which case the 'div' argument can be adjusted. The function was coded primarily for river flow but for extracting daily duration POT rainfall a div of zero could be used (making the assumption that rainfall events separated by a period of 24 hours, with no rain, are independent). For sub-daily rainfall, further work, after use of the function, would be necessary. For example, a div of zero could be used, and if two peaks are extracted but not separated by more than 24 hours, the lower of the two could be discarded. For this approach a data.frame with dates would be required. When plotted, the blue line is the threshold and the green line is the independence line (div).

Examples

Run this code
#Extract POT data from Thames mean daily flow 1970-10-01 to 2015-09-25 with
#div = mean and threshold = 0.95. Then display the first six rows
ThamesQPOT <- POTextract(ThamesPQ[, c(1,3)], thresh = 0.90)
head(ThamesQPOT)
#Extract Thames POT from only the numeric vector of flows and display the
#first six rows
ThamesQPOT <- POTextract(ThamesPQ[, 3], thresh = 0.90)
ThamesQPOT
#Extract the Thames POT precipitation with a div of 0 and the default
#threshold. Then display the first six rows
ThamesPPOT <- POTextract(ThamesPQ[, c(1,2)], div = 0)
head(ThamesPPOT)

Run the code above in your browser using DataLab