Learn R Programming

IRISSeismic (version 1.6.7)

slice: Slice a section out of a Trace or Stream

Description

The slice methods of Trace and Stream objects return like objects that are subsets of the original.

Usage

slice(x, starttime, endtime)

Value

A new Trace or Stream object is returned.

Arguments

x

a Trace or Stream object

starttime

time at which the slice should begin

endtime

time at which the slice should end

Author

Jonathan Callahan jonathan@mazamascience.com

Details

The returned object will always be a subset of the x argument whose time range is the intersection of the original time range and the requested range. When there is no intersection or when starttime > endtime an error is generated.

All metadata associated with the returned Trace or Stream will reflect the new object, rather than the original.

Examples

Run this code
if (FALSE) {
# Open a connection to EarthScope webservices
iris <- new("IrisClient")

starttime <- as.POSIXct("2002-04-20", tz="GMT")
endtime <- as.POSIXct("2002-04-21", tz="GMT")

# Get the waveform
st <- getDataselect(iris,"US","OXF","","BHZ",starttime,endtime)

# This Stream object consists of 5 Traces
length(st@traces)

# Plotting the third trace shows a small quake
plot(st@traces[[3]])

# We can slice out the hour that has the quake signal
sliceStart <- as.POSIXct("2002-04-20 10:30:00", tz="GMT")
sliceEnd <- as.POSIXct("2002-04-20 11:30:00", tz="GMT")
stSlice <- slice(st, sliceStart, sliceEnd)

# Now we only have one Trace of an hour duration
length(stSlice@traces)
stSlice@traces[[1]]@stats
# And a better look at the quake signal
plot(stSlice@traces[[1]])
}

Run the code above in your browser using DataLab