SKILL.md
Matched Filtering for Gravitational Wave Detection
Matched filtering is the primary technique for detecting gravitational wave signals in noisy detector data. It correlates known template waveforms with the detector data to find signals with high signal-to-noise ratio (SNR).
Overview
Matched filtering requires:
- Template waveform (expected signal shape)
- Conditioned detector data (preprocessed strain)
- Power spectral density (PSD) of the noise
- SNR calculation and peak finding
PyCBC supports both time-domain and frequency-domain approaches.
Time-Domain Waveforms
Generate templates in time domain using get_td_waveform:
from pycbc.waveform import get_td_waveform
from pycbc.filter import matched_filter
# Generate time-domain waveform
hp, hc = get_td_waveform(
approximant='IMRPhenomD', # or 'SEOBNRv4_opt', 'TaylorT4'
mass1=25, # Primary mass (solar masses)
mass2=20, # Secondary mass (solar masses)
delta_t=conditioned.delta_t, # Must match data sampling
f_lower=20 # Lower frequency cutoff (Hz)
)
# Resize template to match data length
hp.resize(len(conditioned))
# Align template: cyclic shift so merger is at the start
template = hp.cyclic_time_shift(hp.start_time)
# Perform matched filtering
snr = matched_filter(
template,
conditioned,
psd=psd,
low_frequency_cutoff=20
)
# Crop edges corrupted by filtering
# Remove 4 seconds for PSD + 4 seconds for template length at start
# Remove 4 seconds at end for PSD
snr = snr.crop(4 + 4, 4)
# Find peak SNR
import numpy as np
peak_idx = np.argmax(abs(snr).numpy())
peak_snr = abs(snr[peak_idx])
Why Cyclic Shift?
Waveforms from get_td_waveform have the merger at time zero. For matched filtering, we typically want the merger aligned at the start of the template. cyclic_time_shift rotates the waveform appropriately.
Frequency-Domain Waveforms
Generate templates in frequency domain using get_fd_waveform:
