lenstronomy.LensModel.MultiPlane package

Submodules

lenstronomy.LensModel.MultiPlane.multi_plane module

class MultiPlane(z_source, lens_model_list, lens_redshift_list, cosmo=None, numerical_alpha_class=None, observed_convention_index=None, ignore_observed_positions=False, z_source_convention=None, z_lens_convention=None, cosmo_interp=False, z_interp_stop=None, num_z_interp=100, kwargs_interp=None, kwargs_synthesis=None, distance_ratio_sampling=False)[source]

Bases: object

Multi-plane lensing class with option to assign positions of a selected set of lens models in the observed plane.

The lens model deflection angles are in units of reduced deflections from the specified redshift of the lens to the source redshift of the class instance.

__init__(z_source, lens_model_list, lens_redshift_list, cosmo=None, numerical_alpha_class=None, observed_convention_index=None, ignore_observed_positions=False, z_source_convention=None, z_lens_convention=None, cosmo_interp=False, z_interp_stop=None, num_z_interp=100, kwargs_interp=None, kwargs_synthesis=None, distance_ratio_sampling=False)[source]
Parameters:
  • z_source – source redshift for default computation of reduced lensing quantities

  • lens_model_list – list of lens model strings

  • lens_redshift_list – list of floats with redshifts of the lens models indicated in lens_model_list

  • cosmo – instance of astropy.cosmology

  • numerical_alpha_class – an instance of a custom class for use in NumericalAlpha() lens model (see documentation in Profiles/numerical_alpha)

  • kwargs_interp – interpolation keyword arguments specifying the numerics. See description in the Interpolate() class. Only applicable for ‘INTERPOL’ and ‘INTERPOL_SCALED’ models.

  • observed_convention_index – a list of indices, corresponding to the lens_model_list element with same index, where the ‘center_x’ and ‘center_y’ kwargs correspond to observed (lensed) positions, not physical positions. The code will compute the physical locations when performing computations

  • ignore_observed_positions – bool, if True, will ignore the conversion between observed to physical position of deflectors

  • z_source_convention – float, redshift of a source to define the reduced deflection angles of the lens

models. If None, ‘z_source’ is used. :param z_lens_convention: float, redshift of a lens plane to define the effective time-delay distance. Only needed if distance ratios are sampled. If None, the first lens redshift is used. :param kwargs_synthesis: keyword arguments for the ‘SYNTHESIS’ lens model, if applicable :param distance_ratio_sampling: bool, if True, will use sampled distance ratios to update T_ij value in multi-lens plane computation.

update_source_redshift(z_source)[source]

Update instance of this class to compute reduced lensing quantities and time delays to a specific source redshift.

Parameters:

z_source – float; source redshift

Returns:

self variables update to new redshift

property multi_plane_base
property z_source
property z_source_convention
property z_lens_convention
property T_ij_start
property T_ij_stop
observed2flat_convention(kwargs_lens)[source]
Parameters:

kwargs_lens – keyword argument list of lens model parameters in the observed convention

Returns:

kwargs_lens positions mapped into angular position without lensing along its LOS

ray_shooting(theta_x, theta_y, kwargs_lens, check_convention=True, k=None)[source]

Ray-tracing (backwards light cone) to the default z_source redshift.

Parameters:
  • theta_x – angle in x-direction on the image (usually arc seconds, in the same convention as lensing deflection angles)

  • theta_y – angle in y-direction on the image (usually arc seconds, in the same convention as lensing deflection angles)

  • kwargs_lens – lens model keyword argument list

  • check_convention – flag to check the image position convention (leave this alone)

Returns:

angles in the source plane

ray_shooting_partial(theta_x, theta_y, alpha_x, alpha_y, z_start, z_stop, kwargs_lens, include_z_start=False, T_ij_start=None, T_ij_end=None, check_convention=True)[source]

Ray-tracing through parts of the cone, starting with (x,y) in angular units as seen on the sky without lensing and angles (alpha_x, alpha_y) as seen at redshift z_start and then backwards to redshift z_stop.

Parameters:
  • theta_x – angular position on the sky [arcsec]

  • theta_y – angular position on the sky [arcsec]

  • alpha_x – ray angle at z_start [arcsec]

  • alpha_y – ray angle at z_start [arcsec]

  • z_start – redshift of start of computation

  • z_stop – redshift where output is computed

  • kwargs_lens – lens model keyword argument list

  • include_z_start – bool, if True, includes the computation of the deflection angle at the same redshift as the start of the ray-tracing. ATTENTION: deflection angles at the same redshift as z_stop will be computed always! This can lead to duplications in the computation of deflection angles.

  • T_ij_start – transverse angular distance between the starting redshift to the first lens plane to follow. If not set, will compute the distance each time this function gets executed.

  • T_ij_end – transverse angular distance between the last lens plane being computed and z_end. If not set, will compute the distance each time this function gets executed.

  • check_convention – flag to check the image position convention (leave this alone)

Returns:

angular position and angles at redshift z_stop

ray_shooting_partial_comoving(x, y, alpha_x, alpha_y, z_start, z_stop, kwargs_lens, include_z_start=False, check_convention=True, T_ij_start=None, T_ij_end=None)[source]

Ray-tracing through parts of the cone, starting with (x,y) co-moving distances and angles (alpha_x, alpha_y) at redshift z_start and then backwards to redshift z_stop.

Parameters:
  • x – co-moving position [Mpc] / angle definition

  • y – co-moving position [Mpc] / angle definition

  • alpha_x – ray angle at z_start [arcsec]

  • alpha_y – ray angle at z_start [arcsec]

  • z_start – redshift of start of computation

  • z_stop – redshift where output is computed

  • kwargs_lens – lens model keyword argument list

  • include_z_start – bool, if True, includes the computation of the deflection angle at the same redshift as the start of the ray-tracing. ATTENTION: deflection angles at the same redshift as z_stop will be computed! This can lead to duplications in the computation of deflection angles.

  • check_convention – flag to check the image position convention (leave this alone)

  • T_ij_start – transverse angular distance between the starting redshift to the first lens plane to follow. If not set, will compute the distance each time this function gets executed.

  • T_ij_end – transverse angular distance between the last lens plane being computed and z_end. If not set, will compute the distance each time this function gets executed.

Returns:

co-moving position (modulo angle definition) and angles at redshift z_stop

transverse_distance_start_stop(z_start, z_stop, include_z_start=False)[source]

Computes the transverse distance (T_ij) that is required by the ray-tracing between the starting redshift and the first deflector afterwards and the last deflector before the end of the ray-tracing.

Parameters:
  • z_start – redshift of the start of the ray-tracing

  • z_stop – stop of ray-tracing

  • include_z_start – bool, i

Returns:

T_ij_start, T_ij_end

arrival_time(theta_x, theta_y, kwargs_lens, check_convention=True)[source]

Light travel time relative to a straight path through the coordinate (0,0) Negative sign means earlier arrival time.

Parameters:
  • theta_x – angle in x-direction on the image

  • theta_y – angle in y-direction on the image

  • kwargs_lens – lens model keyword argument list

Returns:

travel time in unit of days

geo_shapiro_delay(theta_x, theta_y, kwargs_lens, check_convention=True)[source]

Geometric and Shapiro (gravitational) light travel time relative to a straight path through the coordinate (0,0) Negative sign means earlier arrival time.

Parameters:
  • theta_x – angle in x-direction on the image

  • theta_y – angle in y-direction on the image

  • kwargs_lens – lens model keyword argument list

  • check_convention – boolean, if True goes through the lens model list and checks whether the positional conventions are satisfied.

Returns:

geometric delay, gravitational delay [days]

alpha(theta_x, theta_y, kwargs_lens, check_convention=True, k=None)[source]

Reduced deflection angle.

Parameters:
  • theta_x – angle in x-direction

  • theta_y – angle in y-direction

  • kwargs_lens – lens model kwargs

  • check_convention – flag to check the image position convention (leave this alone)

Returns:

deflection angles in x and y directions

hessian(theta_x, theta_y, kwargs_lens, k=None, diff=1e-08, check_convention=True)[source]

Computes the hessian components f_xx, f_yy, f_xy from f_x and f_y with numerical differentiation.

Parameters:
  • theta_x (numpy array) – x-position (preferentially arcsec)

  • theta_y (numpy array) – y-position (preferentially arcsec)

  • kwargs_lens – list of keyword arguments of lens model parameters matching the lens model classes

  • diff – numerical differential step (float)

  • check_convention – boolean, if True goes through the lens model list and checks whether the positional conventions are satisfied.

Returns:

f_xx, f_xy, f_yx, f_yy

hessian_z1z2(z1, z2, theta_x, theta_y, kwargs_lens, diff=1e-08)[source]

Computes Hessian matrix when Observed at z1 with rays going to z2 with z1 < z2.

Parameters:
  • z1 – Observer redshift

  • z2 – source redshift

  • theta_x – angular position and direction of the ray

  • theta_y – angular position and direction of the ray

  • kwargs_lens – list of keyword arguments of lens model parameters matching the lens model classes

  • diff – numerical differential step (float)

Returns:

f_xx, f_xy, f_yx, f_yy

co_moving2angle_z1_z2(x, y, z1, z2)[source]

Computes angle for co-moving distance at z=z2 when seen from z=z1.

Parameters:
  • x – co-moving distance at z=z2

  • y – co-moving distance at z=z2

  • z1 – redshift of observer

  • z2 – redshift of source

Returns:

theta_z, theta_y

co_moving2angle_source(x, y)[source]

Special case of the co_moving2angle definition at the source redshift.

Parameters:
  • x – co-moving distance

  • y – co-moving distance

Returns:

angles on the sky at the nominal source plane

set_static(kwargs)[source]
Parameters:

kwargs – lens model keyword argument list

Returns:

lens model keyword argument list with positional parameters all in flat sky coordinates

set_dynamic()[source]
Returns:

class PhysicalLocation[source]

Bases: object

center_x and center_y kwargs correspond to angular location of deflectors without lensing along the LOS.

class LensedLocation(multiplane_instance, observed_convention_index)[source]

Bases: object

center_x and center_y kwargs correspond to observed (lensed) locations of deflectors given a model for the line of sight structure, compute the angular position of the deflector without lensing contribution along the LOS.

__init__(multiplane_instance, observed_convention_index)[source]
Parameters:
  • multiplane_instance – instance of the MultiPlane class

  • observed_convention_index – list of lens model indexes to be modelled in the observed plane

lenstronomy.LensModel.MultiPlane.multi_plane_base module

class MultiPlaneBase(lens_model_list, lens_redshift_list, z_source_convention, cosmo=None, numerical_alpha_class=None, cosmo_interp=False, z_interp_stop=None, num_z_interp=100, kwargs_interp=None, kwargs_synthesis=None)[source]

Bases: ProfileListBase

Multi-plane lensing class.

The lens model deflection angles are in units of reduced deflections from the specified redshift of the lens to the source redshift of the class instance.

__init__(lens_model_list, lens_redshift_list, z_source_convention, cosmo=None, numerical_alpha_class=None, cosmo_interp=False, z_interp_stop=None, num_z_interp=100, kwargs_interp=None, kwargs_synthesis=None)[source]

A description of the recursive multi-plane formalism can be found e.g. here: https://arxiv.org/abs/1312.1536

Parameters:
  • lens_model_list – list of lens model strings

  • lens_redshift_list – list of floats with redshifts of the lens models indicated in lens_model_list

  • z_source_convention – float, redshift of a source to define the reduced deflection angles of the lens models. If None, ‘z_source’ is used.

  • cosmo – instance of astropy.cosmology

  • numerical_alpha_class – an instance of a custom class for use in NumericalAlpha() lens model (see documentation in Profiles/numerical_alpha)

  • kwargs_interp – interpolation keyword arguments specifying the numerics. See description in the Interpolate() class. Only applicable for ‘INTERPOL’ and ‘INTERPOL_SCALED’ models.

  • kwargs_synthesis – keyword arguments for the ‘SYNTHESIS’ lens model, if applicable

property z_source_convention

Redshift of the source to define the reduced deflection angles of the lens models.

property sorted_redshift_index

List of lens indices in the sorted redshift order.

property T_z_list

List of transverse angular diameter distances between the observer and the lens planes.

property T_ij_list

List of transverse angular diameter distances between the lens planes.

ray_shooting_partial_comoving(x, y, alpha_x, alpha_y, z_start, z_stop, kwargs_lens, include_z_start=False, T_ij_start=None, T_ij_end=None)[source]

Ray-tracing through parts of the cone, starting with (x,y) co-moving distances and angles (alpha_x, alpha_y) at redshift z_start and then backwards to redshift z_stop.

Parameters:
  • x – co-moving position [Mpc]

  • y – co-moving position [Mpc]

  • alpha_x – ray angle at z_start [arcsec]

  • alpha_y – ray angle at z_start [arcsec]

  • z_start – redshift of start of computation

  • z_stop – redshift where output is computed

  • kwargs_lens – lens model keyword argument list

  • include_z_start – bool, if True, includes the computation of the deflection angle at the same redshift as the start of the ray-tracing. ATTENTION: deflection angles at the same redshift as z_stop will be computed always! This can lead to duplications in the computation of deflection angles.

  • T_ij_start – transverse angular distance between the starting redshift to the first lens plane to follow. If not set, will compute the distance each time this function gets executed.

  • T_ij_end – transverse angular distance between the last lens plane being computed and z_end. If not set, will compute the distance each time this function gets executed.

Returns:

co-moving position and angles at redshift z_stop

ray_shooting_partial(theta_x, theta_y, alpha_x, alpha_y, z_start, z_stop, kwargs_lens, include_z_start=False, T_ij_start=None, T_ij_end=None, T_z_start=None, T_z_stop=None)[source]

Ray-tracing through parts of the coin, starting with (x,y) in angular units as seen on the sky without lensing and angles (alpha_x, alpha_y) as seen at redshift z_start and then backwards to redshift z_stop.

Parameters:
  • theta_x – angular position on the sky [arcsec]

  • theta_y – angular position on the sky [arcsec]

  • alpha_x – ray angle at z_start [arcsec]

  • alpha_y – ray angle at z_start [arcsec]

  • z_start – redshift of start of computation

  • z_stop – redshift where output is computed

  • kwargs_lens – lens model keyword argument list

  • include_z_start – bool, if True, includes the computation of the deflection angle at the same redshift as the start of the ray-tracing. ATTENTION: deflection angles at the same redshift as z_stop will be computed always! This can lead to duplications in the computation of deflection angles.

  • T_ij_start – transverse angular distance between the starting redshift to the first lens plane to follow. If not set, will compute the distance each time this function gets executed.

  • T_ij_end – transverse angular distance between the last lens plane being computed and z_end. If not set, will compute the distance each time this function gets executed.

  • T_z_start – transverse angular distance up to z_start. If not set, will compute the distance each time this function gets executed.

  • T_z_stop – transverse angular distance up to z_stop. If not set, will compute the distance each time this function gets executed.

Returns:

angular position and angles at redshift z_stop

transverse_distance_start_stop(z_start, z_stop, include_z_start=False)[source]

Computes the transverse distance (T_ij) that is required by the ray-tracing between the starting redshift and the first deflector afterwards and the last deflector before the end of the ray-tracing.

Parameters:
  • z_start – redshift of the start of the ray-tracing

  • z_stop – stop of ray-tracing

  • include_z_start – boolean, if True includes the computation of the starting position if the first deflector is at z_start

Returns:

T_ij_start, T_ij_end

geo_shapiro_delay(theta_x, theta_y, kwargs_lens, z_stop, T_z_stop=None, T_ij_end=None)[source]

Geometric and Shapiro (gravitational) light travel time relative to a straight path through the coordinate (0,0) Negative sign means earlier arrival time.

Parameters:
  • theta_x – angle in x-direction on the image

  • theta_y – angle in y-direction on the image

  • kwargs_lens – lens model keyword argument list

  • z_stop – redshift of the source to stop the backwards ray-tracing

  • T_z_stop – optional, transversal angular distance from z=0 to z_stop

  • T_ij_end – optional, transversal angular distance between the last lensing plane and the source plane

Returns:

dt_geo, dt_shapiro, [days]

Module contents