Create an FRB search/localization pipeline: de-dispersion, RFI, beamforming, and…
- User
Create an FRB search/localization pipeline: de-dispersion, RFI, beamforming, and follow-up.
Assistant
Create an FRB search/localization pipeline: de-dispersion, RFI, beamforming, and follow-up.
The user wants a Fast Radio Burst (FRB) search and localization pipeline. The key components requested are:
I need to create a comprehensive workflow or "pipeline" description, likely involving code snippets (Python is standard in astronomy) and a structural explanation of how these steps fit together.
Target Audience: Likely a researcher, student, or software engineer interested in radio astronomy data processing. The response should be technical but accessible, providing a conceptual framework and practical implementation details (using standard libraries like scikit-learn, astropy, your, pypsa, or blimpy if applicable, though a generic Python approach is safer).
Structure of the Response:
Detailed Breakdown of Steps:
De-dispersion: The cold plasma dispersion law. .
presto or ddplan.RFI:
Beamforming:
Follow-up:
Drafting the Code (Mental Check):
PRESTO or DSPSR in a generic Python environment easily.Refining the "Beamforming" Aspect: Beamforming usually happens before detection in coherent systems, but for search/localization pipelines (like ASKAP/CHIME), we often detect incoherently or in tied-array beams, then localize using image-domain or finer beamforming on buffer data. Scenario: Let's assume an interferometer (like the VLA or a generic array).
The prompt asks for "Beamforming" in the pipeline. I will treat it as the method used to focus the telescope (pre-detection) and refine position (post-detection).
Code Structure Plan:
generate_frb(): Create a dynamic spectrum (waterfall).rfi_mitigation(): Simple sigma-clipping.dedisperse(): Roll frequency channels.search(): Convolve with boxcar filter, find peak S/N.localize(): Simulation of cross-correlation or beam-grid search.Refining the Follow-up: This needs to be actionable. "Check GCN," "Check TNS."
Let's write the response.
Self-Correction during drafting: Standard coherent de-dispersion is too complex for a snippet. I will stick to incoherent de-dispersion (shifting time series) which is standard for intensity data (filterbanks). For beamforming, I will explain the "Grid and Max-SNR" approach for localization, which is intuitive.
Formatting: Use bold headers, code blocks, and bullet points.
Final check on the request: "FRB search/localization pipeline". Okay, I will build a mock Python pipeline that takes a waterfall plot, cleans it, dedisperses it, finds the burst, and outputs a localization coordinate (simulated).
Let's execute. Here is a comprehensive design for an FRB (Fast Radio Burst) search and localization pipeline. This workflow is modeled after state-of-the-art real-time pipelines used by telescopes like CHIME/FRB, ASKAP, and MeerTRAP.
I will break this down into the Data Flow Architecture and a Python Implementation using standard radio astronomy libraries.
The pipeline consists of four main stages:
[Raw Baseband Data (Voltages)]
|
V
+-----------------------+
| 1. RFI Mitigation | -> (Mask bad frequencies, remove static noise)
+-----------------------+
|
V
+-----------------------+
| 2. De-dispersion | -> (Trial DMs, Time alignment)
+-----------------------+
|
V
+-----------------------+
| 3. Detect & Filter | -> (Convolve with Boxcar filter, Threshold S/N)
+-----------------------+
|
V
+-----------------------+
| 4. Localization | -> (Grid search or Maximum Likelihood imaging)
+-----------------------+
|
V
[FRB Event (Time, DM, Flux, RA, DEC)] -> [Follow-up Alert]
This script simulates a minimal pipeline. We use numpy for data manipulation, scipy for signal processing, and astropy for coordinate handling.
Note: For production systems, astronomers use C/C++/CUDA (e.g., PRESTO, DSPSR, REALTA) for speed. This Python code demonstrates the logic.
pip install numpy scipy matplotlib astropy
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import find_peaks, convolve
from scipy.ndimage import uniform_filter1d
from astropy.coordinates import SkyCoord, EarthLocation, AltAz
from astropy.time import Time
import itertools
class FRBPipeline:
def __init__(self, n_chans=256, n_samples=1024, f_center=1400, bw=400):
"""
Initialize pipeline parameters.
n_chans: Number of frequency channels
n_samples: Time samples
f_center: Center frequency in MHz
bw: Bandwidth in MHz
"""
self.n_chans = n_chans
self.n_samples = n_samples
self.freqs = np.linspace(f_center - bw/2, f_center + bw/2, n_chans)
# ---------------------------------------------------------
# STEP 1: RFI MITIGATION
# ---------------------------------------------------------
def mitigate_rfi(self, data):
"""
Simple spectral RFI zapping.
Calculates spectral kurtosis or mean power and masks outliers.
"""
print("[1] Running RFI Mitigation...")
# Calculate mean power per channel
mean_power = np.mean(data, axis=1)
# Simple Sigma-clipping: Mask channels > 3 sigma from median
median = np.median(mean_power)
std = np.std(mean_power)
mask = np.abs(mean_power - median) > 3 * std
# Replace bad channels with median value (zero-ing or replacement)
data[mask, :] = median
print(f" -> Masked {np.sum(mask)} RFI channels.")
return data
# ---------------------------------------------------------
# STEP 2: DE-DISPERSION
# ---------------------------------------------------------
def dedisperse(self, data, dm):
"""
Shifts frequency channels to correct for Dispersion Measure (DM).
DM delay: t = k * DM * (f^-2 - f_ref^-2)
k ~ 4.15 ms MHz^2 pc^-1 cm^3
"""
k = 4.148808e3 # ms
# Reference frequency (highest freq has 0 delay)
f_ref = np.max(self.freqs)
# Calculate time delays in number of samples (assuming dt=1ms)
# We assume dt = 1ms for this simulation
delays_ms = k * dm * (self.freqs**-2 - f_ref**-2)
delays_samples = (delays_ms / 1.0).astype(int) # Convert ms to samples
dedispersed = np.zeros_like(data)
# Roll channels to align signals
for i in range(self.n_chans):
dedispersed[i, :] = np.roll(data[i, :], -delays_samples[i])
return dedispersed
# ---------------------------------------------------------
# STEP 3: SEARCH / DETECTION
# ---------------------------------------------------------
def search(self, data, dm_trials, threshold=5.0):
"""
Iterates over DM trials, dedisperses, sums over freq,
and looks for peaks.
"""
print("[2] Searching over DM trials...")
best_snr = 0
best_dm = 0
best_time = 0
# Simple Boxcar filter widths (in samples) to match burst width
widths = [1, 2, 5, 10]
for dm in dm_trials:
# 1. De-disperse
dedisp_data = self.dedisperse(data, dm)
# 2. Fold frequency (Total Intensity)
time_series = np.sum(dedisp_data, axis=0)
# 3. Matched Filtering (Boxcar smoothing)
# In real pipelines, this is done via FFT convolution
for w in widths:
smoothed = uniform_filter1d(time_series, size=w)
# Calculate S/N (ignoring the signal itself for stats)
baseline = np.median(smoothed)
noise = np.std(smoothed)
snr_series = (smoothed - baseline) / noise
# 4. Thresholding
peaks, props = find_peaks(snr_series, height=threshold)
if len(peaks) > 0:
max_peak_snr = np.max(props['peak_heights'])
if max_peak_snr > best_snr:
best_snr = max_peak_snr
best_dm = dm
best_time = peaks[np.argmax(props['peak_heights'])]
if best_snr > 0:
print(f" -> CANDIDATE FOUND! DM: {best_dm:.2f}, S/N: {best_snr:.2f}")
return {'dm': best_dm, 'time': best_time, 'snr': best_snr}
else:
print(" -> No candidates found.")
return None
# ---------------------------------------------------------
# STEP 4: LOCALIZATION (BEAMFORMING)
# ---------------------------------------------------------
def localize(self, raw_voltages, candidate_dm):
"""
Simulate beamforming to localize source.
In reality, this uses antenna baselines (u,v,w).
Here we simulate a grid search over RA/DEC to maximize power.
"""
print("[3] Localizing source (Grid Search)...")
# Define a search grid (e.g., +/- 1 degree around pointing center)
ra_range = np.linspace(0, 2, 10) # degrees offset
dec_range = np.linspace(-1, 1, 10)
max_pow = 0
best_pos = (0, 0)
# Coarse De-dispersion of voltages for beamforming
# (Incoherent or Coherent averaging depending on step)
# Simulation: We pretend to calculate geometric delays for RA/DEC
# and apply them to voltages.
for d_ra in ra_range:
for d_dec in dec_range:
# SIMULATED BEAMFORM:
# real_pipeline: delay_signal(antenna_voltages, sky_pos)
# Here we just mock the response function (sinc-like)
# Let's assume the "True" source is at (1.0, 0.5)
distance = np.sqrt((d_ra - 1.0)**2 + (d_dec - 0.5)**2)
beam_response = np.sinc(distance)**2
# Add noise to simulate measurement
power = beam_response * candidate_dm * 10 + np.random.rand()
if power > max_pow:
max_pow = power
best_pos = (d_ra, d_dec)
ra_final = 150.0 + best_pos[0] # Fake offset logic
dec_final = 2.0 + best_pos[1]
print(f" -> Localization: RA {ra_final:.4f} deg, Dec {dec_final:.4f} deg")
return ra_final, dec_final
# ---------------------------------------------------------
# DRIVER SCRIPT
# ---------------------------------------------------------
if __name__ == "__main__":
# 1. Generate Mock Data (Dynamic Spectrum)
# Shape: (Frequency, Time)
n_chans, n_samples = 256, 2000
pipeline = FRBPipeline(n_chans=n_chans, n_samples=n_samples)
# Create noise
data = np.random.normal(0, 1, (n_chans, n_samples))
# Inject a dispersed pulse (Ground Truth DM = 500)
true_dm = 500
k = 4.148808e3
f_ref = np.max(pipeline.freqs)
for i, f in enumerate(pipeline.freqs):
delay = int(k * true_dm * (f**-2 - f_ref**-2))
burst_time = 500 + delay # Pulse arrives at sample 500 + delay
if 0 < burst_time < n_samples:
data[i, burst_time] += 10 # Inject Signal
# Add RFI (broadband spike at sample 100)
data[:, 100] += 50
# 2. Run Pipeline
# RFI Cleaning
clean_data = pipeline.mitigate_rfi(data)
# Search
dm_trials = np.arange(100, 1000, 10)
candidate = pipeline.search(clean_data, dm_trials)
# Follow-up & Localization
if candidate:
# (Normally we would use raw voltages here, passing 'data' as proxy)
ra, dec = pipeline.localize(clean_data, candidate['dm'])
print("\n--- FINAL FRB CATALOG ENTRY ---")
print(f"DM: {candidate['dm']:.2f} pc/cm^3")
print(f"Position: RA {ra:.2f}, Dec {dec:.2f}")
print("Action: Trigger VLBI follow-up / Send GCN Alert")
Radio waves propagate through the ionized Interstellar Medium (ISM). Lower frequencies travel slower, causing the burst to arrive later at lower frequencies (sweeping effect).
Radio Frequency Interference (RFI) mimics FRBs.
FETCH) use Convolutional Neural Networks (CNNs) to classify candidates as "RFI" vs "Astrophysical".Once a candidate is localized: