caustics.lenses.func package

Contents

caustics.lenses.func package#

Submodules#

caustics.lenses.func.base module#

caustics.lenses.func.base.forward_raytrace(s, raytrace, x0, y0, fov, n, epsilon, max_depth=25)[source]#
caustics.lenses.func.base.forward_raytrace_rootfind(ix, iy, bx, by, raytrace)[source]#

Perform a forward ray-tracing operation which maps from the source plane to the image plane.

Parameters:
  • ix (ArrayLike) –

    ArrayLike of x coordinate in the image plane. This initializes the ray-tracing optimization. Should have shape (B, 2).

    Unit: arcsec

  • iy (ArrayLike) – ArrayLike of y coordinate in the image plane. This initializes the ray-tracing optimization. Should have shape (B, 2).

  • bx (ArrayLike) –

    ArrayLike of x coordinate in the source plane. Should be a scalar.

    Unit: arcsec

  • by (ArrayLike) –

    ArrayLike of y coordinate in the source plane. Should be a scalar.

    Unit: arcsec

  • raytrace (function) – function that takes in the x and y coordinates in the image plane and returns the x and y coordinates in the source plane.

Returns:

  • x_component (ArrayLike) – x-coordinate ArrayLike of the ray-traced light rays

    Unit: arcsec

  • y_component (ArrayLike) – y-coordinate ArrayLike of the ray-traced light rays

    Unit: arcsec

caustics.lenses.func.base.physical_from_reduced_deflection_angle(ax, ay, d_s, d_ls)[source]#

Computes the physical deflection angle of the given the reduced deflection angles [arcsec].

Parameters:
  • ax (ArrayLike) –

    ArrayLike of x axis reduced deflection angles in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    ArrayLike of y axis reduced deflection angles in the lens plane.

    Unit: arcsec

  • d_s (float) –

    distance to the source.

    Unit: Mpc

  • d_ls (float) –

    distance from lens to source.

    Unit: Mpc

Returns:

  • x_component (ArrayLike) – Physical deflection Angle in the x-direction.

    Unit: arcsec

  • y_component (ArrayLike) – Physical deflection Angle in the y-direction.

    Unit: arcsec

caustics.lenses.func.base.reduced_from_physical_deflection_angle(ax, ay, d_s, d_ls)[source]#

Computes the reduced deflection angle of the lens at given coordinates [arcsec].

Parameters:
  • ax (ArrayLike) –

    ArrayLike of x axis physical deflection angles in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    ArrayLike of y axis physical deflection angles in the lens plane.

    Unit: arcsec

  • d_s (float) –

    distance to the source.

    Unit: Mpc

  • d_ls (float) –

    distance from lens to source.

    Unit: Mpc

Returns:

  • x_component (ArrayLike) – Reduced deflection Angle in the x-direction.

    Unit: arcsec

  • y_component (ArrayLike) – Reduced deflection Angle in the y-direction.

    Unit: arcsec

caustics.lenses.func.base.remove_duplicate_points(x, epsilon)[source]#

Remove duplicate points from the coordinates list.

caustics.lenses.func.base.remove_triangle_duplicates(p)[source]#
caustics.lenses.func.base.time_delay_arcsec2_to_days(d_l, d_s, d_ls, z_l)[source]#

Computes a scaling factor to use in time delay calculations which converts the time delay (i.e. potential and deflection angle squared terms) from arcsec^2 to units of days.

caustics.lenses.func.base.triangle_area(p)[source]#

Determine the area of triangle p where p is a (3,2) tensor.

caustics.lenses.func.base.triangle_contains(p, v)[source]#

determine if point v is inside triangle p. Where p is a (3,2) tensor, and v is a (2,) tensor.

caustics.lenses.func.base.triangle_equals(p1, p2)[source]#

Determine if two triangles are equal. Where p1 and p2 are (3,2) tensors.

caustics.lenses.func.base.triangle_neighbors(p)[source]#

Build a set of neighbors for triangle p where p is a (3,2) tensor. The neighbors all have the same shape as p, but are various translations and reflections of p that share a common edge or vertex.

caustics.lenses.func.base.triangle_upsample(p)[source]#

Upsample triangle p where p is a (3,2) tensor. The upsampled triangles are all triangles internal to p built by taking the midpoints of the edges of p.

caustics.lenses.func.enclosed_mass module#

caustics.lenses.func.enclosed_mass.convergence_enclosed_mass(x0, y0, q, phi, enclosed_mass, x, y, critical_surface_density, s=0.0)[source]#

Calculate the convergence for a lens with an enclosed mass profile. See the Meneghetti lecture notes Equation 3.28 for the convergence from an enclosed mass profile.

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • q (ArrayLike) –

    The axis ratio of the lens. ratio of semi-minor to semi-major axis (b/a).

    Unit: unitless

  • phi (ArrayLike) –

    The position angle of the lens. The angle relative to the positive x-axis.

    Unit: radians

  • enclosed_mass (Callable) – The enclosed mass profile function, solely a function of r.

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

Returns:

The convergence.

Return type:

ArrayLike

caustics.lenses.func.enclosed_mass.physical_deflection_angle_enclosed_mass(x0, y0, q, phi, enclosed_mass, x, y, s=0.0)[source]#

Calculate the reduced deflection angle for a lens with an enclosed mass profile. See the Meneghetti lecture notes Equation 3.19 for the physical deflection angle.

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • q (ArrayLike) –

    The axis ratio of the lens. ratio of semi-minor to semi-major axis (b/a).

    Unit: unitless

  • phi (ArrayLike) –

    The position angle of the lens. The angle relative to the positive x-axis.

    Unit: radians

  • enclosed_mass (Callable) – The enclosed mass profile function, solely a function of r.

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

Returns:

The physical deflection angle.

Return type:

tuple[ArrayLike, ArrayLike]

caustics.lenses.func.epl module#

caustics.lenses.func.epl.convergence_epl(x0, y0, q, phi, Rein, t, x, y, s=0.0)[source]#

Calculate the reduced deflection angle.

See Tessore et al. 2015 equation 2.

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • q (ArrayLike) –

    The axis ratio of the lens. Semi-minor over semi-major axis lengths.

    Unit: unitless

  • phi (ArrayLike) –

    The orientation angle of the lens (position angle).

    Unit: radians

  • Rein (ArrayLike) –

    The Einstein radius of the lens.

    Unit: arcsec

  • t (ArrayLike) –

    Power law slope (gamma-1) of the lens. If not provided, it is considered as a free parameter.

    Unit: unitless

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

  • s (float) –

    The core radius of the lens (defaults to 0.0).

    Unit: arcsec

Returns:

  • x_component (ArrayLike) – The x-component of the deflection angle.

    Unit: arcsec

  • y_component (ArrayLike) – The y-component of the deflection angle.

    Unit: arcsec

caustics.lenses.func.epl.potential_epl(x0, y0, q, phi, Rein, t, x, y, n_iter, chunk_size)[source]#

Calculate the potential for the EPL as defined in Tessore et al. 2015 equation 15.

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • q (ArrayLike) –

    The axis ratio of the lens. Semi-minor over semi-major axis lengths.

    Unit: unitless

  • phi (ArrayLike) –

    The orientation angle of the lens (position angle).

    Unit: radians

  • Rein (ArrayLike) –

    The Einstein radius of the lens.

    Unit: arcsec

  • t (ArrayLike) –

    Power law slope (gamma-1) of the lens. If not provided, it is considered as a free parameter.

    Unit: unitless

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

  • n_iter (int) –

    Number of iterations for the iterative solver.

    Unit: number

  • chunk_size (int) –

    Number of iterations to do in parallel for the iterative solver.

    Unit: number

Returns:

  • x_component (ArrayLike) – The x-component of the deflection angle.

    Unit: arcsec

  • y_component (ArrayLike) – The y-component of the deflection angle.

    Unit: arcsec

caustics.lenses.func.epl.reduced_deflection_angle_epl(x0, y0, q, phi, Rein, t, x, y, n_iter, chunk_size=None)[source]#

Calculate the reduced deflection angle. Given in Tessore et al. 2015 equation 13.

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • q (ArrayLike) –

    The axis ratio of the lens. Semi-minor over semi-major axis lengths.

    Unit: unitless

  • phi (ArrayLike) –

    The orientation angle of the lens (position angle).

    Unit: radians

  • Rein (ArrayLike) –

    The Einstein radius of the lens.

    Unit: arcsec

  • t (ArrayLike) –

    Power law slope (gamma-1) of the lens. If not provided, it is considered as a free parameter.

    Unit: unitless

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

  • n_iter (int) –

    Number of iterations for the iterative solver.

    Unit: number

  • chunk_size (int) –

    Number of iterations to do in parallel for the iterative solver.

    Unit: number

Returns:

  • x_component (ArrayLike) – The x-component of the deflection angle.

    Unit: arcsec

  • y_component (ArrayLike) – The y-component of the deflection angle.

    Unit: arcsec

caustics.lenses.func.external_shear module#

caustics.lenses.func.external_shear.gamma_phi_to_gamma1(gamma, phi)[source]#

Convert the shear magnitude and angle to the gamma_1 component.

Parameters:
  • gamma (ArrayLike) –

    The shear magnitude.

    Unit: unitless

  • phi (ArrayLike) –

    The shear angle.

    Unit: radians

Returns:

The gamma_1 component of the shear.

Unit: unitless

Return type:

ArrayLike

caustics.lenses.func.external_shear.gamma_phi_to_gamma2(gamma, phi)[source]#

Convert the shear magnitude and angle to the gamma_2 component.

Parameters:
  • gamma (ArrayLike) –

    The shear magnitude.

    Unit: unitless

  • phi (ArrayLike) –

    The shear angle.

    Unit: radians

Returns:

The gamma_2 component of the shear.

Unit: unitless

Return type:

ArrayLike

caustics.lenses.func.external_shear.potential_external_shear(x0, y0, gamma_1, gamma_2, x, y)[source]#

Compute the lensing potential for an external shear field. Here we use the Meneghetti lecture notes equation 3.80

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • gamma_1 (ArrayLike) –

    The shear component in the x-direction.

    Unit: unitless

  • gamma_2 (ArrayLike) –

    The shear component in the y-direction.

    Unit: unitless

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

Returns:

The lensing potential.

Unit: arcsec^2

Return type:

ArrayLike

caustics.lenses.func.external_shear.reduced_deflection_angle_external_shear(x0, y0, gamma_1, gamma_2, x, y)[source]#

Compute the reduced deflection angles for an external shear field. Here we use the Meneghetti lecture notes and take derivatives of equation 3.80

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • gamma_1 (ArrayLike) –

    The shear component in the x-direction.

    Unit: unitless

  • gamma_2 (ArrayLike) –

    The shear component in the y-direction.

    Unit: unitless

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

Returns:

  • x_component (ArrayLike) – Deflection Angle in the x-direction.

    Unit: arcsec

  • y_component (ArrayLike) – Deflection Angle in the y-direction.

    Unit: arcsec

caustics.lenses.func.mass_sheet module#

caustics.lenses.func.mass_sheet.convergence_mass_sheet(kappa, x)[source]#

Compute the lensing convergence. In the case of a mass sheet, this is just the convergence value mapped to the input shape.

Parameters:
  • kappa (Optional[Union[ArrayLike, float]]) –

    Convergence. Surface density normalized by the critical surface density.

    Unit: unitless

  • x (ArrayLike) –

    The x-coordinate of the lens. Only used for shape and device.

    Unit: arcsec

Returns:

The lensing potential.

Unit: arcsec^2

Return type:

ArrayLike

caustics.lenses.func.mass_sheet.potential_mass_sheet(x0, y0, kappa, x, y)[source]#

Compute the lensing potential. Here we use the Meneghetti lecture notes equation 3.81.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • kappa (Optional[Union[ArrayLike, float]]) –

    Convergence. Surface density normalized by the critical surface density.

    Unit: unitless

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

Returns:

The lensing potential.

Unit: arcsec^2

Return type:

ArrayLike

caustics.lenses.func.mass_sheet.reduced_deflection_angle_mass_sheet(x0, y0, kappa, x, y)[source]#

Compute the reduced deflection angles. Here we use the Meneghetti lecture notes equation 3.84.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • kappa (Optional[Union[ArrayLike, float]]) –

    Convergence. Surface density normalized by the critical surface density.

    Unit: unitless

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

Returns:

  • x_component (ArrayLike) – Deflection Angle in the x-direction.

    Unit: arcsec

  • y_component (ArrayLike) – Deflection Angle in the y-direction.

    Unit: arcsec

caustics.lenses.func.multipole module#

caustics.lenses.func.multipole.convergence_multipole(x0, y0, m, a_m, phi_m, x, y)[source]#

Compute the lensing convergence.

Parameters:
  • x (ArrayLike) – x-coordinates in the lens plane.

  • y (ArrayLike) – y-coordinates in the lens plane.

  • x0 (ArrayLike) – x-coordinate of the center of the lens.

  • y0 (ArrayLike) – y-coordinate of the center of the lens.

  • m (ArrayLike) – The multipole order(s).

  • a_m (ArrayLike) – The multipole amplitude(s).

  • phi_m (ArrayLike) – The multipole orientation(s).

Returns:

  • convergence (ArrayLike) – Lensing convergence.

    Unit: unitless

  • Equation (B10) and (B3) https (//arxiv.org/pdf/1307.4220, Xu et al. 2014)

caustics.lenses.func.multipole.potential_multipole(x0, y0, m, a_m, phi_m, x, y)[source]#

Compute the lensing potential.

Parameters:
  • x (ArrayLike) – x-coordinates in the lens plane.

  • y (ArrayLike) – y-coordinates in the lens plane.

  • x0 (ArrayLike) – x-coordinate of the center of the lens.

  • y0 (ArrayLike) – y-coordinate of the center of the lens.

  • m (ArrayLike) – The multipole order(s).

  • a_m (ArrayLike) – The multipole amplitude(s).

  • phi_m (ArrayLike) – The multipole orientation(s).

Returns:

  • potential (ArrayLike) – Lensing potential.

    Unit: arcsec^2

  • Equation (B11) and (B3) https (//arxiv.org/pdf/1307.4220, Xu et al. 2014)

caustics.lenses.func.multipole.reduced_deflection_angle_multipole(x0, y0, m, a_m, phi_m, x, y)[source]#

Calculates the reduced deflection angle.

Parameters:
  • x (ArrayLike) – x-coordinates in the lens plane.

  • y (ArrayLike) – y-coordinates in the lens plane.

  • x0 (ArrayLike) – x-coordinate of the center of the lens.

  • y0 (ArrayLike) – y-coordinate of the center of the lens.

  • m (ArrayLike) – The multipole order(s).

  • a_m (ArrayLike) – The multipole amplitude(s).

  • phi_m (ArrayLike) – The multipole orientation(s).

Returns:

  • tuple[ArrayLike, ArrayLike] – The reduced deflection angles in the x and y directions.

  • Equation (B11) and (B12) https (//arxiv.org/pdf/1307.4220, Xu et al. 2014)

caustics.lenses.func.nfw module#

caustics.lenses.func.nfw.convergence_nfw(critical_surface_density, critical_density, x0, y0, mass, c, x, y, d_l, DELTA=200.0, s=0.0)[source]#

Compute the convergence. This can be found in the Meneghetti Lecture notes equation 3.74.

Parameters:
  • critical_surface_density (ArrayLike) –

    The critical surface density of the Universe at the appropriate redshift.

    Unit: Msun/Mpc^2

  • critical_density (ArrayLike) –

    The critical density of the Universe at the appropriate redshift.

    Unit: Msun/Mpc^3

  • mass (ArrayLike) – The mass of the halo

  • c (Optional[ArrayLike]) –

    Concentration parameter of the lens. Default is None.

    Unit: unitless

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • s (float) –

    Softening parameter to avoid singularities at the center of the lens. Default is 0.0.

    Unit: arcsec

caustics.lenses.func.nfw.convergence_s_nfw(critical_surface_density, critical_density, mass, c, DELTA)[source]#

Compute the dimensionaless surface mass density of the lens.

critical_surface_density: ArrayLike

The critical surface density of the Universe at the appropriate redshift.

Unit: Msun/Mpc^2

critical_density: ArrayLike

The critical density of the Universe at the appropriate redshift.

Unit: Msun/Mpc^3

mass: ArrayLike

The mass of the halo.

Unit: Msun

c: ArrayLike

The concentration parameter of the halo.

Unit: unitless

DELTA: float

The overdensity parameter. Amount above the critical surface density at which the scale radius is computed

Unit: unitless

Returns:

The dimensionless surface mass density of the lens.

Unit: unitless

Return type:

ArrayLike

caustics.lenses.func.nfw.physical_deflection_angle_nfw(x0, y0, mass, c, critical_density, d_l, x, y, DELTA=200.0, s=0.0)[source]#

Compute the physical deflection angles. This is an expanded form of the Meneghetti notes equation 3.72

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • mass (ArrayLike) –

    Mass of the lens. Default is None.

    Unit: Msun

  • c (ArrayLike) –

    Concentration parameter of the lens. Default is None.

    Unit: unitless

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • s (float) –

    Softening parameter to avoid singularities at the center of the lens. Default is 0.0.

    Unit: arcsec

caustics.lenses.func.nfw.potential_nfw(critical_surface_density, critical_density, x0, y0, mass, c, d_l, x, y, DELTA=200.0, s=0.0)[source]#

Compute the convergence. This can be found in the Meneghetti Lecture notes equation 3.70.

Parameters:
  • critical_surface_density (ArrayLike) –

    The critical surface density of the Universe at the appropriate redshift.

    Unit: Msun/Mpc^2

  • critical_density (ArrayLike) –

    The critical density of the Universe at the appropriate redshift.

    Unit: Msun/Mpc^3

  • mass (ArrayLike) – The mass of the halo

  • c (Optional[ArrayLike]) –

    Concentration parameter of the lens. Default is None.

    Unit: unitless

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • s (float) –

    Softening parameter to avoid singularities at the center of the lens. Default is 0.0.

    Unit: arcsec

caustics.lenses.func.nfw.scale_density_nfw(critical_density, c, DELTA=200.0)[source]#

Compute the scale density of the NFW profile.

Parameters:
  • critical_density (ArrayLike) –

    The critical density of the Universe at the appropriate redshift.

    Unit: Msun/Mpc^3

  • c (ArrayLike) –

    The concentration parameter of the halo.

    Unit: unitless

  • DELTA (float) –

    The overdensity parameter. Amount above the critical surface density at which the scale radius is computed

    Unit: unitless

Returns:

The scale density of the NFW profile.

Unit: solar mass per square kiloparsec

Return type:

ArrayLike

caustics.lenses.func.nfw.scale_radius_nfw(critical_density, mass, c, DELTA=200.0)[source]#

Compute the scale radius of the NFW profile.

Parameters:
  • critical_density (ArrayLike) –

    The critical density of the Universe at the appropriate redshift.

    Unit: Msun/Mpc^3

  • mass (ArrayLike) –

    The mass of the halo.

    Unit: Msun

  • c (ArrayLike) –

    The concentration parameter of the halo.

    Unit: unitless

  • DELTA (float) –

    The overdensity parameter. Amount above the critical surface density at which the scale radius is computed

    Unit: unitless

Returns:

The scale radius of the NFW profile.

Unit: Mpc

Return type:

ArrayLike

caustics.lenses.func.pixelated_convergence module#

caustics.lenses.func.pixelated_convergence.build_kernels_pixelated_convergence(pixelscale, n_pix)[source]#

Build the kernels for the pixelated convergence.

Parameters:
  • pixelscale (float) –

    The pixel scale of the convergence map.

    Unit: arcsec/pixel

  • n_pix (int) –

    The number of pixels in the convergence map.

    Unit: number

Returns:

  • x_kernel (ArrayLike) – The x-component of the kernel.

    Unit: unitless

  • y_kernel (ArrayLike) – The y-component of the kernel.

    Unit: unitless

caustics.lenses.func.pixelated_convergence.build_window_pixelated_convergence(window, kernel_shape)[source]#

Window the kernel for stable FFT.

Parameters:
  • window (float) – The window to apply as a fraction of the image width. For example a window of 1/4 will set the kernel to start decreasing at 1/4 of the image width, and then linearly go to zero.

  • kernel_shape (tuple) – The shape of the kernel to be windowed.

Returns:

The window to multiply with the kernel.

Return type:

ArrayLike

caustics.lenses.func.pixelated_convergence.potential_pixelated_convergence(x0, y0, convergence_map, x, y, potential_kernel, pixelscale, fov, n_pix, padding, convolution_mode='fft')[source]#

Compute the lensing potential for a pixelated convergence map. This follows from the basic formulas for potential, namely that it is the convolution of the convergence with the logarithm of a vector pointing towards the origin. For more details see the Meneghetti lecture notes equation 2.31

Parameters:
  • x0 (float) –

    The x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (float) –

    The y-coordinate of the center of the lens.

    Unit: arcsec

  • convergence_map (ArrayLike) –

    The pixelated convergence map.

    Unit: unitless

  • x (ArrayLike) –

    The x-coordinate in the lens plane at which to compute the deflection.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate in the lens plane at which to compute the deflection.

    Unit: arcsec

  • potential_kernel (ArrayLike) –

    The kernel for convolution.

    Unit: unitless

  • pixelscale (float) –

    The pixel scale of the convergence map.

    Unit: arcsec/pixel

  • fov (float) –

    The field of view of the convergence map.

    Unit: arcsec

  • n_pix (int) –

    The number of pixels in the convergence map.

    Unit: number

  • padding (str) – The type of padding to use. Either “zero”, “reflect”, “circular”, or “tile”.

  • convolution_mode (str) – The mode of convolution to use. Either “fft” or “conv2d”.

caustics.lenses.func.pixelated_convergence.reduced_deflection_angle_pixelated_convergence(x0, y0, convergence_map, x, y, ax_kernel, ay_kernel, pixelscale, fov, n_pix, padding, convolution_mode='fft')[source]#

Compute the reduced deflection angle for a pixelated convergence map. This follows from the basic formulas for deflection angle, namely that it is the convolution of the convergence with a unit vector pointing towards the origin. For more details see the Meneghetti lecture notes equation 2.32

Parameters:
  • x0 (float) –

    The x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (float) –

    The y-coordinate of the center of the lens.

    Unit: arcsec

  • convergence_map (ArrayLike) –

    The pixelated convergence map.

    Unit: unitless

  • x (ArrayLike) –

    The x-coordinate in the lens plane at which to compute the deflection.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate in the lens plane at which to compute the deflection.

    Unit: arcsec

  • ax_kernel (ArrayLike) –

    The x-component of the kernel for convolution.

    Unit: unitless

  • ay_kernel (ArrayLike) –

    The y-component of the kernel for convolution.

    Unit: unitless

  • pixelscale (float) –

    The pixel scale of the convergence map.

    Unit: arcsec/pixel

  • fov (float) –

    The field of view of the convergence map.

    Unit: arcsec

  • n_pix (int) –

    The number of pixels in the convergence map.

    Unit: number

  • padding (str) – The type of padding to use. Either “zero”, “reflect”, “circular”, or “tile”.

  • convolution_mode (str) – The mode of convolution to use. Either “fft” or “conv2d”.

caustics.lenses.func.point module#

caustics.lenses.func.point.convergence_point(x0, y0, x, y)[source]#

Compute the convergence (dimensionless surface mass density). This follows essenitally by definition.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

Returns:

The convergence (dimensionless surface mass density).

Unit: unitless

Return type:

ArrayLike

caustics.lenses.func.point.mass_to_rein_point(M, d_ls, d_l, d_s)[source]#

Compute the Einstein radius of a point mass. See Meneghetti lecture notes equation 1.39

Parameters:
  • M (ArrayLike) –

    Mass of the lens.

    Unit: solar masses

  • d_ls (ArrayLike) –

    Distance between the lens and the source.

    Unit: Mpc

  • d_l (ArrayLike) –

    Distance between the observer and the lens.

    Unit: Mpc

  • d_s (ArrayLike) –

    Distance between the observer and the source.

    Unit: Mpc

Returns:

The Einstein radius.

Unit: arcsec

Return type:

ArrayLike

caustics.lenses.func.point.potential_point(x0, y0, Rein, x, y, s=0.0)[source]#

Compute the lensing potential. See the Meneghetti lecture notes equation 3.3 for more detail.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • Rein (ArrayLike) –

    Einstein radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

Returns:

The lensing potential.

Unit: arcsec^2

Return type:

ArrayLike

caustics.lenses.func.point.reduced_deflection_angle_point(x0, y0, Rein, x, y, s=0.0)[source]#

Compute the reduced deflection angles. See the Meneghetti lecture notes equation 3.1 for more detail.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • Rein (ArrayLike) –

    Einstein radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

Returns:

  • x_component (ArrayLike) – Deflection Angle in the x-direction.

    Unit: arcsec

  • y_component (ArrayLike) – Deflection Angle in the y-direction.

    Unit: arcsec

caustics.lenses.func.point.rein_to_mass_point(r, d_ls, d_l, d_s)[source]#

Compute the Einstein radius of a point mass. See Meneghetti lecture notes equation 1.39

Parameters:
  • r (ArrayLike) –

    Einstein radius of the lens.

    Unit: arcsec

  • d_ls (ArrayLike) –

    Distance between the lens and the source.

    Unit: Mpc

  • d_l (ArrayLike) –

    Distance between the observer and the lens.

    Unit: Mpc

  • d_s (ArrayLike) –

    Distance between the observer and the source.

    Unit: Mpc

Returns:

The mass of the lens

Unit: solar masses

Return type:

ArrayLike

caustics.lenses.func.pseudo_jaffe module#

caustics.lenses.func.pseudo_jaffe.convergence_0_pseudo_jaffe(mass, Rc, Rs, d_l, critical_surface_density)[source]#

Compute the convergence (dimensionless surface mass density). This is rearranged from Eliasdottir et al 2007 equation A11.

Parameters:
  • mass (ArrayLike) –

    Total mass of the lens (Msun).

    Unit: Msun

  • Rc (ArrayLike) –

    Core radius of the lens.

    Unit: arcsec

  • Rs (ArrayLike) –

    Scaling radius of the lens.

    Unit: arcsec

  • d_l (ArrayLike) –

    Distance to the lens.

    Unit: Mpc

  • critical_surface_density (ArrayLike) –

    Critical surface density of the universe at the lens redshift.

    Unit: Msun / Mpc^2

Returns:

The convergence (dimensionless surface mass density) at the center of the pseudo jaffe.

Unit: unitless

Return type:

ArrayLike

caustics.lenses.func.pseudo_jaffe.convergence_pseudo_jaffe(x0, y0, mass, Rc, Rs, x, y, d_l, critical_surface_density, s=0.0)[source]#

Compute the convergence (dimensionless surface mass density). See Eliasdottir et al 2007 Equation A3.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • mass (ArrayLike) –

    Total mass of the lens

    Unit: Msun

  • Rc (ArrayLike) –

    Core radius of the lens.

    Unit: arcsec

  • Rs (ArrayLike) –

    Scaling radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • d_l (ArrayLike) –

    Distance to the lens.

    Unit: Mpc

  • critical_surface_density (ArrayLike) –

    Critical surface density of the universe at the lens redshift.

    Unit: Msun / Mpc^2

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

caustics.lenses.func.pseudo_jaffe.mass_enclosed_2d_pseudo_jaffe(radius, mass, Rc, Rs, s=0.0)[source]#

Compute the mass enclosed within a given radius. See Eliasdottir et al 2007 equation A10.

Parameters:
  • radius (Optional[ArrayLike]) –

    Radius at which to calculate enclosed mass (arcsec).

    Unit: arcsec

  • mass (ArrayLike) –

    Total mass of the lens

    Unit: Msun

  • Rc (ArrayLike) –

    Core radius of the lens.

    Unit: arcsec

  • Rs (ArrayLike) –

    Scaling radius of the lens.

    Unit: arcsec

caustics.lenses.func.pseudo_jaffe.potential_pseudo_jaffe(x0, y0, mass, Rc, Rs, x, y, d_l, d_s, d_ls, s=0.0)[source]#

Compute the lensing potential for the pseudo jaffe lens. See Eliasdottir et al 2007 equation A18.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • mass (ArrayLike) –

    Total mass of the lens

    Unit: Msun

  • Rc (ArrayLike) –

    Core radius of the lens.

    Unit: arcsec

  • Rs (ArrayLike) –

    Scaling radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • d_l (ArrayLike) –

    Distance to the lens.

    Unit: Mpc

  • d_s (ArrayLike) –

    Distance to the source.

    Unit: Mpc

  • d_ls (ArrayLike) –

    Distance from the lens to the source.

    Unit: Mpc

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

caustics.lenses.func.pseudo_jaffe.reduced_deflection_angle_pseudo_jaffe(x0, y0, mass, Rc, Rs, x, y, d_l, critical_surface_density, s=0.0)[source]#

Compute the reduced deflection angle. See Eliasdottir et al 2007 equation A19.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • mass (ArrayLike) –

    Total mass of the lens

    Unit: Msun

  • Rc (ArrayLike) –

    Core radius of the lens.

    Unit: arcsec

  • Rs (ArrayLike) –

    Scaling radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • d_l (ArrayLike) –

    Distance to the lens.

    Unit: Mpc

  • critical_surface_density (ArrayLike) –

    Critical surface density of the universe at the lens redshift.

    Unit: Msun / Mpc^2

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

caustics.lenses.func.sie module#

caustics.lenses.func.sie.convergence_sie(x0, y0, q, phi, Rein, x, y, s=0.0)[source]#

Calculate the projected mass density. This is converted from the SIS convergence definition.

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • q (ArrayLike) –

    The axis ratio of the lens.

    Unit: unitless

  • phi (ArrayLike) –

    The orientation angle of the lens (position angle).

    Unit: radians

  • Rein (ArrayLike) –

    The Einstein radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

  • s (float) –

    The core radius of the lens (defaults to 0.0).

    Unit: arcsec

Returns:

The projected mass density.

Unit: unitless

Return type:

ArrayLike

caustics.lenses.func.sie.potential_sie(x0, y0, q, phi, Rein, x, y, s=0.0)[source]#

Compute the lensing potential. For more detail see Keeton 2002 equation 33, although our Rein is defined as \(b/\sqrt(q)\) in Keeton’s notation.

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • q (ArrayLike) –

    The axis ratio of the lens.

    Unit: unitless

  • phi (ArrayLike) –

    The orientation angle of the lens (position angle).

    Unit: radians

  • Rein (ArrayLike) –

    The Einstein radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

  • s (float) –

    The core radius of the lens (defaults to 0.0).

    Unit: arcsec

Returns:

The lensing potential.

Unit: arcsec^2

Return type:

ArrayLike

caustics.lenses.func.sie.reduced_deflection_angle_sie(x0, y0, q, phi, Rein, x, y, s=0.0)[source]#

Calculate the physical deflection angle. For more detail see Keeton 2002 equations 34 and 35, although our Rein is defined as \(b/\sqrt(q)\) in Keeton’s notation.

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • q (ArrayLike) –

    The axis ratio of the lens.

    Unit: unitless

  • phi (ArrayLike) –

    The orientation angle of the lens (position angle).

    Unit: radians

  • Rein (ArrayLike) –

    The Einstein radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

  • s (float) –

    The core radius of the lens (defaults to 0.0).

    Unit: arcsec

Returns:

  • x_component (ArrayLike) – The x-component of the deflection angle.

    Unit: arcsec

  • y_component (ArrayLike) – The y-component of the deflection angle.

    Unit: arcsec

caustics.lenses.func.sie.sigma_v_to_rein_sie(sigma_v, dls, ds)[source]#

Convert the velocity dispersion to the Einstein radius. See equation 16.22 in Dynamics and Astrophysics of Galaxies by Jo Bovy

Parameters:
  • sigma_v (ArrayLike) –

    The velocity dispersion of the lens.

    Unit: km/s

  • dls (ArrayLike) –

    The angular diameter distance between the lens and the source.

    Unit: Mpc

  • ds (ArrayLike) –

    The angular diameter distance between the observer and the source.

    Unit: Mpc

Returns:

The Einstein radius.

Unit: arcsec

Return type:

ArrayLike

caustics.lenses.func.sis module#

caustics.lenses.func.sis.convergence_sis(x0, y0, Rein, x, y, s=0.0)[source]#

Compute the lensing convergence. See the Meneghetti lecture notes equation 3.44.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • Rein (ArrayLike) –

    Einstein radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

Returns:

convergence – Lensing convergence.

Unit: unitless

Return type:

ArrayLike

caustics.lenses.func.sis.potential_sis(x0, y0, Rein, x, y, s=0.0)[source]#

Compute the lensing potential. See the Meneghetti lecture notes equation 3.45.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • Rein (ArrayLike) –

    Einstein radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

Returns:

potential – Lensing potential.

Unit: arcsec^2

Return type:

ArrayLike

caustics.lenses.func.sis.reduced_deflection_angle_sis(x0, y0, Rein, x, y, s=0.0)[source]#

Compute the reduced deflection angles. See the Meneghetti lecture notes equation 3.46.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • Rein (ArrayLike) –

    Einstein radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

Returns:

  • x_component (ArrayLike) – Deflection Angle in the x-direction.

    Unit: arcsec

  • y_component (ArrayLike) – Deflection Angle in the y-direction.

    Unit: arcsec

caustics.lenses.func.tnfw module#

caustics.lenses.func.tnfw.M0_scalemass_tnfw(Rs, c, critical_density, d_l, DELTA=200.0)[source]#

What M0 would be for an NFW

Parameters:
  • Rs (ArrayLike) –

    The scale radius of the TNFW lens.

    Unit: arcsec

  • c (ArrayLike) –

    The concentration parameter of an NFW lens with the same parameters.

    Unit: unitless

  • critical_density (ArrayLike) –

    The critical density of the universe.

    Unit: Msun / Mpc^3

  • d_l (ArrayLike) –

    The angular diameter distance to the lens.

    Unit: Mpc

  • DELTA (float) –

    The overdensity parameter.

    Unit: unitless

caustics.lenses.func.tnfw.M0_totmass_tnfw(mass, tau)[source]#

Rearranged from Baltz et al. 2009 equation A.4

caustics.lenses.func.tnfw.concentration_tnfw(mass, Rs, critical_density, d_l, DELTA=200.0)[source]#

Compute the concentration parameter “c” for a TNFW profile.

Parameters:
  • mass (ArrayLike) –

    The mass of the lens.

    Unit: Msun

  • Rs (ArrayLike) –

    The scale radius of the TNFW lens.

    Unit: arcsec

  • critical_density (ArrayLike) –

    The critical density of the universe.

    Unit: Msun / Mpc^3

  • d_l (ArrayLike) –

    The angular diameter distance to the lens.

    Unit: Mpc

  • DELTA (float) –

    The overdensity parameter.

    Unit: unitless

Returns:

The concentration parameter “c” for a TNFW profile.

Unit: unitless

Return type:

ArrayLike

caustics.lenses.func.tnfw.convergence_tnfw(x0, y0, Rs, tau, x, y, critical_density, M0, d_l, s=0.0)[source]#

Compute the dimensionless convergence for the TNFW. See Baltz et al. 2009 equation A.8

Parameters

Unit: arcsec

y0: ArrayLike

The y-coordinate of the lens center.

Unit: arcsec

Rs: ArrayLike

The scale radius of the TNFW lens.

Unit: arcsec

tau: ArrayLike

The truncation scale. Ratio of truncation radius to scale radius.

Unit: unitless

x: ArrayLike

The x-coordinate in the lens plane.

Unit: arcsec

y: ArrayLike

The y-coordinate in the lens plane.

Unit: arcsec

M0: ArrayLike

The mass normalization constant. See M0_totmass_tnfw and M0_scalemass_tnfw.

Unit: Msun

d_l: ArrayLike

The angular diameter distance to the lens.

Unit: Mpc

s: float

Softening parameter to prevent numerical instabilities.

Unit: arcsec

caustics.lenses.func.tnfw.mass_enclosed_2d_tnfw(r, Rs, tau, M0)[source]#

Total projected mass (Msun) within a radius r (arcsec). Given in Baltz et al. 2009 equation A.11

Parameters:
  • r (ArrayLike) –

    Radius at which to compute the enclosed mass.

    Unit: arcsec

  • mass (ArrayLike) –

    Mass of the lens.

    Unit: Msun

  • Rs (ArrayLike) –

    Scale radius of the TNFW lens.

    Unit: arcsec

  • tau (ArrayLike) –

    Truncation scale. Ratio of truncation radius to scale radius.

    Unit: unitless

Returns:

Integrated mass projected in infinite cylinder within radius r.

Unit: Msun

Return type:

ArrayLike

caustics.lenses.func.tnfw.physical_deflection_angle_tnfw(x0, y0, Rs, tau, x, y, M0, d_l, s=0.0)[source]#

Compute the physical deflection angle for a TNFW profile. Converted from Baltz et al. 2009 equation A.18

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • Rs (ArrayLike) –

    The scale radius of the TNFW lens.

    Unit: arcsec

  • tau (ArrayLike) –

    The truncation scale. Ratio of truncation radius to scale radius.

    Unit: unitless

  • x (ArrayLike) –

    The x-coordinate in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate in the lens plane.

    Unit: arcsec

  • M0 (ArrayLike) –

    The mass normalization constant. See M0_totmass_tnfw and M0_scalemass_tnfw.

    Unit: Msun

  • d_l (ArrayLike) –

    The angular diameter distance to the lens.

    Unit: Mpc

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

caustics.lenses.func.tnfw.potential_tnfw(x0, y0, Rs, tau, x, y, M0, d_l, d_s, d_ls, s=0.0)[source]#

Compute the lensing potential for a TNFW profile. See Baltz et al. 2009 equation A.14

Parameters

Unit: arcsec

y0: ArrayLike

The y-coordinate of the lens center.

Unit: arcsec

Rs: ArrayLike

The scale radius of the TNFW lens.

Unit: arcsec

tau: ArrayLike

The truncation scale. Ratio of truncation radius to scale radius.

Unit: unitless

x: ArrayLike

The x-coordinate in the lens plane.

Unit: arcsec

y: ArrayLike

The y-coordinate in the lens plane.

Unit: arcsec

M0: ArrayLike

The mass normalization constant. See M0_totmass_tnfw and M0_scalemass_tnfw.

Unit: Msun

d_l: ArrayLike

The angular diameter distance to the lens.

Unit: Mpc

d_s: ArrayLike

The angular diameter distance to the source.

Unit: Mpc

d_ls: ArrayLike

The angular diameter distance between the lens and the source.

Unit: Mpc

s: float

Softening parameter to prevent numerical instabilities.

Unit: arcsec

caustics.lenses.func.tnfw.scale_density_tnfw(c, critical_density, DELTA=200.0)[source]#

Module contents#

caustics.lenses.func.M0_scalemass_tnfw(Rs, c, critical_density, d_l, DELTA=200.0)[source]#

What M0 would be for an NFW

Parameters:
  • Rs (ArrayLike) –

    The scale radius of the TNFW lens.

    Unit: arcsec

  • c (ArrayLike) –

    The concentration parameter of an NFW lens with the same parameters.

    Unit: unitless

  • critical_density (ArrayLike) –

    The critical density of the universe.

    Unit: Msun / Mpc^3

  • d_l (ArrayLike) –

    The angular diameter distance to the lens.

    Unit: Mpc

  • DELTA (float) –

    The overdensity parameter.

    Unit: unitless

caustics.lenses.func.M0_totmass_tnfw(mass, tau)[source]#

Rearranged from Baltz et al. 2009 equation A.4

caustics.lenses.func.build_kernels_pixelated_convergence(pixelscale, n_pix)[source]#

Build the kernels for the pixelated convergence.

Parameters:
  • pixelscale (float) –

    The pixel scale of the convergence map.

    Unit: arcsec/pixel

  • n_pix (int) –

    The number of pixels in the convergence map.

    Unit: number

Returns:

  • x_kernel (ArrayLike) – The x-component of the kernel.

    Unit: unitless

  • y_kernel (ArrayLike) – The y-component of the kernel.

    Unit: unitless

caustics.lenses.func.build_window_pixelated_convergence(window, kernel_shape)[source]#

Window the kernel for stable FFT.

Parameters:
  • window (float) – The window to apply as a fraction of the image width. For example a window of 1/4 will set the kernel to start decreasing at 1/4 of the image width, and then linearly go to zero.

  • kernel_shape (tuple) – The shape of the kernel to be windowed.

Returns:

The window to multiply with the kernel.

Return type:

ArrayLike

caustics.lenses.func.concentration_tnfw(mass, Rs, critical_density, d_l, DELTA=200.0)[source]#

Compute the concentration parameter “c” for a TNFW profile.

Parameters:
  • mass (ArrayLike) –

    The mass of the lens.

    Unit: Msun

  • Rs (ArrayLike) –

    The scale radius of the TNFW lens.

    Unit: arcsec

  • critical_density (ArrayLike) –

    The critical density of the universe.

    Unit: Msun / Mpc^3

  • d_l (ArrayLike) –

    The angular diameter distance to the lens.

    Unit: Mpc

  • DELTA (float) –

    The overdensity parameter.

    Unit: unitless

Returns:

The concentration parameter “c” for a TNFW profile.

Unit: unitless

Return type:

ArrayLike

caustics.lenses.func.convergence_0_pseudo_jaffe(mass, Rc, Rs, d_l, critical_surface_density)[source]#

Compute the convergence (dimensionless surface mass density). This is rearranged from Eliasdottir et al 2007 equation A11.

Parameters:
  • mass (ArrayLike) –

    Total mass of the lens (Msun).

    Unit: Msun

  • Rc (ArrayLike) –

    Core radius of the lens.

    Unit: arcsec

  • Rs (ArrayLike) –

    Scaling radius of the lens.

    Unit: arcsec

  • d_l (ArrayLike) –

    Distance to the lens.

    Unit: Mpc

  • critical_surface_density (ArrayLike) –

    Critical surface density of the universe at the lens redshift.

    Unit: Msun / Mpc^2

Returns:

The convergence (dimensionless surface mass density) at the center of the pseudo jaffe.

Unit: unitless

Return type:

ArrayLike

caustics.lenses.func.convergence_enclosed_mass(x0, y0, q, phi, enclosed_mass, x, y, critical_surface_density, s=0.0)[source]#

Calculate the convergence for a lens with an enclosed mass profile. See the Meneghetti lecture notes Equation 3.28 for the convergence from an enclosed mass profile.

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • q (ArrayLike) –

    The axis ratio of the lens. ratio of semi-minor to semi-major axis (b/a).

    Unit: unitless

  • phi (ArrayLike) –

    The position angle of the lens. The angle relative to the positive x-axis.

    Unit: radians

  • enclosed_mass (Callable) – The enclosed mass profile function, solely a function of r.

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

Returns:

The convergence.

Return type:

ArrayLike

caustics.lenses.func.convergence_epl(x0, y0, q, phi, Rein, t, x, y, s=0.0)[source]#

Calculate the reduced deflection angle.

See Tessore et al. 2015 equation 2.

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • q (ArrayLike) –

    The axis ratio of the lens. Semi-minor over semi-major axis lengths.

    Unit: unitless

  • phi (ArrayLike) –

    The orientation angle of the lens (position angle).

    Unit: radians

  • Rein (ArrayLike) –

    The Einstein radius of the lens.

    Unit: arcsec

  • t (ArrayLike) –

    Power law slope (gamma-1) of the lens. If not provided, it is considered as a free parameter.

    Unit: unitless

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

  • s (float) –

    The core radius of the lens (defaults to 0.0).

    Unit: arcsec

Returns:

  • x_component (ArrayLike) – The x-component of the deflection angle.

    Unit: arcsec

  • y_component (ArrayLike) – The y-component of the deflection angle.

    Unit: arcsec

caustics.lenses.func.convergence_mass_sheet(kappa, x)[source]#

Compute the lensing convergence. In the case of a mass sheet, this is just the convergence value mapped to the input shape.

Parameters:
  • kappa (Optional[Union[ArrayLike, float]]) –

    Convergence. Surface density normalized by the critical surface density.

    Unit: unitless

  • x (ArrayLike) –

    The x-coordinate of the lens. Only used for shape and device.

    Unit: arcsec

Returns:

The lensing potential.

Unit: arcsec^2

Return type:

ArrayLike

caustics.lenses.func.convergence_multipole(x0, y0, m, a_m, phi_m, x, y)[source]#

Compute the lensing convergence.

Parameters:
  • x (ArrayLike) – x-coordinates in the lens plane.

  • y (ArrayLike) – y-coordinates in the lens plane.

  • x0 (ArrayLike) – x-coordinate of the center of the lens.

  • y0 (ArrayLike) – y-coordinate of the center of the lens.

  • m (ArrayLike) – The multipole order(s).

  • a_m (ArrayLike) – The multipole amplitude(s).

  • phi_m (ArrayLike) – The multipole orientation(s).

Returns:

  • convergence (ArrayLike) – Lensing convergence.

    Unit: unitless

  • Equation (B10) and (B3) https (//arxiv.org/pdf/1307.4220, Xu et al. 2014)

caustics.lenses.func.convergence_nfw(critical_surface_density, critical_density, x0, y0, mass, c, x, y, d_l, DELTA=200.0, s=0.0)[source]#

Compute the convergence. This can be found in the Meneghetti Lecture notes equation 3.74.

Parameters:
  • critical_surface_density (ArrayLike) –

    The critical surface density of the Universe at the appropriate redshift.

    Unit: Msun/Mpc^2

  • critical_density (ArrayLike) –

    The critical density of the Universe at the appropriate redshift.

    Unit: Msun/Mpc^3

  • mass (ArrayLike) – The mass of the halo

  • c (Optional[ArrayLike]) –

    Concentration parameter of the lens. Default is None.

    Unit: unitless

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • s (float) –

    Softening parameter to avoid singularities at the center of the lens. Default is 0.0.

    Unit: arcsec

caustics.lenses.func.convergence_point(x0, y0, x, y)[source]#

Compute the convergence (dimensionless surface mass density). This follows essenitally by definition.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

Returns:

The convergence (dimensionless surface mass density).

Unit: unitless

Return type:

ArrayLike

caustics.lenses.func.convergence_pseudo_jaffe(x0, y0, mass, Rc, Rs, x, y, d_l, critical_surface_density, s=0.0)[source]#

Compute the convergence (dimensionless surface mass density). See Eliasdottir et al 2007 Equation A3.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • mass (ArrayLike) –

    Total mass of the lens

    Unit: Msun

  • Rc (ArrayLike) –

    Core radius of the lens.

    Unit: arcsec

  • Rs (ArrayLike) –

    Scaling radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • d_l (ArrayLike) –

    Distance to the lens.

    Unit: Mpc

  • critical_surface_density (ArrayLike) –

    Critical surface density of the universe at the lens redshift.

    Unit: Msun / Mpc^2

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

caustics.lenses.func.convergence_sie(x0, y0, q, phi, Rein, x, y, s=0.0)[source]#

Calculate the projected mass density. This is converted from the SIS convergence definition.

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • q (ArrayLike) –

    The axis ratio of the lens.

    Unit: unitless

  • phi (ArrayLike) –

    The orientation angle of the lens (position angle).

    Unit: radians

  • Rein (ArrayLike) –

    The Einstein radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

  • s (float) –

    The core radius of the lens (defaults to 0.0).

    Unit: arcsec

Returns:

The projected mass density.

Unit: unitless

Return type:

ArrayLike

caustics.lenses.func.convergence_sis(x0, y0, Rein, x, y, s=0.0)[source]#

Compute the lensing convergence. See the Meneghetti lecture notes equation 3.44.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • Rein (ArrayLike) –

    Einstein radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

Returns:

convergence – Lensing convergence.

Unit: unitless

Return type:

ArrayLike

caustics.lenses.func.convergence_tnfw(x0, y0, Rs, tau, x, y, critical_density, M0, d_l, s=0.0)[source]#

Compute the dimensionless convergence for the TNFW. See Baltz et al. 2009 equation A.8

Parameters

Unit: arcsec

y0: ArrayLike

The y-coordinate of the lens center.

Unit: arcsec

Rs: ArrayLike

The scale radius of the TNFW lens.

Unit: arcsec

tau: ArrayLike

The truncation scale. Ratio of truncation radius to scale radius.

Unit: unitless

x: ArrayLike

The x-coordinate in the lens plane.

Unit: arcsec

y: ArrayLike

The y-coordinate in the lens plane.

Unit: arcsec

M0: ArrayLike

The mass normalization constant. See M0_totmass_tnfw and M0_scalemass_tnfw.

Unit: Msun

d_l: ArrayLike

The angular diameter distance to the lens.

Unit: Mpc

s: float

Softening parameter to prevent numerical instabilities.

Unit: arcsec

caustics.lenses.func.forward_raytrace(s, raytrace, x0, y0, fov, n, epsilon, max_depth=25)[source]#
caustics.lenses.func.forward_raytrace_rootfind(ix, iy, bx, by, raytrace)[source]#

Perform a forward ray-tracing operation which maps from the source plane to the image plane.

Parameters:
  • ix (ArrayLike) –

    ArrayLike of x coordinate in the image plane. This initializes the ray-tracing optimization. Should have shape (B, 2).

    Unit: arcsec

  • iy (ArrayLike) – ArrayLike of y coordinate in the image plane. This initializes the ray-tracing optimization. Should have shape (B, 2).

  • bx (ArrayLike) –

    ArrayLike of x coordinate in the source plane. Should be a scalar.

    Unit: arcsec

  • by (ArrayLike) –

    ArrayLike of y coordinate in the source plane. Should be a scalar.

    Unit: arcsec

  • raytrace (function) – function that takes in the x and y coordinates in the image plane and returns the x and y coordinates in the source plane.

Returns:

  • x_component (ArrayLike) – x-coordinate ArrayLike of the ray-traced light rays

    Unit: arcsec

  • y_component (ArrayLike) – y-coordinate ArrayLike of the ray-traced light rays

    Unit: arcsec

caustics.lenses.func.gamma_phi_to_gamma1(gamma, phi)[source]#

Convert the shear magnitude and angle to the gamma_1 component.

Parameters:
  • gamma (ArrayLike) –

    The shear magnitude.

    Unit: unitless

  • phi (ArrayLike) –

    The shear angle.

    Unit: radians

Returns:

The gamma_1 component of the shear.

Unit: unitless

Return type:

ArrayLike

caustics.lenses.func.gamma_phi_to_gamma2(gamma, phi)[source]#

Convert the shear magnitude and angle to the gamma_2 component.

Parameters:
  • gamma (ArrayLike) –

    The shear magnitude.

    Unit: unitless

  • phi (ArrayLike) –

    The shear angle.

    Unit: radians

Returns:

The gamma_2 component of the shear.

Unit: unitless

Return type:

ArrayLike

caustics.lenses.func.mass_enclosed_2d_pseudo_jaffe(radius, mass, Rc, Rs, s=0.0)[source]#

Compute the mass enclosed within a given radius. See Eliasdottir et al 2007 equation A10.

Parameters:
  • radius (Optional[ArrayLike]) –

    Radius at which to calculate enclosed mass (arcsec).

    Unit: arcsec

  • mass (ArrayLike) –

    Total mass of the lens

    Unit: Msun

  • Rc (ArrayLike) –

    Core radius of the lens.

    Unit: arcsec

  • Rs (ArrayLike) –

    Scaling radius of the lens.

    Unit: arcsec

caustics.lenses.func.mass_enclosed_2d_tnfw(r, Rs, tau, M0)[source]#

Total projected mass (Msun) within a radius r (arcsec). Given in Baltz et al. 2009 equation A.11

Parameters:
  • r (ArrayLike) –

    Radius at which to compute the enclosed mass.

    Unit: arcsec

  • mass (ArrayLike) –

    Mass of the lens.

    Unit: Msun

  • Rs (ArrayLike) –

    Scale radius of the TNFW lens.

    Unit: arcsec

  • tau (ArrayLike) –

    Truncation scale. Ratio of truncation radius to scale radius.

    Unit: unitless

Returns:

Integrated mass projected in infinite cylinder within radius r.

Unit: Msun

Return type:

ArrayLike

caustics.lenses.func.mass_to_rein_point(M, d_ls, d_l, d_s)[source]#

Compute the Einstein radius of a point mass. See Meneghetti lecture notes equation 1.39

Parameters:
  • M (ArrayLike) –

    Mass of the lens.

    Unit: solar masses

  • d_ls (ArrayLike) –

    Distance between the lens and the source.

    Unit: Mpc

  • d_l (ArrayLike) –

    Distance between the observer and the lens.

    Unit: Mpc

  • d_s (ArrayLike) –

    Distance between the observer and the source.

    Unit: Mpc

Returns:

The Einstein radius.

Unit: arcsec

Return type:

ArrayLike

caustics.lenses.func.physical_deflection_angle_enclosed_mass(x0, y0, q, phi, enclosed_mass, x, y, s=0.0)[source]#

Calculate the reduced deflection angle for a lens with an enclosed mass profile. See the Meneghetti lecture notes Equation 3.19 for the physical deflection angle.

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • q (ArrayLike) –

    The axis ratio of the lens. ratio of semi-minor to semi-major axis (b/a).

    Unit: unitless

  • phi (ArrayLike) –

    The position angle of the lens. The angle relative to the positive x-axis.

    Unit: radians

  • enclosed_mass (Callable) – The enclosed mass profile function, solely a function of r.

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

Returns:

The physical deflection angle.

Return type:

tuple[ArrayLike, ArrayLike]

caustics.lenses.func.physical_deflection_angle_nfw(x0, y0, mass, c, critical_density, d_l, x, y, DELTA=200.0, s=0.0)[source]#

Compute the physical deflection angles. This is an expanded form of the Meneghetti notes equation 3.72

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • mass (ArrayLike) –

    Mass of the lens. Default is None.

    Unit: Msun

  • c (ArrayLike) –

    Concentration parameter of the lens. Default is None.

    Unit: unitless

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • s (float) –

    Softening parameter to avoid singularities at the center of the lens. Default is 0.0.

    Unit: arcsec

caustics.lenses.func.physical_deflection_angle_tnfw(x0, y0, Rs, tau, x, y, M0, d_l, s=0.0)[source]#

Compute the physical deflection angle for a TNFW profile. Converted from Baltz et al. 2009 equation A.18

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • Rs (ArrayLike) –

    The scale radius of the TNFW lens.

    Unit: arcsec

  • tau (ArrayLike) –

    The truncation scale. Ratio of truncation radius to scale radius.

    Unit: unitless

  • x (ArrayLike) –

    The x-coordinate in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate in the lens plane.

    Unit: arcsec

  • M0 (ArrayLike) –

    The mass normalization constant. See M0_totmass_tnfw and M0_scalemass_tnfw.

    Unit: Msun

  • d_l (ArrayLike) –

    The angular diameter distance to the lens.

    Unit: Mpc

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

caustics.lenses.func.physical_from_reduced_deflection_angle(ax, ay, d_s, d_ls)[source]#

Computes the physical deflection angle of the given the reduced deflection angles [arcsec].

Parameters:
  • ax (ArrayLike) –

    ArrayLike of x axis reduced deflection angles in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    ArrayLike of y axis reduced deflection angles in the lens plane.

    Unit: arcsec

  • d_s (float) –

    distance to the source.

    Unit: Mpc

  • d_ls (float) –

    distance from lens to source.

    Unit: Mpc

Returns:

  • x_component (ArrayLike) – Physical deflection Angle in the x-direction.

    Unit: arcsec

  • y_component (ArrayLike) – Physical deflection Angle in the y-direction.

    Unit: arcsec

caustics.lenses.func.potential_epl(x0, y0, q, phi, Rein, t, x, y, n_iter, chunk_size)[source]#

Calculate the potential for the EPL as defined in Tessore et al. 2015 equation 15.

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • q (ArrayLike) –

    The axis ratio of the lens. Semi-minor over semi-major axis lengths.

    Unit: unitless

  • phi (ArrayLike) –

    The orientation angle of the lens (position angle).

    Unit: radians

  • Rein (ArrayLike) –

    The Einstein radius of the lens.

    Unit: arcsec

  • t (ArrayLike) –

    Power law slope (gamma-1) of the lens. If not provided, it is considered as a free parameter.

    Unit: unitless

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

  • n_iter (int) –

    Number of iterations for the iterative solver.

    Unit: number

  • chunk_size (int) –

    Number of iterations to do in parallel for the iterative solver.

    Unit: number

Returns:

  • x_component (ArrayLike) – The x-component of the deflection angle.

    Unit: arcsec

  • y_component (ArrayLike) – The y-component of the deflection angle.

    Unit: arcsec

caustics.lenses.func.potential_external_shear(x0, y0, gamma_1, gamma_2, x, y)[source]#

Compute the lensing potential for an external shear field. Here we use the Meneghetti lecture notes equation 3.80

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • gamma_1 (ArrayLike) –

    The shear component in the x-direction.

    Unit: unitless

  • gamma_2 (ArrayLike) –

    The shear component in the y-direction.

    Unit: unitless

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

Returns:

The lensing potential.

Unit: arcsec^2

Return type:

ArrayLike

caustics.lenses.func.potential_mass_sheet(x0, y0, kappa, x, y)[source]#

Compute the lensing potential. Here we use the Meneghetti lecture notes equation 3.81.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • kappa (Optional[Union[ArrayLike, float]]) –

    Convergence. Surface density normalized by the critical surface density.

    Unit: unitless

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

Returns:

The lensing potential.

Unit: arcsec^2

Return type:

ArrayLike

caustics.lenses.func.potential_multipole(x0, y0, m, a_m, phi_m, x, y)[source]#

Compute the lensing potential.

Parameters:
  • x (ArrayLike) – x-coordinates in the lens plane.

  • y (ArrayLike) – y-coordinates in the lens plane.

  • x0 (ArrayLike) – x-coordinate of the center of the lens.

  • y0 (ArrayLike) – y-coordinate of the center of the lens.

  • m (ArrayLike) – The multipole order(s).

  • a_m (ArrayLike) – The multipole amplitude(s).

  • phi_m (ArrayLike) – The multipole orientation(s).

Returns:

  • potential (ArrayLike) – Lensing potential.

    Unit: arcsec^2

  • Equation (B11) and (B3) https (//arxiv.org/pdf/1307.4220, Xu et al. 2014)

caustics.lenses.func.potential_nfw(critical_surface_density, critical_density, x0, y0, mass, c, d_l, x, y, DELTA=200.0, s=0.0)[source]#

Compute the convergence. This can be found in the Meneghetti Lecture notes equation 3.70.

Parameters:
  • critical_surface_density (ArrayLike) –

    The critical surface density of the Universe at the appropriate redshift.

    Unit: Msun/Mpc^2

  • critical_density (ArrayLike) –

    The critical density of the Universe at the appropriate redshift.

    Unit: Msun/Mpc^3

  • mass (ArrayLike) – The mass of the halo

  • c (Optional[ArrayLike]) –

    Concentration parameter of the lens. Default is None.

    Unit: unitless

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • s (float) –

    Softening parameter to avoid singularities at the center of the lens. Default is 0.0.

    Unit: arcsec

caustics.lenses.func.potential_pixelated_convergence(x0, y0, convergence_map, x, y, potential_kernel, pixelscale, fov, n_pix, padding, convolution_mode='fft')[source]#

Compute the lensing potential for a pixelated convergence map. This follows from the basic formulas for potential, namely that it is the convolution of the convergence with the logarithm of a vector pointing towards the origin. For more details see the Meneghetti lecture notes equation 2.31

Parameters:
  • x0 (float) –

    The x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (float) –

    The y-coordinate of the center of the lens.

    Unit: arcsec

  • convergence_map (ArrayLike) –

    The pixelated convergence map.

    Unit: unitless

  • x (ArrayLike) –

    The x-coordinate in the lens plane at which to compute the deflection.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate in the lens plane at which to compute the deflection.

    Unit: arcsec

  • potential_kernel (ArrayLike) –

    The kernel for convolution.

    Unit: unitless

  • pixelscale (float) –

    The pixel scale of the convergence map.

    Unit: arcsec/pixel

  • fov (float) –

    The field of view of the convergence map.

    Unit: arcsec

  • n_pix (int) –

    The number of pixels in the convergence map.

    Unit: number

  • padding (str) – The type of padding to use. Either “zero”, “reflect”, “circular”, or “tile”.

  • convolution_mode (str) – The mode of convolution to use. Either “fft” or “conv2d”.

caustics.lenses.func.potential_point(x0, y0, Rein, x, y, s=0.0)[source]#

Compute the lensing potential. See the Meneghetti lecture notes equation 3.3 for more detail.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • Rein (ArrayLike) –

    Einstein radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

Returns:

The lensing potential.

Unit: arcsec^2

Return type:

ArrayLike

caustics.lenses.func.potential_pseudo_jaffe(x0, y0, mass, Rc, Rs, x, y, d_l, d_s, d_ls, s=0.0)[source]#

Compute the lensing potential for the pseudo jaffe lens. See Eliasdottir et al 2007 equation A18.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • mass (ArrayLike) –

    Total mass of the lens

    Unit: Msun

  • Rc (ArrayLike) –

    Core radius of the lens.

    Unit: arcsec

  • Rs (ArrayLike) –

    Scaling radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • d_l (ArrayLike) –

    Distance to the lens.

    Unit: Mpc

  • d_s (ArrayLike) –

    Distance to the source.

    Unit: Mpc

  • d_ls (ArrayLike) –

    Distance from the lens to the source.

    Unit: Mpc

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

caustics.lenses.func.potential_sie(x0, y0, q, phi, Rein, x, y, s=0.0)[source]#

Compute the lensing potential. For more detail see Keeton 2002 equation 33, although our Rein is defined as \(b/\sqrt(q)\) in Keeton’s notation.

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • q (ArrayLike) –

    The axis ratio of the lens.

    Unit: unitless

  • phi (ArrayLike) –

    The orientation angle of the lens (position angle).

    Unit: radians

  • Rein (ArrayLike) –

    The Einstein radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

  • s (float) –

    The core radius of the lens (defaults to 0.0).

    Unit: arcsec

Returns:

The lensing potential.

Unit: arcsec^2

Return type:

ArrayLike

caustics.lenses.func.potential_sis(x0, y0, Rein, x, y, s=0.0)[source]#

Compute the lensing potential. See the Meneghetti lecture notes equation 3.45.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • Rein (ArrayLike) –

    Einstein radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

Returns:

potential – Lensing potential.

Unit: arcsec^2

Return type:

ArrayLike

caustics.lenses.func.potential_tnfw(x0, y0, Rs, tau, x, y, M0, d_l, d_s, d_ls, s=0.0)[source]#

Compute the lensing potential for a TNFW profile. See Baltz et al. 2009 equation A.14

Parameters

Unit: arcsec

y0: ArrayLike

The y-coordinate of the lens center.

Unit: arcsec

Rs: ArrayLike

The scale radius of the TNFW lens.

Unit: arcsec

tau: ArrayLike

The truncation scale. Ratio of truncation radius to scale radius.

Unit: unitless

x: ArrayLike

The x-coordinate in the lens plane.

Unit: arcsec

y: ArrayLike

The y-coordinate in the lens plane.

Unit: arcsec

M0: ArrayLike

The mass normalization constant. See M0_totmass_tnfw and M0_scalemass_tnfw.

Unit: Msun

d_l: ArrayLike

The angular diameter distance to the lens.

Unit: Mpc

d_s: ArrayLike

The angular diameter distance to the source.

Unit: Mpc

d_ls: ArrayLike

The angular diameter distance between the lens and the source.

Unit: Mpc

s: float

Softening parameter to prevent numerical instabilities.

Unit: arcsec

caustics.lenses.func.reduced_deflection_angle_epl(x0, y0, q, phi, Rein, t, x, y, n_iter, chunk_size=None)[source]#

Calculate the reduced deflection angle. Given in Tessore et al. 2015 equation 13.

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • q (ArrayLike) –

    The axis ratio of the lens. Semi-minor over semi-major axis lengths.

    Unit: unitless

  • phi (ArrayLike) –

    The orientation angle of the lens (position angle).

    Unit: radians

  • Rein (ArrayLike) –

    The Einstein radius of the lens.

    Unit: arcsec

  • t (ArrayLike) –

    Power law slope (gamma-1) of the lens. If not provided, it is considered as a free parameter.

    Unit: unitless

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

  • n_iter (int) –

    Number of iterations for the iterative solver.

    Unit: number

  • chunk_size (int) –

    Number of iterations to do in parallel for the iterative solver.

    Unit: number

Returns:

  • x_component (ArrayLike) – The x-component of the deflection angle.

    Unit: arcsec

  • y_component (ArrayLike) – The y-component of the deflection angle.

    Unit: arcsec

caustics.lenses.func.reduced_deflection_angle_external_shear(x0, y0, gamma_1, gamma_2, x, y)[source]#

Compute the reduced deflection angles for an external shear field. Here we use the Meneghetti lecture notes and take derivatives of equation 3.80

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • gamma_1 (ArrayLike) –

    The shear component in the x-direction.

    Unit: unitless

  • gamma_2 (ArrayLike) –

    The shear component in the y-direction.

    Unit: unitless

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

Returns:

  • x_component (ArrayLike) – Deflection Angle in the x-direction.

    Unit: arcsec

  • y_component (ArrayLike) – Deflection Angle in the y-direction.

    Unit: arcsec

caustics.lenses.func.reduced_deflection_angle_mass_sheet(x0, y0, kappa, x, y)[source]#

Compute the reduced deflection angles. Here we use the Meneghetti lecture notes equation 3.84.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • kappa (Optional[Union[ArrayLike, float]]) –

    Convergence. Surface density normalized by the critical surface density.

    Unit: unitless

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

Returns:

  • x_component (ArrayLike) – Deflection Angle in the x-direction.

    Unit: arcsec

  • y_component (ArrayLike) – Deflection Angle in the y-direction.

    Unit: arcsec

caustics.lenses.func.reduced_deflection_angle_multipole(x0, y0, m, a_m, phi_m, x, y)[source]#

Calculates the reduced deflection angle.

Parameters:
  • x (ArrayLike) – x-coordinates in the lens plane.

  • y (ArrayLike) – y-coordinates in the lens plane.

  • x0 (ArrayLike) – x-coordinate of the center of the lens.

  • y0 (ArrayLike) – y-coordinate of the center of the lens.

  • m (ArrayLike) – The multipole order(s).

  • a_m (ArrayLike) – The multipole amplitude(s).

  • phi_m (ArrayLike) – The multipole orientation(s).

Returns:

  • tuple[ArrayLike, ArrayLike] – The reduced deflection angles in the x and y directions.

  • Equation (B11) and (B12) https (//arxiv.org/pdf/1307.4220, Xu et al. 2014)

caustics.lenses.func.reduced_deflection_angle_pixelated_convergence(x0, y0, convergence_map, x, y, ax_kernel, ay_kernel, pixelscale, fov, n_pix, padding, convolution_mode='fft')[source]#

Compute the reduced deflection angle for a pixelated convergence map. This follows from the basic formulas for deflection angle, namely that it is the convolution of the convergence with a unit vector pointing towards the origin. For more details see the Meneghetti lecture notes equation 2.32

Parameters:
  • x0 (float) –

    The x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (float) –

    The y-coordinate of the center of the lens.

    Unit: arcsec

  • convergence_map (ArrayLike) –

    The pixelated convergence map.

    Unit: unitless

  • x (ArrayLike) –

    The x-coordinate in the lens plane at which to compute the deflection.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate in the lens plane at which to compute the deflection.

    Unit: arcsec

  • ax_kernel (ArrayLike) –

    The x-component of the kernel for convolution.

    Unit: unitless

  • ay_kernel (ArrayLike) –

    The y-component of the kernel for convolution.

    Unit: unitless

  • pixelscale (float) –

    The pixel scale of the convergence map.

    Unit: arcsec/pixel

  • fov (float) –

    The field of view of the convergence map.

    Unit: arcsec

  • n_pix (int) –

    The number of pixels in the convergence map.

    Unit: number

  • padding (str) – The type of padding to use. Either “zero”, “reflect”, “circular”, or “tile”.

  • convolution_mode (str) – The mode of convolution to use. Either “fft” or “conv2d”.

caustics.lenses.func.reduced_deflection_angle_point(x0, y0, Rein, x, y, s=0.0)[source]#

Compute the reduced deflection angles. See the Meneghetti lecture notes equation 3.1 for more detail.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • Rein (ArrayLike) –

    Einstein radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

Returns:

  • x_component (ArrayLike) – Deflection Angle in the x-direction.

    Unit: arcsec

  • y_component (ArrayLike) – Deflection Angle in the y-direction.

    Unit: arcsec

caustics.lenses.func.reduced_deflection_angle_pseudo_jaffe(x0, y0, mass, Rc, Rs, x, y, d_l, critical_surface_density, s=0.0)[source]#

Compute the reduced deflection angle. See Eliasdottir et al 2007 equation A19.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • mass (ArrayLike) –

    Total mass of the lens

    Unit: Msun

  • Rc (ArrayLike) –

    Core radius of the lens.

    Unit: arcsec

  • Rs (ArrayLike) –

    Scaling radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • d_l (ArrayLike) –

    Distance to the lens.

    Unit: Mpc

  • critical_surface_density (ArrayLike) –

    Critical surface density of the universe at the lens redshift.

    Unit: Msun / Mpc^2

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

caustics.lenses.func.reduced_deflection_angle_sie(x0, y0, q, phi, Rein, x, y, s=0.0)[source]#

Calculate the physical deflection angle. For more detail see Keeton 2002 equations 34 and 35, although our Rein is defined as \(b/\sqrt(q)\) in Keeton’s notation.

Parameters:
  • x0 (ArrayLike) –

    The x-coordinate of the lens center.

    Unit: arcsec

  • y0 (ArrayLike) –

    The y-coordinate of the lens center.

    Unit: arcsec

  • q (ArrayLike) –

    The axis ratio of the lens.

    Unit: unitless

  • phi (ArrayLike) –

    The orientation angle of the lens (position angle).

    Unit: radians

  • Rein (ArrayLike) –

    The Einstein radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    The x-coordinate of the lens.

    Unit: arcsec

  • y (ArrayLike) –

    The y-coordinate of the lens.

    Unit: arcsec

  • s (float) –

    The core radius of the lens (defaults to 0.0).

    Unit: arcsec

Returns:

  • x_component (ArrayLike) – The x-component of the deflection angle.

    Unit: arcsec

  • y_component (ArrayLike) – The y-component of the deflection angle.

    Unit: arcsec

caustics.lenses.func.reduced_deflection_angle_sis(x0, y0, Rein, x, y, s=0.0)[source]#

Compute the reduced deflection angles. See the Meneghetti lecture notes equation 3.46.

Parameters:
  • x0 (ArrayLike) –

    x-coordinate of the center of the lens.

    Unit: arcsec

  • y0 (ArrayLike) –

    y-coordinate of the center of the lens.

    Unit: arcsec

  • Rein (ArrayLike) –

    Einstein radius of the lens.

    Unit: arcsec

  • x (ArrayLike) –

    x-coordinates in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    y-coordinates in the lens plane.

    Unit: arcsec

  • s (float) –

    Softening parameter to prevent numerical instabilities.

    Unit: arcsec

Returns:

  • x_component (ArrayLike) – Deflection Angle in the x-direction.

    Unit: arcsec

  • y_component (ArrayLike) – Deflection Angle in the y-direction.

    Unit: arcsec

caustics.lenses.func.reduced_from_physical_deflection_angle(ax, ay, d_s, d_ls)[source]#

Computes the reduced deflection angle of the lens at given coordinates [arcsec].

Parameters:
  • ax (ArrayLike) –

    ArrayLike of x axis physical deflection angles in the lens plane.

    Unit: arcsec

  • y (ArrayLike) –

    ArrayLike of y axis physical deflection angles in the lens plane.

    Unit: arcsec

  • d_s (float) –

    distance to the source.

    Unit: Mpc

  • d_ls (float) –

    distance from lens to source.

    Unit: Mpc

Returns:

  • x_component (ArrayLike) – Reduced deflection Angle in the x-direction.

    Unit: arcsec

  • y_component (ArrayLike) – Reduced deflection Angle in the y-direction.

    Unit: arcsec

caustics.lenses.func.rein_to_mass_point(r, d_ls, d_l, d_s)[source]#

Compute the Einstein radius of a point mass. See Meneghetti lecture notes equation 1.39

Parameters:
  • r (ArrayLike) –

    Einstein radius of the lens.

    Unit: arcsec

  • d_ls (ArrayLike) –

    Distance between the lens and the source.

    Unit: Mpc

  • d_l (ArrayLike) –

    Distance between the observer and the lens.

    Unit: Mpc

  • d_s (ArrayLike) –

    Distance between the observer and the source.

    Unit: Mpc

Returns:

The mass of the lens

Unit: solar masses

Return type:

ArrayLike

caustics.lenses.func.remove_triangle_duplicates(p)[source]#
caustics.lenses.func.scale_density_nfw(critical_density, c, DELTA=200.0)[source]#

Compute the scale density of the NFW profile.

Parameters:
  • critical_density (ArrayLike) –

    The critical density of the Universe at the appropriate redshift.

    Unit: Msun/Mpc^3

  • c (ArrayLike) –

    The concentration parameter of the halo.

    Unit: unitless

  • DELTA (float) –

    The overdensity parameter. Amount above the critical surface density at which the scale radius is computed

    Unit: unitless

Returns:

The scale density of the NFW profile.

Unit: solar mass per square kiloparsec

Return type:

ArrayLike

caustics.lenses.func.scale_density_tnfw(c, critical_density, DELTA=200.0)[source]#
caustics.lenses.func.scale_radius_nfw(critical_density, mass, c, DELTA=200.0)[source]#

Compute the scale radius of the NFW profile.

Parameters:
  • critical_density (ArrayLike) –

    The critical density of the Universe at the appropriate redshift.

    Unit: Msun/Mpc^3

  • mass (ArrayLike) –

    The mass of the halo.

    Unit: Msun

  • c (ArrayLike) –

    The concentration parameter of the halo.

    Unit: unitless

  • DELTA (float) –

    The overdensity parameter. Amount above the critical surface density at which the scale radius is computed

    Unit: unitless

Returns:

The scale radius of the NFW profile.

Unit: Mpc

Return type:

ArrayLike

caustics.lenses.func.sigma_v_to_rein_sie(sigma_v, dls, ds)[source]#

Convert the velocity dispersion to the Einstein radius. See equation 16.22 in Dynamics and Astrophysics of Galaxies by Jo Bovy

Parameters:
  • sigma_v (ArrayLike) –

    The velocity dispersion of the lens.

    Unit: km/s

  • dls (ArrayLike) –

    The angular diameter distance between the lens and the source.

    Unit: Mpc

  • ds (ArrayLike) –

    The angular diameter distance between the observer and the source.

    Unit: Mpc

Returns:

The Einstein radius.

Unit: arcsec

Return type:

ArrayLike

caustics.lenses.func.time_delay_arcsec2_to_days(d_l, d_s, d_ls, z_l)[source]#

Computes a scaling factor to use in time delay calculations which converts the time delay (i.e. potential and deflection angle squared terms) from arcsec^2 to units of days.

caustics.lenses.func.triangle_area(p)[source]#

Determine the area of triangle p where p is a (3,2) tensor.

caustics.lenses.func.triangle_contains(p, v)[source]#

determine if point v is inside triangle p. Where p is a (3,2) tensor, and v is a (2,) tensor.

caustics.lenses.func.triangle_equals(p1, p2)[source]#

Determine if two triangles are equal. Where p1 and p2 are (3,2) tensors.

caustics.lenses.func.triangle_neighbors(p)[source]#

Build a set of neighbors for triangle p where p is a (3,2) tensor. The neighbors all have the same shape as p, but are various translations and reflections of p that share a common edge or vertex.

caustics.lenses.func.triangle_upsample(p)[source]#

Upsample triangle p where p is a (3,2) tensor. The upsampled triangles are all triangles internal to p built by taking the midpoints of the edges of p.