Repository navigation
fix: adaptive rectangular meshes report their true pixel centres - #668
Merged
Merged
Conversation
`mapper.source_plane_mesh_grid` for the four adaptive rectangular meshes returned the uniform overlay the interpolator is built from, not the source-plane positions where the mapper's interpolant takes each reconstruction value (the regular CDF lattice mapped back through the inverse CDF). Anything placing the reconstruction from those positions was wrong: the reconstruction CSV, `max_pixel_centre` (used by PyAutoLens automatic position updating), plot zoom (`extent_from`), PyAutoLens potential correction and workspace interpolation of the source. - `adaptive_rectangular_node_centres_from` + `MeshGeometryRectangular.node_centres` - `InterpolatorRectangular.source_plane_mesh_grid` returns the node centres - kernel regularizations and MaternSparse keep measuring distances on the lattice, now explicitly via `regularization_mesh_grid` / `regularization_mesh_grid_from` (likelihoods unchanged; true-distance kernels are a separate research question) Closes #667 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 30, 2026
2 tasks done
Collaborator
Author
|
Workspace PR: PyAutoLabs/autolens_workspace#606 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
For the four adaptive rectangular meshes (
RectangularBilinearAdaptDensity/Image,RectangularRTUAdaptDensity/Image),mapper.source_plane_mesh_gridreturned the uniform overlay the interpolator is built from, not the source-plane positions where the mapper's interpolant takes each reconstruction value. The mapper works on a regular lattice in CDF space; the real pixel centres are that lattice mapped back through the inverse CDF, and they bunch up where the mesh adapts.On autolens_workspace
imaging/simple__no_lens_light(28×28 BilinearAdaptDensity) the overlay spacing was a uniform 0.11″ while the true central spacing is ~0.036″, sogriddataof the reconstruction from the reported positions integrated ~4.6× too high (interpolation-route magnification 6.9 vs mesh-route 31.6 vs truth 34.9).Everything that places the reconstruction from those positions was wrong and is fixed by this PR:
source_plane_reconstruction_{i}.csvy/x columns (inversion_plots.py)inversion.max_pixel_centre→ PyAutoLens automatic position updating (result.py). Measured shift on a centred source: brightest pixel at (−0.055″, 0.044″) → (0.018″, 0.020″) (truth (0, 0)); larger for sources offset within the mesh.Mapper.extent_fromzoom-to-brightest for plotsPlots of the mesh itself were already right (they use
edges_transformed). Areas (areas_for_magnification) are untouched.Regularization — deliberately unchanged. Kernel regularizations (
ExponentialKernel,GaussianKernel,MaternKernel,MaternAdaptKernel) andMaternSparsehave always measured distances on the lattice (the mesh's stretched coordinates). Tuned separately on the test lens, lattice distances beat true distances on Bayesian evidence (Matern 1923.5 vs 1812.1; Gaussian 2105.3 vs 1758.6) while true distances were ~1 point better on magnification. Human ruling: keep the lattice explicitly (newregularization_mesh_grid), so no likelihood changes; the question goes to an end-to-end research study (Minddraft/research/autolens_inference/kernel_regularization_distances_adaptive_rectangular.md).Heart at ship: STALE — "release validation stale: source moved since rehearsal (PyAutoFit, PyAutoArray, PyAutoGalaxy, PyAutoLens)"; acknowledged by the human 2026-10-30.
Release note: the reconstruction CSV's y/x columns change for adaptive rectangular meshes (now the true pixel centres).
API Changes
Mapper.source_plane_mesh_gridnow returns the true source-plane pixel centres for adaptive rectangular meshes (was the uniform overlay). NewMeshGeometryRectangular.node_centresandMapper.regularization_mesh_grid(the lattice kernel regularizations measure distances on). Likelihoods are unchanged.See full details below.
Test Plan
test_autoarray/inversion/pixelization/mesh_geometry/test_node_centres.py: each node's interpolation weight is ~1 at its reported centre (all 4 adaptive meshes, on a distorted lensing-like grid); centres form a row-major lattice inside the data span; interpolating a least-squares reconstruction from the centres recovers the analytic integral (density meshes ~2%; image-adaptive meshes much closer than the overlay); RectangularUniform unchanged.DpsiLinearObj) fixed byregularization_mesh_grid_from's fallback;test_autolens/potential_correction60 passedscripts/imaging/mesh_magnification.py: all meshes within tolerance, identical to beforeFull API Changes (for automation & release notes)
Added
autoarray.inversion.mesh.interpolator.rectangular.adaptive_rectangular_node_centres_from(source_grid_shape, data_grid, mesh_weight_map=None, bandwidth=, n_knots=, transform=, xp=np)— source-plane centre of every adaptive-mesh node, in mapper orderMeshGeometryRectangular.node_centres— true pixel centres (mesh_gridforRectangularUniform)AbstractInterpolator.source_plane_mesh_grid,AbstractInterpolator.regularization_mesh_grid(both default tomesh_grid)Mapper.regularization_mesh_grid— positions kernel regularizations measure distances onautoarray.inversion.regularization.abstract.regularization_mesh_grid_from(linear_obj)—regularization_mesh_grid, falling back tosource_plane_mesh_gridfor duck-typed linear objectsChanged Behaviour
Mapper.source_plane_mesh_grid(viaInterpolatorRectangular.source_plane_mesh_grid) — true pixel centres for adaptive rectangular meshes; downstream: reconstruction CSV y/x,max_pixel_centre,extent_from, PyAutoLens potential correctionMaternSparsereadregularization_mesh_grid_from(linear_obj)instead oflinear_obj.source_plane_mesh_grid— same values as before for every mesh (lattice for adaptive rectangular), so no likelihood changeMigration
mapper.regularization_mesh_grid(ormapper.interpolator.mesh_grid), notsource_plane_mesh_grid.Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code