feat: image↔source mapping regions, clumps, subplot_mappings (P1) - #517
Merged
Merged
Conversation
…appings Add autoarray/inversion/mappings/ (Mapping, ImageRegion, mesh-graph connected components, image-plane regions from the mapping matrix, arcsec boundary polygons), Inversion.source_clumps_from / mappings_from, Mapper.mappings_from, a regions= polygon overlay on plot_array / plot_inversion_reconstruction / plot_mapper, and rewrite subplot_mappings as the 2x2 colour-matched figure of how each bright source clump maps to its multiple images. Config keys total_mappings / mappings_threshold / mappings_min_pixels replace the dead total_mappings_pixels (read as a fallback). Phase 1 of the image-source-mappings epic. Closes #515. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V2ujRnmqc3jGh82hZAQ9iJ
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.
Closes #515. Phase 1 of the
image-source-mappingsepic (PyAutoMind ledgerdraft/feature/autoarray/image_source_mappings_epic.md).Summary
Restores image-plane ↔ source-plane mapping visualization, which was hollowed out by
0cb75ebd(2025-07-21) and the 2026-03 plotter removal:subplot_mappingshad been computing peak source pixels and discarding them. This PR adds plotting-agnostic mapping objects, source clump finding on the mesh, a generic arcsec-polygonregions=overlay, and rewritessubplot_mappingsas the one-look figure of how each bright source clump maps to its multiple images, colour-matched across both planes.autoarray/inversion/mappings/package:ImageRegion(one connected image-plane region: slim indexes, mask, arcsec boundary loops, centre,area(),brightest_coordinate_from,centroid_from,flux_from) andMapping(source pixels + source polygons + the image regions they map to); helpers for mesh-graph connected components, image regions from the mapping matrix, and pixel-edge boundary tracing.Inversion.source_clumps_from/Inversion.mappings_from: threshold × max, connected components overMapper.neighbors, min-pixel filter, brightest-first, explicitpix_indexesbypass.Mapper.mappings_fromfor bare mappers (tutorial use).regions/region_colors/region_alpha/region_labelsonplot_arrayandplot_inversion_reconstruction;subplot_image_and_mapperpasses them through.subplot_mappingsrewritten (2×2, matched colours, numbered clumps). Config:total_mappings,mappings_threshold,mappings_min_pixelsreplace the deadtotal_mappings_pixels(still read as a fallback).Design constraints honoured (see issue): image regions are built from
mapping_matrix, notslim_indexes_for_pix_indexes(which returns sub-slim indexes); overlays are arcsec polygons becauseplot_arraycrops viazoom_arraybefore drawing; Delaunay clumps are drawn as Voronoi cells.API Changes
Additive only.
aa.Mapping,aa.ImageRegion(new, exported fromautoarray).Inversion.source_clumps_from(mapper_index=0, threshold=0.5, min_pixels=3, total_clumps=None, pix_indexes=None),Inversion.mappings_from(mapper_index=0, weight_threshold=0.0, **clump_kwargs).Mapper.mappings_from(pix_indexes, weight_threshold=0.0, min_pixels=1).plot_array(..., regions=None, region_colors=None, region_alpha=0.25, region_labels=None); same onplot_inversion_reconstruction;subplot_image_and_mapper(..., regions=None, region_colors=None, region_labels=None).subplot_mappings(inversion, pixelization_index=0, ..., threshold=None, min_pixels=None, total_clumps=None, pix_indexes=None, weight_threshold=0.0)— existing positional/keyword usage unchanged; figure content changes from a plain 2×2 to the mapping figure.visualize/general.yamlinversion:keystotal_mappings,mappings_threshold,mappings_min_pixels;total_mappings_pixelsdeprecated (fallback for one release).Downstream
subplot_mappings(inversion=..., pixelization_index=0)(autolens_workspaceimaging/group/interferometer/multi_galaxypixelization/fit.py) keep working and now produce the promised mapping figure. Prose updates land in Phase 3.subplot_mappings, brightest multiple-image positions) builds onImageRegion/Mappingand must wait for this to merge and release.Test plan
pytest test_autoarray/inversion test_autoarray/plot— new tests for connected components, image regions from a bimodal mapping matrix, closed contours, brightest/centroid,source_clumps_from(two peaks / low threshold / passthrough / truncation / all-negative),regions=overlays,subplot_mappingsrectangular + Delaunay +pix_indexes.pytest test_autoarray.subplot_mappingson a two-peak synthetic reconstruction renders two colours, each clump's images outlined in the same colour in both image panels.🤖 Generated with Claude Code
https://claude.ai/code/session_01V2ujRnmqc3jGh82hZAQ9iJ