merge_time {hydroroute} | R Documentation |
Merge Events
Description
Given two event data frames of neighboring stations
S_{x}
and S_{y}
that consist of flow
fluctuation events and computed metrics (see
hydropeak::get_events()
),
the translation time indicated by the relation file as well as
timeLag
between these two stations is subtracted from
S_{y}
and events are merged where matches according
to differences allowed to timeLag
can be found.
Usage
merge_time(
Sx,
Sy,
relation,
timeLag = c(1, 1, 1),
TimeFormat = "%Y-%m-%d %H:%M",
tz = "Etc/GMT-1"
)
Arguments
Sx |
Data frame that consists of flow fluctuation events and computed
metrics (see |
Sy |
Data frame that consists of flow fluctuation events and computed
metrics (see |
relation |
Data frame that contains the relation between upstream and
downstream hydrograph. Must only contain two rows (one for each hydrograph)
in order of their location in downstream direction.
See the appended example data |
timeLag |
Numeric vector specifying factors to alter the interval to capture
events from the downstream hydrograph. By default it is
|
TimeFormat |
Character string giving the date-time format of the date-time column in the input data frame (default: "%Y-%m-%d %H:%M"). |
tz |
Character string specifying the time zone to be used for the conversion (default: "Etc/GMT-1"). |
Value
Data frame that has a matched event at S_{x}
and
S_{y}
in each row. If no matches are detected,
NULL
is returned.
Examples
Sx <- system.file("testdata", "Events", "100000_2_2014-01-01_2014-02-28.csv",
package = "hydroroute")
Sy <- system.file("testdata", "Events", "200000_2_2014-01-01_2014-02-28.csv",
package = "hydroroute")
relation <- system.file("testdata", "relation.csv", package = "hydroroute")
# read data
Sx <- utils::read.csv(Sx)
Sy <- utils::read.csv(Sy)
relation <- utils::read.csv(relation)
relation <- relation[1:2, ]
# exact matches
merged <- merge_time(Sx, Sy, relation, timeLag = c(0, 1, 0))
head(merged)
# matches within +/- mean translation time
merged <- merge_time(Sx, Sy, relation)
head(merged)