merge_time function

Merge Events

Merge Events

Given two event data frames of neighboring stations SxS_x and SyS_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 SyS_y and events are merged where matches according to differences allowed to timeLag can be found.

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 hydropeak::get_events()) of an upstream hydrograph SxS_x.
  • Sy: Data frame that consists of flow fluctuation events and computed metrics (see hydropeak::get_events()) of a downstream hydrograph SyS_y.
  • 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 relation.csv or vignette for details on the structure. See get_lag() for further information about the relation and the lag between the hydrographs.
  • timeLag: Numeric vector specifying factors to alter the interval to capture events from the downstream hydrograph. By default it is timeLag = c(1, 1, 1), this refers to matches within a time slot ±\pm the mean translation time from relation. For exact time matches, timeLag = c(0, 1, 0) must be specified.
  • 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").

Returns

Data frame that has a matched event at SxS_x and SyS_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)

Other functions in hydroroute

Related functions from the same R package

  • Maintainer: Bettina Grün
  • License: GPL-2
  • Last published: 2023-02-08

Useful links