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.4.7.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.4.7-py3-none-any.whl (7.6 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gwsnr-0.4.7.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.4.7.tar.gz
Algorithm Hash digest
SHA256 b6d5838b9e640f6ce0ca5e857f16c897e19e46bccf6e426b3f3cefa743d7f5cf
MD5 a01d7ddfcc2f0500a870ce05bc5de764
BLAKE2b-256 f46432a04430550c1b8c2759ac8d444e621c58f636dc34cccb1c58603f5328f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gwsnr-0.4.7-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.4.7-py3-none-any.whl
Algorithm Hash digest
SHA256 5d95adc306684fccd5ec9269108cf6752c9fc1e4ea4caa51e297e80c10eeb6a4
MD5 d893cd3c79840f601472a8151903dac6
BLAKE2b-256 b662011ce07c40171b479aa0db8e09c2ae504df2957fb356d6a2efdf55c1b726

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