Files
DataAnalysis2021/03-Cross_Correlation/2-enhanced_picker.ipynb
T
kasper 06d2f0c31c add exercise 03 (#11)
Adding exercise 3: simple cross-correlations

Co-authored-by: Kasper D. Fischer <kasper.fischer@rub.de>
Reviewed-on: #11
Co-authored-by: Kasper D. Fischer <kasper.fischer@ruhr-uni-bochum.de>
Co-committed-by: Kasper D. Fischer <kasper.fischer@ruhr-uni-bochum.de>
2021-05-17 14:38:08 +02:00

4.7 KiB

Simple cross correlation to enhance pick accuracy

This part is taken from the ObsPy tutorial at https://docs.obspy.org/master/tutorial/code_snippets/xcorr_pick_correction.html.

This example shows how to align the waveforms of phase onsets of two earthquakes in order to correct the original pick times that can never be set perfectly consistent in routine analysis. A parabola is fit to the concave part of the cross correlation function around its maximum, following the approach by Deichmann 1992.

To adjust the parameters (i.e. the used time window around the pick and the filter settings) and to validate and check the results the options plot and filename can be used to open plot windows or save the figure to a file.

See the documentation of xcorr_pick_correction() for more details.

In [ ]:
# show figures inline
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('ggplot')                            # Matplotlib style sheet - nicer plots!
plt.rcParams['figure.figsize'] = 12, 8             # Slightly bigger plots by default

# python imports
from obspy import read, UTCDateTime
from obspy.signal.cross_correlation import xcorr_pick_correction
In [ ]:
# read example data of two small earthquakes
path = "https://examples.obspy.org/BW.UH1..EHZ.D.2010.147.%s.slist.gz"
st1 = read(path % ("a", ))
st2 = read(path % ("b", ))

# display info and plot data
print(st1)
st1.plot();
print(st2)
st2.plot();
In [ ]:
# select the single traces to use in correlation.
# to avoid artifacts from preprocessing there should be some data left and
# right of the short time window actually used in the correlation.
tr1 = st1.select(component="Z")[0]
tr2 = st2.select(component="Z")[0]

# these are the original pick times set during routine analysis
t1 = UTCDateTime("2010-05-27T16:24:33.315000Z")
t2 = UTCDateTime("2010-05-27T16:27:30.585000Z")
In [ ]:
# estimate the time correction for pick 2 without any preprocessing and open
# a plot window to visually validate the results
dt, coeff = xcorr_pick_correction(t1, tr1, t2, tr2, 0.05, 0.2, 0.25, plot=True)
print("No preprocessing:")
print("  Time correction for pick 2: %.6f s" % dt)
print("  Correlation coefficient: %.2f" % coeff)
In [ ]:
# estimate the time correction with bandpass prefiltering
dt, coeff = xcorr_pick_correction(t1, tr1, t2, tr2, 0.05, 0.2, 0.25, plot=True,
                                  filter="bandpass",
                                  filter_options={'freqmin': 1, 'freqmax': 10})
print("Bandpass prefiltering:")
print("  Time correction for pick 2: %.6f s" % dt)
print("  Correlation coefficient: %.2f" % coeff)
In [ ]: