# gwsnr: Gravitational Wave Signal-to-Noise Ratio Computation Package
[]() [](https://badge.fury.io/py/gwsnr) [](https://gwsnr.readthedocs.io/en/latest/)
<p align="center">
<img src="docs/_static/logo.svg" alt="Your Logo" width="200" height="200">
</p>
## Installation
```bash
pip install gwsnr
```
## Example Usage
```python
from gwsnr import GWSNR
gwsnr = GWSNR()
snrs = gwsnr.snr(mass_1=30, mass_2=30, distance=1000, psi=0.0, phase=0.0, geocent_time=1246527224.169434, ra=0.0, dec=0.0)
print(f"SNR value: {snrs}")
```
## Summary
Gravitational waves (GWs)—ripples in spacetime predicted by Einstein’s theory of General Relativity—have revolutionized astrophysics since their first direct detection in 2015. These signals, emitted by the mergers of compact objects such as binary black holes (BBHs), binary neutron stars (BNSs), and black hole–neutron star pairs, provide unique insights into the universe. A central quantity in GW data analysis is the **signal-to-noise ratio** (SNR), which quantifies the strength of a GW signal relative to the noise in detectors like LIGO, Virgo, and KAGRA. Reliable SNR estimation is essential for confirming GW detections and performing astrophysical inference. However, modern GW research—especially in population simulations and hierarchical Bayesian inference with selection effects—requires the computation of SNRs for vast numbers of systems, making traditional methods based on noise-weighted inner products prohibitively slow.
The **`gwsnr`** Python package addresses this computational bottleneck, offering a flexible, high-performance, and user-friendly framework for SNR and probability of detection ($P_{\rm det}$) estimation. At its core, `gwsnr` leverages [NumPy](https://numpy.org/) vectorization along with Just-In-Time (JIT) compilation via [Numba](https://numba.pydata.org/) and [JAX](https://github.com/google/jax), as well as Python multiprocessing, to deliver exceptional performance.
### Key Features
- **Noise-Weighted Inner Product with Multiprocessing**: Provides accurate SNR calculations for arbitrary frequency-domain waveforms, including those with spin precession and higher-order harmonics available in [lalsimulation](https://lscsoft.docs.ligo.org/lalsuite/lalsimulation/modules.html). The method is enhanced with multiprocessing and JIT compilation to accelerate computation, with optional support for JAX-based waveform libraries like [ripple](https://github.com/tedwards2412/ripple).
- **Partial Scaling Interpolation**: An innovative and highly efficient interpolation method for accurately calculating the SNR of non-precessing (spinless or aligned-spin) binary systems. This approach dramatically reduces computation time, making large-scale analyses practical.
- **ANN-Based $P_{\rm det}$ Estimation**: Employs a trained Artificial Neural Network (ANN) to provide fast probability of detection ($P_{\rm det}$) estimates via SNR calculations for precessing BBH systems. This feature is especially valuable when rapid detection assessments are needed without requiring precise SNR values.
- **Hybrid SNR Recalculation**: A balanced approach that combines the speed of the partial scaling method (or ANN-based estimation) with the precision of the noise-weighted inner product, ensuring high accuracy for systems near the detection threshold.
- **Horizon Distance Calculation**: Implements both analytical and numerical methods to compute the horizon distance for gravitational wave sources, allowing users to assess detector sensitivity and detection capabilities across various configurations.
- **Integration and Flexibility**: Offers a user-friendly interface to combine various detector noise models, waveform models, detector configurations, and signal parameters.
These capabilities make `gwsnr` an invaluable tool for GW data analysis, particularly for determining the rates of lensed and unlensed GW events (as demonstrated by its use in the [ler](https://ler.readthedocs.io/en/latest/) package and related works), and for modeling selection biases in hierarchical Bayesian frameworks.
## Documentation
The `gwsnr` package documentation is available at [ReadTheDocs](https://gwsnr.readthedocs.io/en/latest/).
Raw data
{
"_id": null,
"home_page": "https://github.com/hemantaph/gwsnr",
"name": "gwsnr",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "Hemantakumar Phurailatpam <hemantaphurailatpam@gmail.com>",
"keywords": "gravitational-waves, signal-processing, physics, astronomy",
"author": "Hemantakumar Phurailatpam",
"author_email": "Hemantakumar Phurailatpam <hemantaphurailatpam@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/a7/e9/439042135dde225ba20da2d1f5faf60c24849aecd3979c645e8122ec1200/gwsnr-0.3.6.tar.gz",
"platform": null,
"description": "# gwsnr: Gravitational Wave Signal-to-Noise Ratio Computation Package\n[]() [](https://badge.fury.io/py/gwsnr) [](https://gwsnr.readthedocs.io/en/latest/)\n\n<p align=\"center\">\n <img src=\"docs/_static/logo.svg\" alt=\"Your Logo\" width=\"200\" height=\"200\">\n</p>\n\n## Installation\n\n```bash\npip install gwsnr\n```\n\n## Example Usage\n\n```python\nfrom gwsnr import GWSNR\ngwsnr = GWSNR()\nsnrs = gwsnr.snr(mass_1=30, mass_2=30, distance=1000, psi=0.0, phase=0.0, geocent_time=1246527224.169434, ra=0.0, dec=0.0)\nprint(f\"SNR value: {snrs}\")\n```\n\n## Summary\n\nGravitational waves (GWs)\u2014ripples in spacetime predicted by Einstein\u2019s theory of General Relativity\u2014have revolutionized astrophysics since their first direct detection in 2015. These signals, emitted by the mergers of compact objects such as binary black holes (BBHs), binary neutron stars (BNSs), and black hole\u2013neutron star pairs, provide unique insights into the universe. A central quantity in GW data analysis is the **signal-to-noise ratio** (SNR), which quantifies the strength of a GW signal relative to the noise in detectors like LIGO, Virgo, and KAGRA. Reliable SNR estimation is essential for confirming GW detections and performing astrophysical inference. However, modern GW research\u2014especially in population simulations and hierarchical Bayesian inference with selection effects\u2014requires the computation of SNRs for vast numbers of systems, making traditional methods based on noise-weighted inner products prohibitively slow.\n\nThe **`gwsnr`** Python package addresses this computational bottleneck, offering a flexible, high-performance, and user-friendly framework for SNR and probability of detection ($P_{\\rm det}$) estimation. At its core, `gwsnr` leverages [NumPy](https://numpy.org/) vectorization along with Just-In-Time (JIT) compilation via [Numba](https://numba.pydata.org/) and [JAX](https://github.com/google/jax), as well as Python multiprocessing, to deliver exceptional performance.\n\n### Key Features\n\n- **Noise-Weighted Inner Product with Multiprocessing**: Provides accurate SNR calculations for arbitrary frequency-domain waveforms, including those with spin precession and higher-order harmonics available in [lalsimulation](https://lscsoft.docs.ligo.org/lalsuite/lalsimulation/modules.html). The method is enhanced with multiprocessing and JIT compilation to accelerate computation, with optional support for JAX-based waveform libraries like [ripple](https://github.com/tedwards2412/ripple).\n\n- **Partial Scaling Interpolation**: An innovative and highly efficient interpolation method for accurately calculating the SNR of non-precessing (spinless or aligned-spin) binary systems. This approach dramatically reduces computation time, making large-scale analyses practical.\n\n- **ANN-Based $P_{\\rm det}$ Estimation**: Employs a trained Artificial Neural Network (ANN) to provide fast probability of detection ($P_{\\rm det}$) estimates via SNR calculations for precessing BBH systems. This feature is especially valuable when rapid detection assessments are needed without requiring precise SNR values.\n\n- **Hybrid SNR Recalculation**: A balanced approach that combines the speed of the partial scaling method (or ANN-based estimation) with the precision of the noise-weighted inner product, ensuring high accuracy for systems near the detection threshold.\n\n- **Horizon Distance Calculation**: Implements both analytical and numerical methods to compute the horizon distance for gravitational wave sources, allowing users to assess detector sensitivity and detection capabilities across various configurations.\n\n- **Integration and Flexibility**: Offers a user-friendly interface to combine various detector noise models, waveform models, detector configurations, and signal parameters.\n\nThese capabilities make `gwsnr` an invaluable tool for GW data analysis, particularly for determining the rates of lensed and unlensed GW events (as demonstrated by its use in the [ler](https://ler.readthedocs.io/en/latest/) package and related works), and for modeling selection biases in hierarchical Bayesian frameworks.\n\n## Documentation\n\nThe `gwsnr` package documentation is available at [ReadTheDocs](https://gwsnr.readthedocs.io/en/latest/).\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python package for calculating gravitational wave signal-to-noise ratios",
"version": "0.3.6",
"project_urls": {
"Bug Tracker": "https://github.com/hemantaph/gwsnr/issues",
"Documentation": "https://gwsnr.readthedocs.io",
"Homepage": "https://github.com/hemantaph/gwsnr",
"Repository": "https://github.com/hemantaph/gwsnr"
},
"split_keywords": [
"gravitational-waves",
" signal-processing",
" physics",
" astronomy"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "0c610cccf07b75c73da251491a82fa482424b71c53b89ed3994c2f84ee6a93bf",
"md5": "db86eae8b1fa0b785aba6c0e1c10e750",
"sha256": "e5281fa1d0b07d4b8f558bf2952eb2461f69415317b149fd1007cd2ec69cdd1c"
},
"downloads": -1,
"filename": "gwsnr-0.3.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "db86eae8b1fa0b785aba6c0e1c10e750",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 13946931,
"upload_time": "2025-08-13T13:37:29",
"upload_time_iso_8601": "2025-08-13T13:37:29.224068Z",
"url": "https://files.pythonhosted.org/packages/0c/61/0cccf07b75c73da251491a82fa482424b71c53b89ed3994c2f84ee6a93bf/gwsnr-0.3.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "a7e9439042135dde225ba20da2d1f5faf60c24849aecd3979c645e8122ec1200",
"md5": "b29b5e408cf4848e706f5fa428c08b83",
"sha256": "4490d03e3afb653270bdcab8abfc174423dd544cd6d45dfc065b2222c1207ffe"
},
"downloads": -1,
"filename": "gwsnr-0.3.6.tar.gz",
"has_sig": false,
"md5_digest": "b29b5e408cf4848e706f5fa428c08b83",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 13836439,
"upload_time": "2025-08-13T13:37:46",
"upload_time_iso_8601": "2025-08-13T13:37:46.502547Z",
"url": "https://files.pythonhosted.org/packages/a7/e9/439042135dde225ba20da2d1f5faf60c24849aecd3979c645e8122ec1200/gwsnr-0.3.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-13 13:37:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hemantaph",
"github_project": "gwsnr",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "setuptools",
"specs": [
[
">=",
"80.9.0"
]
]
},
{
"name": "absl-py",
"specs": [
[
">=",
"2.1.0"
]
]
},
{
"name": "astropy",
"specs": [
[
">=",
"6.1.7"
]
]
},
{
"name": "astropy-iers-data",
"specs": [
[
">=",
"0.2025.6.9.14.9.37"
]
]
},
{
"name": "astunparse",
"specs": [
[
">=",
"1.6.3"
]
]
},
{
"name": "attrs",
"specs": [
[
">=",
"25.3.0"
]
]
},
{
"name": "beautifulsoup4",
"specs": [
[
">=",
"4.13.4"
]
]
},
{
"name": "bilby",
"specs": [
[
">=",
"2.5.2"
]
]
},
{
"name": "bilby.cython",
"specs": [
[
">=",
"0.5.3"
]
]
},
{
"name": "certifi",
"specs": [
[
">=",
"2024.2.2"
]
]
},
{
"name": "cffi",
"specs": [
[
">=",
"1.17.1"
]
]
},
{
"name": "charset-normalizer",
"specs": [
[
">=",
"3.3.2"
]
]
},
{
"name": "click",
"specs": [
[
">=",
"8.2.1"
]
]
},
{
"name": "contourpy",
"specs": [
[
">=",
"1.3.2"
]
]
},
{
"name": "corner",
"specs": [
[
">=",
"2.2.3"
]
]
},
{
"name": "cryptography",
"specs": [
[
">=",
"45.0.4"
]
]
},
{
"name": "cycler",
"specs": [
[
">=",
"0.12.1"
]
]
},
{
"name": "Cython",
"specs": [
[
">=",
"3.1.2"
]
]
},
{
"name": "dateparser",
"specs": [
[
">=",
"1.2.1"
]
]
},
{
"name": "dill",
"specs": [
[
">=",
"0.4.0"
]
]
},
{
"name": "dqsegdb2",
"specs": [
[
">=",
"1.3.0"
]
]
},
{
"name": "dynesty",
"specs": [
[
">=",
"2.1.5"
]
]
},
{
"name": "emcee",
"specs": [
[
">=",
"3.1.6"
]
]
},
{
"name": "flatbuffers",
"specs": [
[
">=",
"24.3.25"
]
]
},
{
"name": "fonttools",
"specs": [
[
">=",
"4.58.3"
]
]
},
{
"name": "gast",
"specs": [
[
">=",
"0.6.0"
]
]
},
{
"name": "google-pasta",
"specs": [
[
">=",
"0.2.0"
]
]
},
{
"name": "grpcio",
"specs": [
[
">=",
"1.63.0"
]
]
},
{
"name": "gwdatafind",
"specs": [
[
">=",
"2.0.0"
]
]
},
{
"name": "gwosc",
"specs": [
[
">=",
"0.8.1"
]
]
},
{
"name": "gwpy",
"specs": [
[
">=",
"3.0.12"
]
]
},
{
"name": "h5py",
"specs": [
[
">=",
"3.11.0"
]
]
},
{
"name": "idna",
"specs": [
[
">=",
"3.7"
]
]
},
{
"name": "igwn-auth-utils",
"specs": [
[
">=",
"1.4.0"
]
]
},
{
"name": "igwn-segments",
"specs": [
[
">=",
"2.1.0"
]
]
},
{
"name": "jax",
"specs": [
[
">=",
"0.4.34"
]
]
},
{
"name": "jaxlib",
"specs": [
[
">=",
"0.4.34"
]
]
},
{
"name": "Jinja2",
"specs": [
[
">=",
"3.1.6"
]
]
},
{
"name": "joblib",
"specs": [
[
">=",
"1.5.1"
]
]
},
{
"name": "keras",
"specs": [
[
">=",
"3.10.0"
]
]
},
{
"name": "keras-nightly",
"specs": [
[
">=",
"3.3.3.dev2024051503"
]
]
},
{
"name": "kiwisolver",
"specs": [
[
">=",
"1.4.8"
]
]
},
{
"name": "lalsuite",
"specs": [
[
">=",
"7.26.1"
]
]
},
{
"name": "libclang",
"specs": [
[
">=",
"18.1.1"
]
]
},
{
"name": "ligo-segments",
"specs": [
[
">=",
"1.4.0"
]
]
},
{
"name": "ligotimegps",
"specs": [
[
">=",
"2.0.1"
]
]
},
{
"name": "llvmlite",
"specs": [
[
">=",
"0.44.0"
]
]
},
{
"name": "lscsoft-glue",
"specs": [
[
">=",
"4.1.0"
]
]
},
{
"name": "Mako",
"specs": [
[
">=",
"1.3.10"
]
]
},
{
"name": "Markdown",
"specs": [
[
">=",
"3.6"
]
]
},
{
"name": "markdown-it-py",
"specs": [
[
">=",
"3.0.0"
]
]
},
{
"name": "MarkupSafe",
"specs": [
[
">=",
"2.1.5"
]
]
},
{
"name": "matplotlib",
"specs": [
[
">=",
"3.10.3"
]
]
},
{
"name": "mdurl",
"specs": [
[
">=",
"0.1.2"
]
]
},
{
"name": "ml-dtypes",
"specs": [
[
">=",
"0.3.1"
]
]
},
{
"name": "mpld3",
"specs": [
[
">=",
"0.5.10"
]
]
},
{
"name": "namex",
"specs": [
[
">=",
"0.0.8"
]
]
},
{
"name": "numba",
"specs": [
[
">=",
"0.61.2"
]
]
},
{
"name": "numexpr",
"specs": [
[
">=",
"2.11.0"
]
]
},
{
"name": "numpy",
"specs": [
[
">=",
"1.26.4"
]
]
},
{
"name": "opt-einsum",
"specs": [
[
">=",
"3.3.0"
]
]
},
{
"name": "optree",
"specs": [
[
">=",
"0.11.0"
]
]
},
{
"name": "packaging",
"specs": [
[
">=",
"25.0"
]
]
},
{
"name": "pandas",
"specs": [
[
">=",
"2.3.0"
]
]
},
{
"name": "pegasus-wms.api",
"specs": [
[
">=",
"5.1.1"
]
]
},
{
"name": "pegasus-wms.common",
"specs": [
[
">=",
"5.1.1"
]
]
},
{
"name": "pillow",
"specs": [
[
">=",
"11.2.1"
]
]
},
{
"name": "protobuf",
"specs": [
[
">=",
"4.25.3"
]
]
},
{
"name": "pycparser",
"specs": [
[
">=",
"2.22"
]
]
},
{
"name": "pyerfa",
"specs": [
[
">=",
"2.0.1.5"
]
]
},
{
"name": "Pygments",
"specs": [
[
">=",
"2.18.0"
]
]
},
{
"name": "PyJWT",
"specs": [
[
">=",
"2.10.1"
]
]
},
{
"name": "pykerr",
"specs": [
[
">=",
"0.1.0"
]
]
},
{
"name": "pyparsing",
"specs": [
[
">=",
"3.2.3"
]
]
},
{
"name": "python-dateutil",
"specs": [
[
">=",
"2.9.0.post0"
]
]
},
{
"name": "pytz",
"specs": [
[
">=",
"2025.2"
]
]
},
{
"name": "PyYAML",
"specs": [
[
">=",
"6.0.2"
]
]
},
{
"name": "regex",
"specs": [
[
">=",
"2024.11.6"
]
]
},
{
"name": "requests",
"specs": [
[
">=",
"2.32.4"
]
]
},
{
"name": "rich",
"specs": [
[
">=",
"13.7.1"
]
]
},
{
"name": "ripplegw",
"specs": [
[
">=",
"0.0.9"
]
]
},
{
"name": "safe-netrc",
"specs": [
[
">=",
"1.0.1"
]
]
},
{
"name": "scikit-learn",
"specs": [
[
">=",
"1.7.0"
]
]
},
{
"name": "scipy",
"specs": [
[
">=",
"1.15.3"
]
]
},
{
"name": "scitokens",
"specs": [
[
">=",
"1.8.1"
]
]
},
{
"name": "six",
"specs": [
[
">=",
"1.16.0"
]
]
},
{
"name": "soupsieve",
"specs": [
[
">=",
"2.7"
]
]
},
{
"name": "tensorboard",
"specs": [
[
">=",
"2.17.1"
]
]
},
{
"name": "tensorboard-data-server",
"specs": [
[
">=",
"0.7.2"
]
]
},
{
"name": "tensorflow",
"specs": [
[
">=",
"2.17.1"
]
]
},
{
"name": "tensorflow-io-gcs-filesystem",
"specs": [
[
">=",
"0.37.0"
]
]
},
{
"name": "termcolor",
"specs": [
[
">=",
"2.4.0"
]
]
},
{
"name": "threadpoolctl",
"specs": [
[
">=",
"3.6.0"
]
]
},
{
"name": "tqdm",
"specs": [
[
">=",
"4.67.1"
]
]
},
{
"name": "typing_extensions",
"specs": [
[
">=",
"4.14.0"
]
]
},
{
"name": "tzdata",
"specs": [
[
">=",
"2025.2"
]
]
},
{
"name": "tzlocal",
"specs": [
[
">=",
"5.3.1"
]
]
},
{
"name": "urllib3",
"specs": [
[
">=",
"2.2.1"
]
]
},
{
"name": "Werkzeug",
"specs": [
[
">=",
"3.0.3"
]
]
},
{
"name": "wrapt",
"specs": [
[
">=",
"1.16.0"
]
]
}
],
"lcname": "gwsnr"
}