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.3.9.tar.gz (140.9 kB view details)

Uploaded Source

Built Distribution

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

gwsnr-0.3.9-py3-none-any.whl (143.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for gwsnr-0.3.9.tar.gz
Algorithm Hash digest
SHA256 9cc4a4f391c5d420f7b588bfe552a877993a79c10a14aa04352726a9ddee44df
MD5 3b4d3542291422d003bbd562312b55e2
BLAKE2b-256 bd725df141e6dd50ca0cfca45f584d07cbdf85f45dc2a3dd741e551ea8da9c13

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for gwsnr-0.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 6417d2f38aa7ac10db98a7ceb2877e893ee56ebda425d0f175d70526647f82d9
MD5 5ed2c3df0cfe8083426a8fbc68fc8d86
BLAKE2b-256 dfde63f018435eefaea15154b21d61343d88a37c11d55e410144f98b03bccc08

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