TheMatchedFilterTutorial Oct 2017

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

The Matched Filter (CPU version) Tutorial

Xiaofeng Meng

Red: Parameters, directories Blue: Command lines Purple: File names

1. Data preparation
1.1. Waveforms naming rule
$network.$station.$channel.SAC
For example, BP.FROB.BP1.SAC

1.2. Continuous data: ContWaveform/


Name each directory by the beginning time of the data (yyyymmddhhmmss). For example,
20031221000000/.
The time window of one day for continuous data is usually good enough. The detection results might be
very unstable if the time window is too short. If the number of stations is too large that one day’s data can
not fit into memory, one should use shorter time window.
Create a file that lists all directories cont.list.

1.2.1. Headers
Set one common kztime for all channels for one day and set the ‘o’ header to 0.
All waveforms should have the same ‘b’ header (i.e., 0) and ‘e’ header (i.e., 86400). If one channel is much
shorter than others, it should be excluded.
Use gsact command to shift time (this step is included in check_cont_waveforms.bash).
All channels should have the same sampling rate delta. If not, use SAC command interpolate to
correct (this step is in check_cont_waveforms.bash).
Command: check_cont_waveforms.bash
Output: 'sampling_rate.list' lists directories that have different sampling rate among channels.
Output: 'length.list' lists directories that have significantly different length (default value is 3600s, which
one can change in check_cont_waveforms.bash by themselves).
Then, one should decide if those channels need to be removed.

1.2.2. Band-pass filter


To enhance local earthquakes' signal to noise ratio, one need to apply a band-pass or high-pass filter.
For local/regional (~100 km) scale detection, one usually use filters like 2-8 Hz, 5-15 Hz etc. However, due
to the variations in noise level, signal strength and source/receiver distance, the final filter should be
decided by users.
Command: bp.bash
Output: BP.FROB.BP1.SAC.bp

1.2.3. Sampling rate


The computing time grows linearly with sampling rate. Therefore, it is recommended to desample the data
if possible.
The filter's frequency range must below Nyquist frequency (i.e., sampling rate/2).
Modify 'bp.bash' to allow or disallow desampling.

1.3. Template data TempWaveform/


Name template id as the origin time of the earthquake (yyyymmddhhmmss). For example,
20031221211539.
Create a file that lists all directories temp.list.
Prepare the catalog of all templates template.catalog, whose format should be:
[template_id] [year] [month] [day] [hour] [minute] [second] [lat] [lon] [depth] [magnitude] [epoch_ti
me]
1.3.1. Length
Half minute before to two minutes after the origin time of the template is good enough.

1.3.2. Headers
Set the kztime to the origin time of the template event and set the ‘o’ header to 0.
Command: set_otime.bash
Set desired arrival times for detection as ‘t1’ header. How to get arrival times?
1) Phase information listed in the local catalog;
2) Hand-pick;
3) Predict the arrival time based on 1D velocity model.

1.3.3. Band-pass filter and sampling rate


Template waveforms must have the same band-pass filter and sampling rate as the continuous data.
Command: bp.bash

1.3.4. Signal to noise ratio (SNR)


Compute the signal to noise ratio of each channel. Only channels with SNR larger than 5 will be used for
detection.
Command: compute_SNR.bash
Output: wf_SNR.dat in each template’s directory, lists SNR of each channel, whose format is:
[wf name] [SNR] [energy of signal window] [energy of noise window]
Output: dir_event_SNR.dat in parent directory, lists SNR information of each template, whose format is:
[template ID] [median SNR] [Total number of channels] [Channels with SNR>5]

2. Detection WorkDir/
2.1. Running detection on single channel
sliding_wfcc_fix_v5 [-f template_sac_file] [-s continuous_sac_file] [-b template_start_time] [-a
template_end_time] [-B continuous_start_time] [-A continuous_end_time] [-S time_step] [-O
shift _time] [-t taper] [-D debug] [-F output] [-o sacfile] -h help
sliding_wfcc_fix_v5 -
f /home/xmeng/Tutorial/CPU_WFCC/TempWaveform/20031221211539/BP.VCAB.BP1.SAC.bp -
s /home/xmeng/Tutorial/CPU_WFCC/ContWaveform/20031221000000/BP.VCAB.BP1.SAC.bp -b 4.7216
-a 10.7216 -B 1 -A 86448 -S 0.05 -O 4.7216 -F 1 -o
VCAB_BP1_20031221191400_t2_bp_20031221191400_wfcc.sac
Output: VCAB_BP1_20031221191400_t2_bp_20031221191400_wfcc.sac

2.2. Running detection on all continuous days with one template


Prepare a config file ‘config’. [wfcc_code] is full path to code; [data_dir] is full path to data and working
directories; [output_option]: 0 outputs ascii file, 1 outputs sac file, 2 only shows script; [slide_win] is
temporal step (usually sampling rate); [phase] is header for arrival time; [t1] is starting time of detecting
time window (1s before arrival time); [t2] is end time of detecting time window (4s after arrival time);
[minimum_wf_cutoff] is the minimum number of channels per template; [min_SNR] is the minimum SNR
for detection; [allow_shift] is the number of data points allowed to shift while stacking.

Command: Run_detection.bash 20031221211539, where 20031221211539 is template id.

2.3. Stack correlation traces and output positive detections


XmengStackShift [list_of_correlating_traces] [number_of_correlating_traces] [number_of_points_allo
w_to_shift] [output_sac_file] > [output_detected_events]
Default detection threshold is {median value+9*MAD}. You may change it at line 123 in the source code
and recompile it.
XmengStackShift sac_file_SNR_20031221191400.id 27 0 shift_20031221191400.sac >
9times_20031221191400.dat
Output: shift_20031221191400.sac, stacked CC trace.
Output: 9times_20031221191400.dat, list of detected events. Format is following:
First line: mad:median_value:MAD
Other lines: detection_time CC (CC-median_value)/MAD
This step is included in 'Run_detection.bash'.

2.4. Running detection on all continuous days with all templates


In the sample dataset, we have 6 templates and 1-day continuous data. Since we usually have multiple
CPUs on one computer, we can utilize them at once.
We can divide the template library into three equal parts and submit a job for each one of them. In this way,
we can shorten the computing time to one third.
Command: Run_Whole_Dataset.bash 3, where 3 is the number of CPUs you want to use.

3. Prepare catalog Catalog/


Prepare a config file ‘config’. [min_chan_number] is the minimum number of channels per template;
[threshold] is detection threshold (median+9*MAD); [time_step] is the time window for removing
duplicate detections (2 s); [data_dir] is full path to data and working directories; [min_SNR] is the
minimum SNR for detection; [phase] is header for arrival time.
Command: Generate_catalog.bash 20031221000000, where 20031221000000 is continuous data ID.

3.1. Combine detections from all templates


3.2. Remove duplicate detections
Many close templates may detect the same earthquake, with subtle differences in origin time. Therefore, we
only keep the one with the highest CC every a few seconds (default is 2s).
3.3. Compute the magnitude of the detected events
Obtain the peak amplitude of the detected event and the corresponding template, respectively.
magnitude_detected_event = magnitude_template + log10(peak_amp_ratio).
3.4. Generate final catalog
Output: catalog_20031221000000.dat. Final catalog format:
[1. detected event date] [2. detected event time] [3. detected event epoch time] [4. detected event time
since midnight] [5. detected event magnitude] [6. CC] [7. (CC-median value)/MAD] [8. template id] [9.
template year] [10. template month] [11. template day] [12. template hour] [13. template minute] [14.
template second] [15. template latitude] [16. template longitude] [17. template depth] [18. template
magnitude] [19. template epoch time]

4. Figure Figures/
Generate the a simple figure for waveform comparison between the detected and template event.
Command: waveforms_comparison.bash catalog_20031221000000.dat 36,
where catalog_20031221000000.dat is the detected catalog and 36 is the number of detected events.
Users can change the absolute path and parameters in waveforms_comparison.bash.
Output: 75448.00.eps

5. Measure differential travel time Detected/


Prepare a config file ‘config’. [search_range] assume different templates detect one event within the time
window; [delta] is sampling rate; [fit_points] is number of data points around peak CC for quadratic
interpolation; [wfcc_code] is full path to code; [data_dir] is full path to data and working directories;
[phase] is header for arrival time; [threshold] is detection threshold (median+9*MAD); [threshold2] is
threshold on single channel for measuring differential travel time; [min_SNR] is the minimum SNR for
detection.
Command: Correlate.bash catalog_20031221000000.dat 11

5.1. Correlate around the origin time of the detected event


Perform correlation 60s before and 60 after the origin time of the detected event from all templates that
detected the particular event. Make sure to differentiate P- and S-arrivals.
5.2. Output the differential travel time and weight
5.2.1. The origin time of the detected event is the detection time from the template that has the highest CC;
5.2.2. Find the highest CC (CCpeak) on each channel, as well as the second highest CC (CCsecond), within
search_range of the origin time, and determine if CCpeak is above threshold2;
5.2.3. Perform a spline interpolation to the three data points around CCpeak;
5.2.4. Weight is CCpeak*CCpeak*(0.1+3*(CCpeak-CCsecond));
5.2.5. Write the differential travel time and weight to the output file ‘hypoDD.$template’.

You might also like