autolens.LensCalc#
- class LensCalc[source]#
Bases:
objectComputes lensing quantities from a deflection-angle callable and an optional potential callable.
The deflection callable is used to compute the Hessian, Jacobian, convergence, shear, magnification, critical curves, caustics, and Einstein radius/mass. If a potential callable is also supplied,
fermat_potential_fromis available as well.- Parameters:
deflections_yx_2d_from – A callable with signature
(grid, xp=np, **kwargs)that returns the 2D deflection angles on the given grid. Typically a bound method of aMassProfile,Galaxy, orGalaxiesinstance.potential_2d_from – Optional callable with signature
(grid, xp=np, **kwargs)that returns the 2D lensing potential on the given grid. Required only forfermat_potential_from.
Methods
Returns the convergence of the lensing object, which is computed from the 2D deflection angle map via the Hessian using the expression (see equation 56 https://inspirehep.net/literature/419263):
Returns the deflection angles at a single (y, x) arc-second coordinate as a JAX array of shape (2,), where index 0 is the y-deflection and index 1 is the x-deflection.
Returns the Einstein radius corresponding to the area within the tangential critical curve.
Returns a list of the angular Einstein massses corresponding to the area within each tangential critical curve.
Returns the Einstein radius corresponding to the area within the tangential critical curve.
JIT-friendly Einstein radius from the tangential critical curve.
Returns a list of the Einstein radii corresponding to the area within each tangential critical curve.
Returns a list of Einstein radii from the tangential critical curves traced via
tangential_critical_curve_list_via_zero_contour_from.Returns the Einstein radius from the tangential critical curve traced via
jax_zero_contour.Returns the Fermat potential for a given grid of image-plane positions.
Construct from any object that has a
deflections_yx_2d_frommethod.Construct from a PyAutoLens
Tracerobject.Returns the Hessian of the lensing object, where the Hessian is the second partial derivatives of the potential (see equation 55 https://inspirehep.net/literature/419263):
Returns the lensing Jacobian of the lensing object as a 2x2 list of lists.
Returns the 2D magnification map of lensing object, which is computed as the inverse of the determinant of the lensing Jacobian, expressed via the Hessian components.
Returns the 2D magnification map of lensing object, which is computed from the 2D deflection angle map via the Hessian using the expressions (see equation 60 https://inspirehep.net/literature/419263):
Returns all radial caustics of the lensing system, which are computed as follows:
Returns radial caustics by ray-tracing the radial critical curves computed via
radial_critical_curve_list_via_zero_contour_from.Returns the surface area within each radial critical curve as a list, the calculation of which is described in the function radial_critical_curve_list_from().
Returns all radial critical curves of the lensing system, which are computed as follows:
Returns radial critical curves using the
jax_zero_contourpackage.Returns the radial eigen values of lensing jacobian, which are given by the expression:
Returns the 2D weak-lensing shear vector field of the lensing object, computed from the deflection-angle Hessian (see equation 57 of https://inspirehep.net/literature/419263):
Returns all tangential caustics of the lensing system, which are computed as follows:
Returns tangential caustics by ray-tracing the tangential critical curves computed via
tangential_critical_curve_list_via_zero_contour_from.Returns the surface area within each tangential critical curve as a list, the calculation of which is described in the function tangential_critical_curve_list_from().
Returns all tangential critical curves of the lensing system, which are computed as follows:
Returns tangential critical curves using the
jax_zero_contourpackage.Returns the tangential eigen values of lensing jacobian, which are given by the expression:
Returns the geometric time delay term of the Fermat potential for a given grid of image-plane positions.
- classmethod from_mass_obj(mass_obj)[source]#
Construct from any object that has a
deflections_yx_2d_frommethod.If the object also exposes
potential_2d_from, it is captured so thatfermat_potential_fromis available on the returned instance.
- classmethod from_tracer(tracer, use_multi_plane=True, plane_i=0, plane_j=-1)[source]#
Construct from a PyAutoLens
Tracerobject.The
Tracertype is deliberately left unannotated:autogalaxydoes not depend onautolens, so no import ofTraceris performed here. Callers (which live insideautolens) are responsible for passing the correct object.- Parameters:
tracer – A PyAutoLens
Tracerinstance. Must exposedeflections_yx_2d_fromand, whenuse_multi_plane=True,deflections_between_planes_from.use_multi_plane (
bool) – IfTruethe stored callable istracer.deflections_between_planes_fromwithplane_iandplane_jbound viafunctools.partial, matching the multi-plane ray-tracing path. IfFalsethe stored callable istracer.deflections_yx_2d_from, i.e. the standard two-plane path.plane_i (
int) – Index of the first plane used bydeflections_between_planes_from. Ignored whenuse_multi_plane=False. Defaults to0(image plane).plane_j (
int) – Index of the second plane used bydeflections_between_planes_from. Ignored whenuse_multi_plane=False. Defaults to-1(source plane).
- time_delay_geometry_term_from(grid, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>)[source]#
Returns the geometric time delay term of the Fermat potential for a given grid of image-plane positions.
This term is given by:
\[\[ au_{ ext{geom}}(oldsymbol{ heta}) =\]rac{1}{2} |oldsymbol{ heta} - oldsymbol{eta}|^2]
where: - ( oldsymbol{ heta} ) is the image-plane coordinate, - ( oldsymbol{eta} = oldsymbol{ heta} - oldsymbol{lpha}(oldsymbol{ heta}) ) is the source-plane coordinate, - ( oldsymbol{lpha} ) is the deflection angle at each image-plane coordinate.
- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the deflection angles and time delay geometric term are computed on.
- Returns:
- fermat_potential_from(grid, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>)[source]#
Returns the Fermat potential for a given grid of image-plane positions.
This is the sum of the geometric time delay term and the gravitational (Shapiro) delay term (i.e. the lensing potential), and is given by:
\[\phi(\boldsymbol{\theta}) = \frac{1}{2} |\boldsymbol{\theta} - \boldsymbol{\beta}|^2 - \psi(\boldsymbol{\theta})\]Requires that
potential_2d_fromwas supplied at construction (e.g. viaLensCalc.from_mass_objorLensCalc.from_tracer).- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the Fermat potential is computed on.
xp – The array module (
numpyorjax.numpy).
- tangential_eigen_value_from(grid, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>)[source]#
Returns the tangential eigen values of lensing jacobian, which are given by the expression:
tangential_eigen_value = 1 - convergence - shear
- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the deflection angles and tangential eigen values are computed on.
xp – The array module (
numpyorjax.numpy). Passed through toconvergence_2d_via_hessian_fromandshear_yx_2d_via_hessian_from. Whenxpis notnumpythe result is a raw array rather than anaa.Array2Dwrapper.
- radial_eigen_value_from(grid, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>)[source]#
Returns the radial eigen values of lensing jacobian, which are given by the expression:
radial_eigen_value = 1 - convergence + shear
- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the deflection angles and radial eigen values are computed on.
xp – The array module (
numpyorjax.numpy). Passed through toconvergence_2d_via_hessian_fromandshear_yx_2d_via_hessian_from. Whenxpis notnumpythe result is a raw array rather than anaa.Array2Dwrapper.
- magnification_2d_from(grid, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>)[source]#
Returns the 2D magnification map of lensing object, which is computed as the inverse of the determinant of the lensing Jacobian, expressed via the Hessian components.
- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the deflection angles and magnification map are computed on.
xp – The array module (
numpyorjax.numpy). Passed through tohessian_from. Whenxpis notnumpythe result is a raw array rather than anaa.Array2Dwrapper.
- deflections_yx_scalar(y, x, pixel_scales)[source]#
Returns the deflection angles at a single (y, x) arc-second coordinate as a JAX array of shape (2,), where index 0 is the y-deflection and index 1 is the x-deflection.
This is an internal method used by hessian_from to enable JAX auto-differentiation via jax.jacfwd. The function must accept y and x as two separate scalar inputs (rather than a single combined array) so that JAX treats the function as R² -> R² and computes a proper 2x2 Jacobian matrix.
- Parameters:
y – The y arc-second coordinate (scalar).
x – The x arc-second coordinate (scalar).
pixel_scales – The pixel scales used to construct the internal (1, 1) Mask2D.
- hessian_from(grid, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>)[source]#
Returns the Hessian of the lensing object, where the Hessian is the second partial derivatives of the potential (see equation 55 https://inspirehep.net/literature/419263):
hessian_{i,j} = d^2 / dtheta_i dtheta_j
The Hessian is returned as a 4-entry tuple reflecting its structure as a 2x2 matrix: (hessian_yy, hessian_xy, hessian_yx, hessian_xx).
Two computational paths are available, selected via the xp parameter:
NumPy (
xp=np, default): 2-point central finite-difference approximation, Richardson-extrapolated at step sizeshandh/2and combined as(4 * H(h/2) - H(h)) / 3. This cancels the leadingO(h^2)truncation term, givingO(h^4)accuracy and matching the JAX path to float64 precision. JAX is not imported.JAX (
xp=jnp): exact derivatives viajax.jacfwdapplied todeflections_yx_scalar, vectorised over the grid withjnp.vectorize.
Both paths support uniform
Grid2Dand irregularGrid2DIrregulargrids.- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the Hessian is computed on.
xp – The array module (
numpyorjax.numpy). Controls which computational path is used and the type of the returned arrays.
- jacobian_from(grid, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>)[source]#
Returns the lensing Jacobian of the lensing object as a 2x2 list of lists.
The Jacobian is the matrix A = I - H, where H is the Hessian matrix of the deflection angles:
A = [[1 - hessian_xx, -hessian_xy], [-hessian_yx, 1 - hessian_yy]]It is computed from hessian_from, so it supports both uniform and irregular grids and accepts the same xp parameter for JAX acceleration.
- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the Jacobian is computed on.
xp – The array module (
numpyorjax.numpy). Passed through tohessian_from.
- convergence_2d_via_hessian_from(grid, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>)[source]#
Returns the convergence of the lensing object, which is computed from the 2D deflection angle map via the Hessian using the expression (see equation 56 https://inspirehep.net/literature/419263):
convergence = 0.5 * (hessian_{0,0} + hessian_{1,1}) = 0.5 * (hessian_xx + hessian_yy)
By going via the Hessian, the convergence can be calculated at any (y,x) coordinate therefore using either a 2D uniform or irregular grid.
This calculation of the convergence is independent of analytic calculations defined within MassProfile objects and can therefore be used as a cross-check.
- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the deflection angles and Hessian are computed on.
xp – The array module to use for the computation (e.g. numpy or jax.numpy). Passed through to hessian_from. When xp is not numpy (e.g. inside a jax.jit trace) the result is returned as a raw array rather than an aa.ArrayIrregular wrapper.
- shear_yx_2d_via_hessian_from(grid, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>)[source]#
Returns the 2D weak-lensing shear vector field of the lensing object, computed from the deflection-angle Hessian (see equation 57 of https://inspirehep.net/literature/419263):
\[ \begin{align}\begin{aligned}\gamma_1 = \tfrac{1}{2} (\partial^2 \psi / \partial x^2 - \partial^2 \psi / \partial y^2) = 0.5 \, (H_{xx} - H_{yy})\\\gamma_2 = \partial^2 \psi / \partial x \partial y = H_{xy} = H_{yx}\end{aligned}\end{align} \]where \(\psi(\theta)\) is the lensing potential and \(H_{ij}\) are its second partial derivatives, i.e. the components of the Hessian returned by
hessian_from. The two components together encode the full distortion tensor of a background source: \(\gamma_1\) is the stretch along the x/y axes and \(\gamma_2\) is the stretch along the diagonals.Because the Hessian is computed numerically (Richardson-extrapolated finite differences in NumPy, or
jax.jacfwdin JAX), this routine works for anyMassProfile,Galaxy,GalaxiesorTracerthat exposesdeflections_yx_2d_from— no per-profile analytic formula is required. It can therefore be used as a numerical cross-check of analytic shear methods such asIsothermal.shear_yx_2d_from(seetest_isothermal.py). It also accepts both uniformGrid2Dand irregularGrid2DIrregulargrids, which makes it the natural choice for simulating a weak-lensing shear field on either a regular pixel grid or at the discrete positions of background source galaxies.
- magnification_2d_via_hessian_from(grid, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>)[source]#
Returns the 2D magnification map of lensing object, which is computed from the 2D deflection angle map via the Hessian using the expressions (see equation 60 https://inspirehep.net/literature/419263):
magnification = 1.0 / det(Jacobian) = 1.0 / abs((1.0 - convergence)**2.0 - shear**2.0) magnification = (1.0 - hessian_{0,0}) * (1.0 - hessian_{1, 1)) - hessian_{0,1}*hessian_{1,0} magnification = (1.0 - hessian_xx) * (1.0 - hessian_yy)) - hessian_xy*hessian_yx
By going via the Hessian, the magnification can be calculated at any (y,x) coordinate, therefore using either a 2D uniform or irregular grid.
This calculation of the magnification is independent of calculations using the Jacobian and can therefore be used as a cross-check.
- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the deflection angles and magnification map are computed on.
- tangential_critical_curve_list_from(grid, pixel_scale=0.05)[source]#
Returns all tangential critical curves of the lensing system, which are computed as follows:
Compute the tangential eigen values for every coordinate on the input grid via the Jacobian.
Find contours of all values in the tangential eigen values that are zero using a marching squares algorithm.
Due to the use of a marching squares algorithm that requires the zero values of the tangential eigen values to be computed, critical curves can only be calculated using the Jacobian and a uniform 2D grid.
- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the deflection angles and tangential eigen values are computed on.
pixel_scale (
Union[Tuple[float,float],float]) – If input, the evaluation_grid decorator creates the 2D grid at this resolution, therefore enabling the critical curve to be computed more accurately using a higher resolution grid.
- radial_critical_curve_list_from(grid, pixel_scale=0.05)[source]#
Returns all radial critical curves of the lensing system, which are computed as follows:
Compute the radial eigen values for every coordinate on the input grid via the Jacobian.
Find contours of all values in the radial eigen values that are zero using a marching squares algorithm.
Due to the use of a marching squares algorithm that requires the zero values of the radial eigen values to be computed, this critical curves can only be calculated using the Jacobian and a uniform 2D grid.
- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the deflection angles and radial eigen values are computed on.
pixel_scale (
Union[Tuple[float,float],float]) – If input, the evaluation_grid decorator creates the 2D grid at this resolution, therefore enabling the critical curve to be computed more accurately using a higher resolution grid.
- tangential_caustic_list_from(grid, pixel_scale=0.05)[source]#
Returns all tangential caustics of the lensing system, which are computed as follows:
Compute the tangential eigen values for every coordinate on the input grid via the Jacobian.
Find contours of all values in the tangential eigen values that are zero using a marching squares algorithm.
Compute the lensing system’s deflection angles at the (y,x) coordinates of the tangential critical curve contours and ray-trace it to the source-plane, therefore forming the tangential caustics.
Due to the use of a marching squares algorithm that requires the zero values of the tangential eigen values to be computed, caustics can only be calculated using the Jacobian and a uniform 2D grid.
- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the deflection angles and tangential eigen values are computed on.
pixel_scale (
Union[Tuple[float,float],float]) – If input, the evaluation_grid decorator creates the 2D grid at this resolution, therefore enabling the caustic to be computed more accurately using a higher resolution grid.
- radial_caustic_list_from(grid, pixel_scale=0.05)[source]#
Returns all radial caustics of the lensing system, which are computed as follows:
Compute the radial eigen values for every coordinate on the input grid via the Jacobian.
Find contours of all values in the radial eigen values that are zero using a marching squares algorithm.
Compute the lensing system’s deflection angles at the (y,x) coordinates of the radial critical curve contours and ray-trace it to the source-plane, therefore forming the radial caustics.
Due to the use of a marching squares algorithm that requires the zero values of the radial eigen values to be computed, this caustics can only be calculated using the Jacobian and a uniform 2D grid.
- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the deflection angles and radial eigen values are computed on.
pixel_scale (
Union[Tuple[float,float],float]) – If input, the evaluation_grid decorator creates the 2D grid at this resolution, therefore enabling the caustic to be computed more accurately using a higher resolution grid.
- radial_critical_curve_area_list_from(grid, pixel_scale)[source]#
Returns the surface area within each radial critical curve as a list, the calculation of which is described in the function radial_critical_curve_list_from().
The area is computed via a line integral.
Due to the use of a marching squares algorithm to estimate the critical curve, this function can only use the Jacobian and a uniform 2D grid.
- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the deflection angles used to calculate the radial critical curve are computed on.
pixel_scale (
Union[Tuple[float,float],float]) – If input, the evaluation_grid decorator creates the 2D grid at this resolution, therefore enabling the caustic to be computed more accurately using a higher resolution grid.
- tangential_critical_curve_area_list_from(grid, pixel_scale=0.05)[source]#
Returns the surface area within each tangential critical curve as a list, the calculation of which is described in the function tangential_critical_curve_list_from().
The area is computed via a line integral.
Due to the use of a marching squares algorithm to estimate the critical curve, this function can only use the Jacobian and a uniform 2D grid.
- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the deflection angles used to calculate the tangential critical curve are computed on.
pixel_scale (
Union[Tuple[float,float],float]) – If input, the evaluation_grid decorator creates the 2D grid at this resolution, therefore enabling the caustic to be computed more accurately using a higher resolution grid.
- einstein_radius_list_from(grid, pixel_scale=0.05)[source]#
Returns a list of the Einstein radii corresponding to the area within each tangential critical curve.
Each Einstein radius is defined as the radius of the circle which contains the same area as the area within each tangential critical curve.
This definition is sometimes referred to as the “effective Einstein radius” in the literature and is commonly adopted in studies, for example the SLACS series of papers.
- The calculation of the tangential critical curves and their areas is described in the functions
tangential_critical_curve_list_from() and tangential_critical_curve_area_list_from().
Due to the use of a marching squares algorithm to estimate the critical curve, this function can only use the Jacobian and a uniform 2D grid.
- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the deflection angles used to calculate the tangential critical curve are computed on.
pixel_scale (
Union[Tuple[float,float],float]) – If input, the evaluation_grid decorator creates the 2D grid at this resolution, therefore enabling the caustic to be computed more accurately using a higher resolution grid.
- einstein_radius_from(grid, pixel_scale=0.05)[source]#
Returns the Einstein radius corresponding to the area within the tangential critical curve.
The Einstein radius is defined as the radius of the circle which contains the same area as the area within the tangential critical curve.
This definition is sometimes referred to as the “effective Einstein radius” in the literature and is commonly adopted in studies, for example the SLACS series of papers.
If there are multiple tangential critical curves (e.g. because the mass distribution is complex) this function raises an error, and the function einstein_radius_list_from() should be used instead.
- The calculation of the tangential critical curves and their areas is described in the functions
tangential_critical_curve_list_from() and tangential_critical_curve_area_list_from().
Due to the use of a marching squares algorithm to estimate the critical curve, this function can only use the Jacobian and a uniform 2D grid.
- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the deflection angles used to calculate the tangential critical curve are computed on.
pixel_scale (
Union[Tuple[float,float],float]) – If input, the evaluation_grid decorator creates the 2D grid at this resolution, therefore enabling the caustic to be computed more accurately using a higher resolution grid.
- einstein_mass_angular_list_from(grid, pixel_scale=0.05)[source]#
Returns a list of the angular Einstein massses corresponding to the area within each tangential critical curve.
The angular Einstein mass is defined as: einstein_mass = pi * einstein_radius ** 2.0 where the Einstein radius is the radius of the circle which contains the same area as the area within the tangential critical curve.
The Einstein mass is returned in units of arcsecond**2.0 and requires division by the lensing critical surface density sigma_cr to be converted to physical units like solar masses (see autogalaxy.util.cosmology_util).
This definition of Eisntein radius (and therefore mass) is sometimes referred to as the “effective Einstein radius” in the literature and is commonly adopted in studies, for example the SLACS series of papers.
The calculation of the einstein radius is described in the function einstein_radius_from().
Due to the use of a marching squares algorithm to estimate the critical curve, this function can only use the Jacobian and a uniform 2D grid.
- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the deflection angles used to calculate the tangential critical curve are computed on.
pixel_scale (
Union[Tuple[float,float],float]) – If input, the evaluation_grid decorator creates the 2D grid at this resolution, therefore enabling the caustic to be computed more accurately using a higher resolution grid.
- einstein_mass_angular_from(grid, pixel_scale=0.05)[source]#
Returns the Einstein radius corresponding to the area within the tangential critical curve.
The angular Einstein mass is defined as: einstein_mass = pi * einstein_radius ** 2.0 where the Einstein radius is the radius of the circle which contains the same area as the area within the tangential critical curve.
The Einstein mass is returned in units of arcsecond**2.0 and requires division by the lensing critical surface density sigma_cr to be converted to physical units like solar masses (see autogalaxy.util.cosmology_util).
This definition of Eisntein radius (and therefore mass) is sometimes referred to as the “effective Einstein radius” in the literature and is commonly adopted in studies, for example the SLACS series of papers.
The calculation of the einstein radius is described in the function einstein_radius_from().
Due to the use of a marching squares algorithm to estimate the critical curve, this function can only use the Jacobian and a uniform 2D grid.
- Parameters:
grid – The 2D grid of (y,x) arc-second coordinates the deflection angles used to calculate the tangential critical curve are computed on.
pixel_scale (
Union[Tuple[float,float],float]) – If input, the evaluation_grid decorator creates the 2D grid at this resolution, therefore enabling the caustic to be computed more accurately using a higher resolution grid.
- tangential_critical_curve_list_via_zero_contour_from(init_guess=None, delta=0.05, N=500, pixel_scales=(0.05, 0.05), tol=1e-06, max_newton=5)[source]#
Returns tangential critical curves using the
jax_zero_contourpackage.Unlike
tangential_critical_curve_list_from, this method does not evaluate lensing quantities on a dense uniform grid. Instead it traces the zero contour of the tangential eigen value directly, evaluating the function only along the curve itself.The algorithm (from
jax_zero_contour.ZeroSolver):Newton’s method projects each initial guess onto the exact zero contour of the tangential eigen value.
Euler-Lagrange (gradient-perpendicular) stepping traces the contour in both directions from each projected seed point.
Tracing stops when the path closes, hits an endpoint, or exhausts
Nsteps.
- Parameters:
init_guess – JAX or NumPy array of shape
(n, 2)with rough(y, x)positions near the tangential critical curve — one seed per distinct curve. IfNonea coarse 25 × 25 grid scan is used to find seed points automatically.delta (
float) – Arc-second step size along the contour. Smaller values give denser, more accurate curves but require a largerNto trace the same total length.N (
int) – Maximum number of steps in each direction from each seed point. The traced path has at most2N + 1points per seed.pixel_scales (
Tuple[float,float]) – Pixel scales passed todeflections_yx_scalarfor its internal single-pixel mask.tol (
float) – Newton’s method convergence tolerance (forwarded toZeroSolver).max_newton (
int) – Maximum Newton iterations per step (forwarded toZeroSolver).
- Returns:
One
Grid2DIrregularper traced contour segment, matching the return type oftangential_critical_curve_list_from.- Return type:
List[aa.Grid2DIrregular]
- radial_critical_curve_list_via_zero_contour_from(init_guess=None, delta=0.05, N=500, pixel_scales=(0.05, 0.05), tol=1e-06, max_newton=5)[source]#
Returns radial critical curves using the
jax_zero_contourpackage.Identical to
tangential_critical_curve_list_via_zero_contour_fromexcept the zero contour of the radial eigen value is traced.- Parameters:
init_guess – JAX or NumPy array of shape
(n, 2)with rough(y, x)positions near the radial critical curve. IfNonea coarse grid scan finds seed points automatically.delta (
float) – Arc-second step size along the contour.N (
int) – Maximum number of steps in each direction from each seed.pixel_scales (
Tuple[float,float]) – Pixel scales passed todeflections_yx_scalar.tol (
float) – Newton’s method convergence tolerance.max_newton (
int) – Maximum Newton iterations per step.
- Return type:
List[aa.Grid2DIrregular]
- tangential_caustic_list_via_zero_contour_from(init_guess=None, delta=0.05, N=500, pixel_scales=(0.05, 0.05), tol=1e-06, max_newton=5)[source]#
Returns tangential caustics by ray-tracing the tangential critical curves computed via
tangential_critical_curve_list_via_zero_contour_from.- Parameters:
init_guess – Forwarded to
tangential_critical_curve_list_via_zero_contour_from.delta (
float) – Arc-second step size along the contour.N (
int) – Maximum steps per seed direction.pixel_scales (
Tuple[float,float]) – Pixel scales passed todeflections_yx_scalar.tol (
float) – Newton’s method convergence tolerance.max_newton (
int) – Maximum Newton iterations per step.
- Return type:
List[aa.Grid2DIrregular]
- radial_caustic_list_via_zero_contour_from(init_guess=None, delta=0.05, N=500, pixel_scales=(0.05, 0.05), tol=1e-06, max_newton=5)[source]#
Returns radial caustics by ray-tracing the radial critical curves computed via
radial_critical_curve_list_via_zero_contour_from.- Parameters:
init_guess – Forwarded to
radial_critical_curve_list_via_zero_contour_from.delta (
float) – Arc-second step size along the contour.N (
int) – Maximum steps per seed direction.pixel_scales (
Tuple[float,float]) – Pixel scales passed todeflections_yx_scalar.tol (
float) – Newton’s method convergence tolerance.max_newton (
int) – Maximum Newton iterations per step.
- Return type:
List[aa.Grid2DIrregular]
- einstein_radius_list_via_zero_contour_from(init_guess=None, delta=0.05, N=500, pixel_scales=(0.05, 0.05), tol=1e-06, max_newton=5)[source]#
Returns a list of Einstein radii from the tangential critical curves traced via
tangential_critical_curve_list_via_zero_contour_from.Each Einstein radius is the radius of the circle with the same area as the corresponding tangential critical curve.
- Parameters:
init_guess – Forwarded to
tangential_critical_curve_list_via_zero_contour_from.delta (
float) – Arc-second step size along the contour.N (
int) – Maximum steps per seed direction.pixel_scales (
Tuple[float,float]) – Pixel scales passed todeflections_yx_scalar.tol (
float) – Newton’s method convergence tolerance.max_newton (
int) – Maximum Newton iterations per step.
- Return type:
List[float]
- einstein_radius_via_zero_contour_from(init_guess=None, delta=0.05, N=500, pixel_scales=(0.05, 0.05), tol=1e-06, max_newton=5)[source]#
Returns the Einstein radius from the tangential critical curve traced via
jax_zero_contour.If there are multiple tangential critical curves the radii are summed, consistent with
einstein_radius_from.- Parameters:
init_guess – Forwarded to
einstein_radius_list_via_zero_contour_from.delta (
float) – Arc-second step size along the contour.N (
int) – Maximum steps per seed direction.pixel_scales (
Tuple[float,float]) – Pixel scales passed todeflections_yx_scalar.tol (
float) – Newton’s method convergence tolerance.max_newton (
int) – Maximum Newton iterations per step.
- Return type:
- einstein_radius_jit_from(init_guess, delta=0.05, N=500, pixel_scales=(0.05, 0.05), tol=1e-06, max_newton=5)[source]#
JIT-friendly Einstein radius from the tangential critical curve.
Designed for use inside
jax.jit(...)(e.g. the per-sample latent loop inautofit.Analysis.compute_latent_sampleswithLATENT_BATCH_MODE='jit'). Unlikeeinstein_radius_via_zero_contour_from, this method:Requires an explicit
init_guess— no marching-squares seed search (which would requireskimageand break the JAX trace).Skips
ZeroSolver.path_reduce(variable-length output, not jit-able).Computes the enclosed area directly from the raw NaN-padded paths array via a JAX-vectorised shoelace formula.
Returns a single scalar
jax.Array(not a Pythonfloat).
Do NOT combine this with
jax.vmap— the underlyingjax_zero_contour.ZeroSolver.zero_contour_finderusesjax.lax.cond/jax.lax.while_loopfor early termination, which upstream explicitly documents as incompatible withjax.vmap. For batched evaluation, wrap the caller injax.jitand loop over samples in Python (seeAnalysis.LATENT_BATCH_MODE='jit').- Parameters:
init_guess – JAX or NumPy array of shape
(n_seeds, 2)— seed positions (y, x) near the expected critical curve. For typical galaxy-scale lenses centred on the image, a single seed at[[1.0, 0.0]]works; for clusters or off-centre lenses pass a small fan of seeds (e.g. four at cardinal positions).delta (
float) – Arc-second step size along the contour. Forwarded toZeroSolver.N (
int) – Maximum steps per seed direction. Forwarded toZeroSolver.pixel_scales (
Tuple[float,float]) – Pixel scales passed todeflections_yx_scalar(used internally by_make_eigen_fn).tol (
float) – Newton’s method convergence tolerance.max_newton (
int) – Maximum Newton iterations per step.
- Returns:
Scalar Einstein radius in arc-seconds (
sqrt(area / pi)whereareais the largest enclosed area across all seeds — robust to multiple seeds landing on the same critical curve).- Return type:
jax.Array