Last data update: 2014.03.03

R: Determine times when a channel starts/stops collecting data
getUpDownTimesR Documentation

Determine times when a channel starts/stops collecting data

Description

The getUpDownTimes method determines the on/off times for data collection within a Stream and returns a list containing these times, ignoring Traces with a duration less than min_signal as well as data dropouts that are less than min_gap.

Usage

getUpDownTimes(x, min_signal, min_gap)

Arguments

x

Stream object

min_signal

minimum Trace duration in seconds (default=30)

min_gap

minimum gap in seconds (default=60)

Details

A Stream object returned by getDataselect contains a list of individual Trace objects, each of which is guaranteed to contain a continuous array of data in the Trace@data slot. Each Trace also contains a starttime and an endtime representing a period of uninterrupted data collection. Data dropouts are determined by first rejecting any Traces of duration less than min_signal. The temporal spacing between Traces is then analyzed, ignoring spaces shorter than min_gap.

This method first checks the SNCL id of each Trace to make sure they are identical and throws an error if they are not.

The first element returned is always the starttime associated the first Trace. The last element is always the endtime associated with the last trace. Thus, when the first element is identical to the starttime of the web services data request this does not necessarily mean that the channel was down before this.

NOTE: Even when data are complete for the duration of the requested timespan, the last element returned may be earlier than the endtime of the web services data request by up to a second.

Value

A vector of POSIXct datetimes associated with on/off transitions.

Author(s)

Jonathan Callahan jonathan.s.callahan@gmail.com

See Also

plotUpDownTimes

Examples

# Open a connection to IRIS DMC webservices
iris <- new("IrisClient")

starttime <- as.POSIXct("2012-01-24", tz="GMT")
endtime <- as.POSIXct("2012-01-25", tz="GMT")

# Get the waveform
st <- getDataselect(iris,"AK","PIN","","VEA",starttime,endtime)

# Determine up/down transitions, ignoring Traces < 3 min and gaps < 5 min
upDownTimes <- getUpDownTimes(st, min_signal=180, min_gap=300)

# Or just plot them directly
plotUpDownTimes(st, min_signal=180, min_gap=300)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(IRISSeismic)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/IRISSeismic/getUpDownTimes.Rd_%03d_medium.png", width=480, height=480)
> ### Name: getUpDownTimes
> ### Title: Determine times when a channel starts/stops collecting data
> ### Aliases: getUpDownTimes getUpDownTimes,Stream,missing,missing-method
> ###   getUpDownTimes,Stream,numeric,numeric-method
> ### Keywords: methods
> 
> ### ** Examples
> 
> # Open a connection to IRIS DMC webservices
> iris <- new("IrisClient")
> 
> starttime <- as.POSIXct("2012-01-24", tz="GMT")
> endtime <- as.POSIXct("2012-01-25", tz="GMT")
> 
> # Get the waveform
> st <- getDataselect(iris,"AK","PIN","","VEA",starttime,endtime)
> 
> # Determine up/down transitions, ignoring Traces < 3 min and gaps < 5 min
> upDownTimes <- getUpDownTimes(st, min_signal=180, min_gap=300)
> 
> # Or just plot them directly
> plotUpDownTimes(st, min_signal=180, min_gap=300)
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>