ler.image_properties.image_properties
Module for computing image properties of strongly lensed gravitational wave events.
This module contains the ImageProperties class, which computes image positions, magnifications, time delays, and other lensing-related quantities for gravitational wave sources that are strongly lensed by intervening galaxies. The class uses multiprocessing to efficiently solve lens equations for large samples.
- Usage:
Basic workflow example:
>>> from ler.image_properties import ImageProperties >>> ip = ImageProperties() >>> lens_parameters = dict(zs=np.array([2.0]), zl=np.array([0.5]), ...) >>> result = ip.image_properties(lens_parameters)
Copyright (C) 2026 Phurailatpam Hemantakumar. Distributed under MIT License.
Module Contents
Classes
Class to compute image properties of strongly lensed gravitational wave events. |
Attributes
- class ler.image_properties.image_properties.ImageProperties(npool=4, n_min_images=2, n_max_images=4, lens_model_list=['EPL_NUMBA', 'SHEAR'], image_properties_function='image_properties_epl_shear', image_properties_function_params=None, cosmology=None, time_window=365 * 24 * 3600 * 2, spin_zero=True, spin_precession=False, pdet_finder=None, include_effective_parameters=False, multiprocessing_verbose=True, include_redundant_parameters=False)[source]
Class to compute image properties of strongly lensed gravitational wave events.
This class solves the lens equation to find image positions, magnifications, time delays, and image types (morse phase) for strongly lensed sources. It uses multiprocessing for efficient computation of large samples.
Key Features:
Solves lens equations using multiprocessing for efficiency
Computes image positions, magnifications, and time delays
Classifies image types using morse phase
Calculates detection probabilities for lensed images
- Parameters:
- npool
int Number of processes for multiprocessing.
default: 4
- n_min_images
int Minimum number of images required for a valid lensing event.
default: 2
- n_max_images
int Maximum number of images to consider per event.
default: 4
- time_window
float Time window for lensed events from min(geocent_time) (units: seconds).
default: 365*24*3600*2 (2 years)
- include_effective_parameters
bool Whether to include effective parameters (effective_phase, effective_ra, effective_dec) in the output.
default: True
- lens_model_list
list List of lens models to use.
default: [‘EPL_NUMBA’, ‘SHEAR’]
- cosmology
astropy.cosmologyorNone Cosmology for distance calculations.
If None, uses default LambdaCDM.
default: LambdaCDM(H0=70, Om0=0.3, Ode0=0.7, Tcmb0=0.0, Neff=3.04, m_nu=None, Ob0=0.0)
- spin_zero
bool If True, spin parameters are set to zero (no spin sampling).
default: False
- spin_precession
bool If True (and spin_zero=False), sample precessing spin parameters.
If False (and spin_zero=False), sample aligned/anti-aligned spins.
default: False
- multiprocessing_verbose
bool If True, shows a progress bar for multiprocessing tasks.
default: True
- include_redundant_parameters
bool If True, removes redundant parameters (e.g., theta_E, n_images, mass_1, mass_2, luminosity_distance) from output to save memory.
- npool
Examples
Basic usage:
>>> from ler.image_properties import ImageProperties >>> ip = ImageProperties() >>> lens_parameters = dict( ... zs=np.array([2.0]), ... zl=np.array([0.5]), ... gamma1=np.array([0.0]), ... gamma2=np.array([0.0]), ... phi=np.array([0.0]), ... q=np.array([0.8]), ... gamma=np.array([2.0]), ... theta_E=np.array([1.0]) ... ) >>> result = ip.image_properties(lens_parameters) >>> print(result.keys())
Instance Methods
ImageProperties has the following methods:
Method
Description
Compute image properties for lensed events
Compute detection probability for lensed images
Instance Attributes
ImageProperties has the following attributes:
Attribute
Type
Unit
Description
intNumber of multiprocessing workers
boolIf True, shows a progress bar for multiprocessing tasks
intMinimum number of images required
intMaximum number of images per event
floats
Time window for lensed events
boolTo include effective parameters in output
boolIf True, removes redundant parameters from output to save memory
listList of lens models
astropy.cosmologyCosmology for calculations
boolFlag for zero spin assumption
boolFlag for spin precession
callableProbability of detection calculator
listKeys for probability of detection outputs
- property npool[source]
Number of multiprocessing workers.
- Returns:
- npool
int Number of processes for multiprocessing.
default: 4
- npool
- property n_min_images[source]
Minimum number of images required for a valid lensing event.
- Returns:
- n_min_images
int Minimum number of images required.
default: 2
- n_min_images
- property n_max_images[source]
Maximum number of images per event.
- Returns:
- n_max_images
int Maximum number of images to consider per event.
default: 4
- n_max_images
- property lens_model_list[source]
List of lens models to use.
- Returns:
- lens_model_list
list List of lens model names.
default: [‘EPL_NUMBA’, ‘SHEAR’]
- lens_model_list
- property spin_zero[source]
Flag for zero spin assumption.
- Returns:
- spin_zero
bool Whether to assume zero spin for compact objects.
If True, spin parameters are set to zero (no spin sampling).
If False, spin parameters are sampled.
default: False
- spin_zero
- property spin_precession[source]
Flag for spin precession.
- Returns:
- spin_precession
bool Whether to include spin precession effects.
If True (and spin_zero=False), sample precessing spin parameters.
If False (and spin_zero=False), sample aligned/anti-aligned spins.
default: False
- spin_precession
- property time_window[source]
Time window for lensed events.
- Returns:
- time_window
float Time window for lensed events (units: s).
default: 365*24*3600*20 (20 years)
- time_window
- property cosmo[source]
Astropy cosmology object for calculations.
- Returns:
- cosmo
astropy.cosmology Cosmology used for distance calculations.
default: LambdaCDM(H0=70, Om0=0.3, Ode0=0.7, Tcmb0=0.0, Neff=3.04, m_nu=None, Ob0=0.0)
- cosmo
- property pdet_finder[source]
Detection probability finder function.
- Returns:
- pdet_finder
callable Function that calculates detection probability for GW events.
The function signature should be:
pdet_finder(gw_param_dict) -> dictwith key ‘pdet_net’.
- pdet_finder
- property pdet_finder_output_keys[source]
Output keys from the detection probability finder function.
- Returns:
- pdet_finder_output_keys
list List of keys returned by the pdet_finder function.
default: None
- pdet_finder_output_keys
- property include_effective_parameters[source]
Flag to include effective parameters in output.
- Returns:
- include_effective_parameters
bool Whether to include effective parameters in the output of get_lensed_snrs.
default: False
- include_effective_parameters
- property available_image_properties_functions[source]
Dictionary of available functions for computing image properties.
- Returns:
- available_image_properties_functions
dict Dictionary with function names and default parameters.
- available_image_properties_functions
- image_properties_epl_shear_njit(lens_parameters)[source]
Compute image properties for strongly lensed events. This use functions similar to lenstronomy but rewritten in numba njit for speed.
Solves the lens equation using multiprocessing to find image positions, magnifications, time delays, and image types for each lensing event.
- Parameters:
- lens_parameters
dict Dictionary containing lens and source parameters shown in the table:
Parameter
Units
Description
zl
redshift of the lens
zs
redshift of the source
sigma
km s^-1
velocity dispersion
q
axis ratio
theta_E
radian
Einstein radius
phi
rad
axis rotation angle. counter-clockwise from the positive x-axis (RA-like axis) to the major axis of the projected mass distribution.
gamma
density profile slope of EPL galaxy
gamma1
external shear component in the x-direction (RA-like axis)
gamma2
external shear component in the y-direction (Dec-like axis)
- lens_parameters
- Returns:
- lens_parameters
dict Updated dictionary with additional image properties with the following description:
x0_image_positions
radian
x-coordinate (RA-like axis) of the images
x1_image_positions
radian
y-coordinate (Dec-like axis) of the images
magnifications
magnifications
time_delays
time delays
image_type
image type
n_images
number of images
x_source
radian
x-coordinate (RA-like axis) of the source
y_source
radian
y-coordinate (Dec-like axis) of the source
- lens_parameters
- image_properties_epl_shear(lens_parameters)[source]
Compute image properties for strongly lensed events. This use functions from lenstronomy.
Solves the lens equation using multiprocessing to find image positions, magnifications, time delays, and image types for each lensing event.
- Parameters:
- lens_parameters
dict Dictionary containing lens and source parameters shown in the table:
Parameter
Units
Description
zl
redshift of the lens
zs
redshift of the source
sigma
km s^-1
velocity dispersion
q
axis ratio
theta_E
radian
Einstein radius
phi
rad
axis rotation angle. counter-clockwise from the positive x-axis (RA-like axis) to the major axis of the projected mass distribution.
gamma
density profile slope of EPL galaxy
gamma1
external shear component in the x-direction (RA-like axis)
gamma2
external shear component in the y-direction (Dec-like axis)
- lens_parameters
- Returns:
- lens_parameters
dict Updated dictionary with additional image properties with the following description:
x0_image_positions
radian
x-coordinate (RA-like axis) of the images
x1_image_positions
radian
y-coordinate (Dec-like axis) of the images
magnifications
magnifications
time_delays
time delays
image_type
image type
n_images
number of images
x_source
radian
x-coordinate (RA-like axis) of the source
y_source
radian
y-coordinate (Dec-like axis) of the source
- lens_parameters
- get_lensed_snrs(lensed_param, pdet_finder=None, include_effective_parameters=False)[source]
Compute detection probability for each lensed image.
Calculates the effective luminosity distance, geocent time, and phase for each image accounting for magnification and morse phase, then computes detection probabilities using the provided calculator.
- Parameters:
- lensed_param
dict Dictionary containing lensed source and image parameters given below:
Parameter
Units
Description
geocent_time
s
geocent time
ra
rad
right ascension
dec
rad
declination
phase
rad
phase of GW at reference freq
psi
rad
polarization angle
theta_jn
rad
inclination angle
a_1
spin of the primary compact binary
a_2
spin of the secondary compact binary
luminosity_distance
Mpc
luminosity distance of the source
mass_1
Msun
mass of the primary compact binary (detector frame)
mass_2
Msun
mass of the secondary compact binary (detector frame)
x0_image_positions
radian
x-coordinate (RA-like axis) of the images
x1_image_positions
radian
y-coordinate (Dec-like axis) of the images
magnifications
magnifications
time_delays
time delays
image_type
image type
- pdet_finder
callable Function that computes detection probability given GW parameters.
- include_effective_parameters
bool If True, includes effective parameters in output lensed_param.
- lensed_param
- Returns:
- result_dict
dict Dictionary containing:
‘pdet_net’: network detection probability (shape: size x n_max_images)
Individual detector probabilities if pdet_finder outputs them
- lensed_param
dict Updated dictionary with effective parameters shown below:
Parameter
Units
Description
effective_luminosity_distance
Mpc
magnification-corrected distance luminosity_distance / sqrt(|magnifications_i|)
time-delay-corrected GPS time geocent_time + time_delays_i
morse-phase-corrected phase phi - morse_phase_i
effective_geocent_time
s
effective_phase
rad
effective_ra
rad
RA of the image ra + (x0_image_positions_i - x_source)/cos(dec)
effective_dec
rad
Dec of the image dec + (x1_image_positions_i - y_source)
- result_dict
- recover_redundant_parameters(lensed_param)[source]
Recover redundant parameters in lensed_param, i.e. theta_E, n_images, mass_1, mass_2, luminosity_distance.
- produce_effective_params(lensed_param)[source]
Produce effective parameters for each lensed image.
Calculates the effective luminosity distance, geocent time, phase, RA, and Dec for each image accounting for magnification and morse phase.
- Parameters:
- lensed_param
dict Dictionary containing lensed source and image parameters.
- lensed_param
- Returns:
- lensed_param
dict Updated dictionary with effective parameters shown below:
Parameter
Units
Description
effective_luminosity_distance
Mpc
magnification-corrected distance luminosity_distance / sqrt(|magnifications_i|)
time-delay-corrected GPS time geocent_time + time_delays_i
morse-phase-corrected phase phi - morse_phase_i
effective_geocent_time
s
effective_phase
rad
effective_ra
rad
RA of the image ra + (x0_image_positions_i - x_source)/cos(dec)
effective_dec
rad
Dec of the image dec + (x1_image_positions_i - y_source)
- lensed_param