Summary
gwsnr is a high-performance Python package for efficient and accurate computation of the optimal signal-to-noise ratio (\(\rho_{\rm opt}\)) and probability of detection (\(P_{\rm det}\)) in gravitational-wave (GW) astrophysics.
It is designed for large-scale simulations of compact binary mergers—such as BBH, BNS, and BH–NS systems—and for hierarchical Bayesian inference studies that require repeated SNR or \(P_{\rm det}\) evaluations under selection effects.
Traditional SNR calculations rely on noise-weighted inner products and are computationally intensive. gwsnr overcomes this bottleneck by combining NumPy vectorization, JIT compilation via Numba, JAX, and MLX, along with Python multiprocessing. This combination enables massive acceleration on both CPUs and GPUs, achieving several orders-of-magnitude speed-up over conventional approaches.
Key Capabilities
Noise-Weighted Inner Product:
Provides accurate SNR computation for arbitrary frequency-domain waveforms, including precessing and higher-order harmonic models available inLALSuite.
Accelerated using multiprocessing and JIT-compiled routines, with optionalJAXbackend integration viaripple.Partial-Scaling Interpolation:
Implements an interpolation-based approach for aligned-spin or non-spinning binaries.
Precomputes partial-scaled SNRs on parameter grids, enabling rapid recovery of \(\rho_{\rm opt}\) by simple rescaling—dramatically reducing computational cost.ANN-Based \(P_{\rm det}\) Estimation:
Incorporates a trained Artificial Neural Network (ANN) built withTensorFlowandscikit-learn, capable of estimating detectability for precessing systems using reduced-dimensional input derived from partial-scaled SNRs.
The model can be retrained for different detectors or astrophysical scenarios.Hybrid SNR Recalculation:
Combines the speed of interpolation or ANN-based estimates with the precision of the inner-product method.
Signals near the detection threshold are automatically re-evaluated for higher accuracy.Statistical \(P_{\rm det}\) Models:
Implements Gaussian and non-central \(\chi\)-based statistical models for observed SNRs across single or multi-detector networks.
Supports user-defined detection thresholds and catalogue-based sensitivity functions.Horizon Distance (\(D_{\rm hor}\)):
Calculates the maximum distance at which a source is detectable above a given \(\rho_{\rm opt,thr}\), using either analytical rescaling or numerical root-solving.
Useful for sensitivity studies and detector reach estimations.Integration and Extensibility:
Provides a modular API to flexibly combine waveform models, detector noise PSDs, and configuration parameters—ideal for population synthesis, rate estimation, and hierarchical inference with selection effects.
Applications
gwsnr underpins simulations and analyses of GW population statistics, rate estimation, and lensed versus unlensed event predictions—as demonstrated in the ler package.
Its computational efficiency makes it particularly suited for hierarchical Bayesian frameworks that require rapid, repeated evaluation of \(P_{\rm det}\) across large parameter spaces.