pairEvents {hydroEvents} | R Documentation |
Pair Events
Description
Pairing of events performed either forwards or backwards within specified lag times.
Usage
pairEvents(events.1, events.2, lag = 5, type = 1)
Arguments
events.1 |
Events of first data set |
events.2 |
Events of second data set |
lag |
Maximum lag time (search radius) for pairing |
type |
Method used to pair events (see details) |
Details
Pairing can be performed forwards and backwards and centrally.events.1
and events.2
need to be
a dataframe with column names appropriate to the method type.
That is, if pairing needs a time of maximum then "which.max" is expected (see examples). Column names are taken from
the function event matching functions. The method types are:
Type = 1: Search for the peak in
events.2
within the start ofevent.1
to the end ofevent.1
+lag
Type = 2: Search for an end in
events.2
within the start ofevent.1
to the end ofevent.1
+lag
Type = 3: Search for the peak in
events.1
within the start ofevent.2
-lag
to the peak inevent.2
Type = 4: Search for a start in
events.1
within the start ofevent.2
-lag
to the start ofevent.2
Type = 5: Search for the peak in
events.2
within the peak ofevent.1
-lag
to the peak ofevent.1
+lag
It is appropriate to pick a lag time that is equivalent to the catchment time of concentration if matching rainfall to streamflow.
Value
Returns indices of start and end of events as well as the matched events as a four column dataframe.
See Also
calcStats
eventBaseflow
eventMaxima
eventMinima
eventPOT
Examples
# Load package
library(hydroEvents)
# Identify events
srt = as.Date("2015-02-05")
end = as.Date("2015-04-01")
idx = which(dataCatchment$`105105A`$Date >= srt & dataCatchment$`105105A`$Date <= end)
dat = dataCatchment$`105105A`[idx,]
events.P = eventPOT(dat$Precip_mm, threshold = 1, min.diff = 2)
events.Q = eventMaxima(dat$Flow_ML, delta.y = 2, delta.x = 1, thresh = 70)
# Plot events
oldpar <- par(mfrow = c(2, 1), mar = c(3, 2.7, 2, 1))
plotEvents(dat$Precip_mm, events = events.P, type = "hyet", colpnt = "#E41A1C",
colline = "#E41A1C", ylab = "Precipitation (mm)", xlab = "Index", main = "2015")
plotEvents(dat$Flow_ML, events = events.Q, type = "lineover", colpnt = "#E41A1C",
colline = "#377EB8", ylab = "Flow (ML/day)", xlab = "Index", main = "")
par(oldpar)
# Pair events
matched.1 = pairEvents(events.P, events.Q, lag = 5, type = 1)
matched.2 = pairEvents(events.P, events.Q, lag = 5, type = 2)
matched.3 = pairEvents(events.P, events.Q, lag = 3, type = 3)
matched.4 = pairEvents(events.P, events.Q, lag = 7, type = 4)
matched.5 = pairEvents(events.P, events.Q, lag = 5, type = 5)
# Plot Pairs
oldpar <- par(mfrow = c(5, 1), mar = c(2, 3, 2, 3))
plotPairs(data.1 = dat$Precip_mm, data.2 = dat$Flow_ML, events = matched.1,
col = rainbow(nrow(events.P)), ylab.1 = "P (mm)", ylab.2 = "Q (ML/day)", cex.2 = 0.66)
plotPairs(data.1 = dat$Precip_mm, data.2 = dat$Flow_ML, events = matched.2,
col = rainbow(nrow(events.P)), ylab.1 = "P (mm)", ylab.2 = "Q (ML/day)", cex.2 = 0.66)
plotPairs(data.1 = dat$Precip_mm, data.2 = dat$Flow_ML, events = matched.3,
col = rainbow(nrow(events.P)), ylab.1 = "Q (ML/day)", ylab.2 = "P (mm)", cex.2 = 0.66)
plotPairs(data.1 = dat$Precip_mm, data.2 = dat$Flow_ML, events = matched.4,
col = rainbow(nrow(events.P)), ylab.1 = "Q (ML/day)", ylab.2 = "P (mm)", cex.2 = 0.66)
plotPairs(data.1 = dat$Precip_mm, data.2 = dat$Flow_ML, events = matched.5,
col = rainbow(nrow(events.P)), ylab.1 = "P (mm)", ylab.2 = "Q ML/day)", cex.2 = 0.66)
par(oldpar)