mergeUpDownTimes {IRISSeismic} | R Documentation |
Determine overlaps in two sets of upDownTimes.
Description
The mergeUpDownTimes
function determines the overlaps in two sets of times representing up/down (on/off) periods for a single
or a set of channels. This function can be used to determine overall station up/down periods.
Usage
mergeUpDownTimes(udt1, udt2, bothOn)
Arguments
udt1 |
vector of |
udt2 |
vector of |
bothOn |
logical specifying whether overlaps are determined with |
Details
When bothOn=FALSE
, the default, this function returns the times of transitions from "either to neither" and back.
When bothOn=TRUE
, this function returns the times of transitions from "both to either" and back.
If an empty vector is passed in for udt1
or udt2
then the other vector is returned unchanged. This can be useful
when merging the upDownTimes for multiple channels. See the example below.
Value
A vector of POSIXct
datetimes associated with on/off transitions.
Note
The vector of times in udt1
and udt2
has no information on the values of min_signal
or min_gap
that
were used to generate the timeseries. It is up to the user to make sure that the incoming vectors are appropriate for comparison.
See getUpDownTimes
.
Author(s)
Jonathan Callahan jonathan@mazamascience.com
See Also
getUpDownTimes
,
plotUpDownTimes
Examples
## Not run:
# Open a connection to IRIS DMC webservices
iris <- new("IrisClient")
# Three Streams, each with different upDownTimes
starttime <- as.POSIXct("2012-07-01", tz="GMT")
endtime <- as.POSIXct("2012-07-02", tz="GMT")
stE <- getDataselect(iris,"IU","XMAS","10","BHE",starttime,endtime)
stN <- getDataselect(iris,"IU","XMAS","10","BHN",starttime,endtime)
stZ <- getDataselect(iris,"IU","XMAS","10","BHZ",starttime,endtime)
udtE <- getUpDownTimes(stE)
udtN <- getUpDownTimes(stN)
udtZ <- getUpDownTimes(stZ)
udtAll <- c()
udtAny <- c()
for (udt in list(udtE, udtN, udtZ)) {
udtAll <- mergeUpDownTimes(udtAll,udt,bothOn=TRUE)
udtAny <- mergeUpDownTimes(udtAny,udt,bothOn=FALSE)
}
# 5 rows
layout(matrix(seq(5)))
# Plot the results
par(mar=c(3,4,3,2)) # adjust margins
plotUpDownTimes(udtE); title("BHE")
plotUpDownTimes(udtN); title("BHN")
plotUpDownTimes(udtZ); title("BHZ")
plotUpDownTimes(udtAll); title("ALL channels up")
plotUpDownTimes(udtAny); title("ANY channel up")
# Restore default layout
layout(1)
## End(Not run)