Learn R Programming

IRISMustangMetrics (version 1.0.1)

crossCorrelationMetric: Correlation between channels

Description

The crossCorrelationMetric() function calculates the peak_correlation and peak_lag associated with two streams of seismic data.

Usage

crossCorrelationMetric(st1, st2, maxLagSecs=10, filter=signal::butter(2,0.2))

Arguments

st1
a Stream object containing a seismic signal
st2
a Stream object containing a seismic signal
maxLagSecs
maximum number of seconds of lag to use
filter
a signal package filter to be applied before cross-correlating

Value

A list with two SingleValueMetric objects is returned. The metric names are peak_correlation and peak_lag.

Details

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 see(signal::decimate).
  • Both signals are filtered, by default with a Butterworth low pass filter see(signal::filter).
  • Signals are cross-correlated using the ccf() function.

The maximum absolute correlation is saved as peak_correlation while the lag at peak correlation is saved as peak_lag.

Note: For cross-correlation, seismic signals must not have any gaps -- they must be contained in a single Trace object.

Examples

Run this code
# Open a connection to IRIS DMC 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)

#[[1]]
# SingleValueMetric 
#  metric:        peak_correlation
#  snclq:         NM.SLM.00.BHZ.M
#  starttime:     2013-11-12 07:09:45
#  endtime:       2013-11-12 07:19:45
#  value:         0.999
#  snclq2:    NM.SLM.00.BHZ.M
#
#[[2]]
#SingleValueMetric 
#  metric:        peak_lag
#  snclq:         NM.SLM.00.BHZ.M
#  starttime:     2013-11-12 07:09:45
#  endtime:       2013-11-12 07:19:45
#  value:         3.000
#  snclq2:    NM.SLM.00.BHZ.M

Run the code above in your browser using DataLab