Last chance! 50% off unlimited learning
Sale ends in
The crossCorrelationMetric() function calculates the maximum absolute correlation (polarity_check
)
and lag at maximum correlation (timing_drift
) associated with two streams of seismic data.
crossCorrelationMetric(st1, st2, maxLagSecs=10, filter)
A list with one GeneralValueMetric
object is returned.
The metric names is polarity_check
.
a Stream
object containing a seismic signal
a Stream
object containing a seismic signal
maximum number of seconds of lag to use
a signal package filter to be applied before cross-correlating, optional
Jonathan Callahan jonathan@mazamascience.com (R code), Mary Templeton mary.templeton@earthscope.org (algorithm)
Details of the algorithm are as follows:
Both signals are demeaned and detrended
If one signal has a higher sampling rate, it is decimated to the lower sampling rate using an IIR filter if it is a multiple of the lower sample rate. See (signal::decimate
).
Both signals are filtered, by default with a Butterworth 2-pole low pass filter with a 0.1 Hz (10 second) corner frequency. See (signal::filter
).
Signals are cross-correlated using the stats::ccf()
function.
The maximum absolute correlation is saved as polarity_check
while the lag at peak correlation is saved as timing_drift
.
Note: For cross-correlation, seismic signals must not have any gaps -- they must be contained in a single Trace
object.
if (FALSE) {
# Open a connection to EarthScope webservices
iris <- new("IrisClient")
# Get the same signal, shifted by 3 seconds
starttime <- as.POSIXct("2013-11-12 07:09:45",tz="GMT")
endtime <- starttime + 600
st1 <- getSNCL(iris,"NM.SLM.00.BHZ",starttime,endtime)
st2 <- getSNCL(iris,"NM.SLM.00.BHZ",starttime+3,endtime+3)
# Cross-correlate
crossCorrelationMetric(st1,st2)
}
Run the code above in your browser using DataLab