Skip to content

docs: explain mesh magnification and check it against truth in pixelization source_science - #606

Merged
Jammy2211 merged 2 commits into
mainfrom
feature/pixelization-mesh-mag-docs
Oct 30, 2026
Merged

Jammy2211 merged 2 commits into
mainfrom
feature/pixelization-mesh-mag-docs

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

The four pixelization source_science.py examples computed magnifications that were far from the truth, and their prose named a non-existent mesh_areas attribute. This PR documents the mesh magnification properly and makes the examples give the right answers, checked against each simulated dataset's true magnification (arc phase 4e of epic cluster-strong-lensing, before phase 6).

  • Magnification via Mesh (all four): mapper.mesh_geometry.areas_for_magnification is each pixel's basis-function integral, so sum(reconstruction * areas) is the source's total surface brightness; how the areas are computed per mesh (exact for rectangular + Delaunay, numerical for kNN, ~0.5% approximation for DelaunayNN); accuracy; points to the magnification latent. Imaging/interferometer carry the full explanation, group/multi_galaxy a short version pointing to it.
  • True Magnification (new section, all four): computes the simulator's truth from tracer.json and prints it beside the estimates, and explains that the remaining difference is the reconstruction (regularization smoothing), not the areas.
  • imaging: scale the extra galaxy out of the fit (mask_extra_galaxies.fits, invert=True) — its light was being reconstructed as source light (mesh 16.6 vs truth 34.9).
  • interferometer: regularization coefficient 0.1 for the fixed fit (1.0 over-smoothed the source; mesh 4.5 vs truth 7.2).
  • griddata(..., fill_value=0.0) on reconstruction interpolations, so interpolated sums are no longer NaN (noise-map interpolation keeps NaN deliberately).

Human prose ruling: describe the calculation as it stands — no "fixed"/"now exact" history; accuracy figures are fine; no PR numbers in user prose.

Upstream PR

PyAutoLabs/PyAutoArray#668 (merged) — true pixel centres for adaptive rectangular meshes (the interpolation route depends on it). The areas text also describes PyAutoArray#664/#666 (merged). All three are pending release: on PyPI 2026.10.29.1 the interpolation route and kNN/adaptive areas give the old answers.

Scripts Changed

  • scripts/imaging/features/pixelization/source_science.py
  • scripts/interferometer/features/pixelization/source_science.py
  • scripts/group/features/pixelization/source_science.py
  • scripts/multi_galaxy/features/pixelization/source_science.py
  • matching notebooks regenerated (autohands generate autolens, unrelated drift reverted), llms-full.txt / workspace_index.json catalogue entries

Test Plan

Full-size datasets, PYAUTO_TEST_MODE=2, library mains (incl. #668):

script truth mesh interpolation
imaging 34.91 31.63 (−9.4%) 33.22 (−4.9%)
interferometer 7.16 7.62 (+6.4%) 11.82 (+65%)
group 20.51 20.00 (−2.5%) 20.34 (−0.8%)
multi_galaxy 25.58 22.70 (−11%) 24.10 (−5.8%)

Before: imaging mesh 16.6 / interp 7.2; interferometer mesh 4.5; group/multi interpolation NaN.

  • All four run clean in CI smoke mode (PYAUTO_TEST_MODE=2 PYAUTO_SMALL_DATASETS=1)
  • black clean; prose grep: no fix/history wording

Heart at ship: STALE — "release validation stale: source moved since rehearsal (PyAutoFit, PyAutoArray, PyAutoGalaxy, PyAutoLens)"; acknowledged by the human, who authorized shipping and merge on green 2026-10-30.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

Jammy2211 and others added 2 commits October 30, 2026 10:09
…ce scripts

Parked behind a PyAutoArray fix: source_plane_mesh_grid is the uniform overlay
for adaptive rectangular meshes (see autolens_workspace#605 comment).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…zation source_science

- Magnification via Mesh: what `areas_for_magnification` is (each pixel's basis-function
  integral), how it is computed per mesh, its accuracy, and when to use it over the
  interpolation grid; points to the `magnification` latent
- True Magnification: compute the simulator's true magnification from `tracer.json`
  and print it beside the estimates
- imaging: scale the extra galaxy out of the fit (it was reconstructed as source light)
- interferometer: regularization coefficient 0.1 (1.0 over-smoothed the source)
- griddata fill_value=0.0 so interpolated sums are not NaN

Closes #605

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jammy2211
Jammy2211 merged commit 65efb65 into main Oct 30, 2026
8 checks passed
@Jammy2211
Jammy2211 deleted the feature/pixelization-mesh-mag-docs branch October 30, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant