extractPeaks | R Documentation |
Extracts independent peaks
extractPeaks(vecTime = NULL, vecObs, mintimeDiff = 73, thrConst = (2/3))
vecTime |
an optional numeric vector containing information on the time variable.
The vector is used to order the vecObs variable, so it should be provided if the data are not in chronological order
If |
vecObs |
the vector of observations, the variable from which peaks should be extracted |
mintimeDiff |
the time after which peaks should be considered independent |
thrConst |
the constant defining how much the through should be smaller than the peaks to identify independent peaks |
This functions has been (sort of) tested in extracting peaks from 15 minutes data.
The function assumes that two peaks are independent if they are at least mintimeDiff
steps apart and
if the minimumn amount of water in the though is less than thrConst
the value of the maximum peak.
mintimeDiff
can not be given as an actual time measuraments, it is just an indicator of how many postions apart
in the vecTIme
vector two peaks need to be to be considered independent.
Therefore vecTIme
needs to be equally spaced,
e.g. if missing values are present in the original file they should be infilled.
a list of 0-1 values which indicate whether the vecObs
value is a peak
zz <- data.frame(hour=seq(1, 240),
flow=sample(c(rnorm(200, 50, 5),rgev(40, 70,3,0.2))))
zz$isPeak <- extractPeaks(vecTime=zz$hour,vecObs=zz$flow,mintimeDiff=4)
plot(zz$hour, zz$flow, type = "l")
points(zz$hour[zz$isPeak==1], zz$flow[zz$isPeak==1], col=2)
## more hours needed to be assumed independent
zz$isPeak <- extractPeaks(vecTime=zz$hour,vecObs=zz$flow,mintimeDiff=8)
points(zz$hour[zz$isPeak==1], zz$flow[zz$isPeak==1], col=4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.