Skip to main content

A Python package for calculating gravitational wave signal-to-noise ratios

Project description

gwsnr: Gravitational Wave Signal-to-Noise Ratio Computation Package

Docs PyPI version DOI

Your Logo

Installation

pip install gwsnr

Example Usage

from gwsnr import GWSNR

# Initialize the default calculator
gwsnr = GWSNR()

# Compute SNR and Pdet for a 30-30 Msun binary at 1000 Mpc with other random extrinsic parameters
snrs = gwsnr.optimal_snr(mass_1=30, mass_2=30, luminosity_distance=1000, psi=0.0, phase=0.0, geocent_time=1246527224.169434, ra=0.0, dec=0.0)
pdet = gwsnr.pdet(mass_1=30, mass_2=30, luminosity_distance=1000, psi=0.0, phase=0.0, geocent_time=1246527224.169434, ra=0.0, dec=0.0)

print(f"SNR value: {snrs},\nP_det value: {pdet}")

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 in LALSuite.
    Accelerated using multiprocessing and JIT-compiled routines, with optional JAX backend integration via ripple.

  • 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 with TensorFlow and scikit-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.

Examples

Detailed usage examples and tutorials are available in the gwsnr/docs/examples directory and online at the gwsnr documentation site.

Documentation

The gwsnr package documentation is available at ReadTheDocs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gwsnr-0.5.0.tar.gz (7.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gwsnr-0.5.0-py3-none-any.whl (7.6 MB view details)

Uploaded Python 3

File details

Details for the file gwsnr-0.5.0.tar.gz.

File metadata

  • Download URL: gwsnr-0.5.0.tar.gz
  • Upload date:
  • Size: 7.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for gwsnr-0.5.0.tar.gz
Algorithm Hash digest
SHA256 dac2223a5ef587e52c0754fc721e80c658c6c5e59e772eb578fc2e2cec5087a8
MD5 dbc5b986301a097d87c006b7067a02b1
BLAKE2b-256 b8c5f0cf78071d2a7d90924cf2ff3dc966c0ca9fe75b0eecd059bd4b2d231982

See more details on using hashes here.

File details

Details for the file gwsnr-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: gwsnr-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for gwsnr-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a35c04055b63a48cffb83c1609cfec88e34fc67acaca390deb4ba556a141eff2
MD5 36d17782714990862e5b49d1da9642fc
BLAKE2b-256 013e4b2fed39674364c9e1f0f85ee6d257202fb058035c2f18bda5130cf925d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page