autolens.PointSolver#
- class PointSolver[source]#
Bases:
AbstractSolverDetermine the image plane coordinates that are traced to be a source plane coordinate.
This is performed efficiently by iteratively subdividing the image plane into triangles and checking if the source plane coordinate is contained within the triangle. The triangles are subsampled to increase the resolution.
The solver is stateless with respect to the array module (
xp); the array module is chosen per.solve()call and the initial triangle tiling is built lazily from the stored geometry primitives.- Parameters:
y_min (
float) – The extent of the image plane used to tile the initial triangles.y_max (
float) – The extent of the image plane used to tile the initial triangles.x_min (
float) – The extent of the image plane used to tile the initial triangles.x_max (
float) – The extent of the image plane used to tile the initial triangles.scale (
float) – The pixel scale of the image plane. The initial triangles have this side length.pixel_scale_precision (
float) – The target pixel scale of the image grid.magnification_threshold – The threshold for the magnification under which multiple images are filtered.
neighbor_degree (
int) – The number of times recursively add neighbors for the triangles that contain the source plane coordinate.use_jax (
bool) – IfTrue,.solve()defaults toxp=jnpandremove_infinities=False(the JAX-static-shape contract), and registersTracerplus the concrete galaxy / profile classes it carries as JAX pytrees on the first call. The user wraps the call in their own@jax.jit— see thelens_calc.pyworkspace guide for the canonical pattern.
Methods
for_gridCreate a solver for a given grid.
for_limits_and_scaleCreate a solver for an explicit image-plane extent.
Solve for the image plane coordinates that are traced to the source plane coordinate.
solve_trianglesSolve for the image plane coordinates that are traced to the source plane coordinate.
stepsIterate over the steps of the triangle solver algorithm.
tree_flattentree_unflattenAttributes
n_stepsHow many times should triangles be subdivided?
- solve(tracer, source_plane_coordinate, xp=None, plane_redshift=None, remove_infinities=None)[source]#
Solve for the image plane coordinates that are traced to the source plane coordinate.
This is done by tiling the image plane with triangles and checking if the source plane coordinate is contained within the triangle. The triangles are sub-sampled to increase the resolution with only the triangles that contain the source plane coordinate and their neighbours being kept.
The means of the triangles are then filtered to keep only those with an absolute magnification above the threshold.
The positions are stored on an array of fixed shape defined by MAX_CONTAINING_SIZE. This ensures the array is static, which is important for JAX compatibility. This array typically has many entries which use the sentinel value of inf, subsequent JAX calculations incorporated. By default, these sentinel values are removed from the output, for example general use outside of JAX when simulating strong lenses.
- Parameters:
tracer (
Tracer) – The tracer that traces the image plane coordinates to the source plane.source_plane_coordinate (
Tuple[float,float]) – The plane coordinate to trace to the image plane, which by default in the source-plane coordinate but could be a coordinate in another plane is plane_redshift is input.xp – The array module (
numpyorjax.numpy) the solve runs in.AnalysisPointpassesjax.numpywhenuse_jax=Trueis set on the analysis. WhenNone(the default), falls back toself._xp— which isjnpif the solver was constructed withuse_jax=Trueandnpotherwise. Pass explicitly to override.plane_redshift (
Optional[float]) – The redshift of the plane coordinate, which for multi-plane systems may not be the source-plane.remove_infinities (
Optional[bool]) – Whether to strip theinfsentinel rows from the output. WhenNone(the default), defaults toTrueon the NumPy path andFalseon the JAX path. The JAX path keeps the padded static shape so the output crosses ajax.jitboundary cleanly; strip the infinities outside the jit if needed.
- Returns:
A
Grid2DIrregularof image-plane coordinates. NumPy-backed on the default path,jax.Array-backed whenuse_jax=True(orxp=jnp).
Notes
Smoke-test short-circuit (
PYAUTO_SMALL_DATASETS): the triangle-tiling solve is the dominant cost in many simulator scripts and is meaningless on the downsized grids used for fast smoke tests. WhenPYAUTO_SMALL_DATASETS=1is set the solver returns the fixed pair[(1.0, 0.0), (0.0, 1.0)]immediately, skippingsolve_trianglesentirely. The two coordinates are well separated so any downstreampositions_likelihood_from/ threshold calculation behaves normally.PYAUTO_SMALL_DATASETSis a smoke-test-only flag and is never set inside ajax.jittrace, so a plain numpy-backedGrid2DIrregularis safe here even when the surrounding analysis usesxp=jnp.