Skip to main content

LeR

DOI PyPI version DOCS

ler logo

ler is a statistics-based Python package for simulating compact-binary gravitational-wave (GW) populations and calculating detectable event rates. It supports both unlensed and strongly lensed events, with workflows for source populations, lens populations, image properties, detector selection effects, and rate estimation.

ler is intended for gravitational-wave population studies, lensing studies, and forecasting for current and future detector networks.

Installation

ler supports Python 3.10+; Python 3.11 is recommended in the documentation.

Recommended installation with uv:

uv add ler

You can also install with pip:

pip install ler

For development, clone the repository and install in editable mode:

git clone https://github.com/hemantaph/ler.git
cd ler
pip install -e ".[dev]"

Quick start

from ler import LeR

ler = LeR(npool=4) # npool sets the number of parallel processes for sampling and integration. It should be set according to your system's capabilities.

# Generate simulated populations and save parameters in json files
unlensed_param = ler.unlensed_cbc_statistics(size=100000)
lensed_param = ler.lensed_cbc_statistics(size=100000)

# Calculate detectable rates, saving detected parameters in json files
unlensed_rate, unlensed_param_detected = ler.unlensed_rate()
lensed_rate, lensed_param_detected = ler.lensed_rate()

# Compare lensed and unlensed rates
ratio = ler.rate_ratio()

What ler does

  • samples compact-binary source populations, including BBH, BNS, and NSBH systems
  • calculates detectable unlensed gravitational-wave event rates
  • samples strongly lensed source and lens populations
  • computes lensing image properties such as magnifications and time delays
  • calculates detectable strongly lensed event rates using image-level detection criteria
  • supports configurable source, lens, and detection models
  • uses gwsnr for efficient signal-to-noise ratio and detection-probability calculations
  • uses lenstronomy and in-house EPL+Shear routines for lensing calculations
  • uses Monte Carlo integration, multiprocessing, and numba-compiled routines for large simulations

Method overview

Unlensed rates are estimated by drawing source parameters from astrophysical priors, evaluating the probability of detection, and averaging over the population:

$$ \frac{\Delta N^{\mathrm{obs}}{\mathrm{U}}}{\Delta t} = \mathcal{N}{\mathrm{U}} \bigg\langle P(\mathrm{obs} \mid \vec{\theta}) \bigg\rangle_{\vec{\theta} \sim P(\vec{\theta})} $$

Strongly lensed rates extend the same idea by sampling source redshift, lens redshift, lens parameters, and source position under the strong-lensing condition:

$$ \frac{\Delta N^{\mathrm{obs}}{\mathrm{L}}}{\Delta t} = \mathcal{N}{\mathrm{L}} \bigg\langle P(\mathrm{obs}\mid \vec{\theta}{\mathrm{U}}, \vec{\theta}{\mathrm{L}}, \vec{\beta}, \mathrm{SL}) \bigg\rangle_{\substack{ \vec{\theta}{\mathrm{U}},\vec{\theta}{\mathrm{L}} \sim P(\vec{\theta}{\mathrm{U}},\vec{\theta}{\mathrm{L}} \mid z_L, z_s, \mathrm{SL}) \ \vec{\beta} \sim P(\vec{\beta} \mid z_s, \vec{\theta}_{\mathrm{L}}, \mathrm{SL}) }} $$

The lensed workflow uses the optical depth, the multi-image caustic cross-section, lens-equation solutions, and a requirement that at least two lensed images satisfy the chosen detection criterion.

Documentation

The documentation is available at:

https://ler.hemantaph.com/

Useful sections include:

Community guidelines

Guidelines for contributing, reporting issues, and seeking support are available in CONTRIBUTING.md.

Issues can be reported at:

https://github.com/hemantaph/ler/issues

Citation

If ler supports your research, please cite the project as described in the documentation and repository metadata.

Metadata

Release files for ler 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ler 1.0.2
File Size Uploaded Provenance Actions
ler-1.0.2.tar.gz 12.2 MB Without provenance Details for ler-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ler 1.0.2
File Interpreter ABI Platform Actions
ler-1.0.2-py3-none-any.whl Python 3 none any Details for ler-1.0.2-py3-none-any.whl

Total release size: 24.5 MB

Release files / ler-1.0.2.tar.gz

Download URL ler-1.0.2.tar.gz
Size 12.2 MB
Tags Source
SHA-256 checksum
How to use checksums
aa7be9c0d719d1306f70d530ef1db2404ffa0c954d44b6990c325e002e7ca505
BLAKE2b-256 checksum
How to use checksums
1ad81ad2d5681e91e3de6fbcb505f714d4ff8c650b5cba4a5d99f1a7da5a873a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.18

Release files / ler-1.0.2-py3-none-any.whl

Download URL ler-1.0.2-py3-none-any.whl
Size 12.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
c3728505c70eb5d168c3bccedc5e93bf531669471a72001394b0f393aa7fad51
BLAKE2b-256 checksum
How to use checksums
cf9bf863cc2b17d5ab6f7e8d20d780b643d20910e1c357c04981ca9f312fa9bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.18

Security for ler 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page