Skip to content

feat: unfloored S/N adapt images and soft AdaptSplit images for HilbertSNR #762

Done

Description

@Jammy2211

Overview

Phase 2 of making the adapt-mesh-weighting result the default everywhere (#714 in PyAutoArray; phase 1 PyAutoLabs/PyAutoArray#717 merged, adding image_mesh.HilbertSNR, soft_snr_from, adapt_image_soft_from). HilbertSNR and the soft AdaptSplit image need the source S/N map before the 1% adapt-image floor, which only private helpers reach today. This adds a public way to get it and one function for the soft adapt images, without changing any existing output (backward compatible, as the human asked).

Plan

  • galaxy_name_image_dict_via_result_from gains minimum_percent=None (None = the config floor, unchanged; 0.0 = the S/N map before the floor, negatives set to 0), read from the same raw cache.
  • New galaxy_name_soft_image_dict_from(galaxy_name_image_dict, galaxy_names=None): the soft adapt image per galaxy, for AdaptImages → AdaptSplit.
  • Export from ag and al.
  • Tests with the existing cache stubs; full suite; a test-mode SLaM fit of the science project's unified arm rebuilt on these calls gives the same mesh and adapt image (0.0).
  • Tier: effective level: supervised; merge mode: human /prm
Detailed implementation plan

Affected Repositories

  • PyAutoGalaxy (primary)
  • PyAutoLens (one-line export in autolens/__init__.py)

Branch Survey

Repository Current Branch Dirty?
./galaxy/PyAutoGalaxy main clean
./lens/PyAutoLens main clean

Suggested branch: feature/adapt-mesh-weighting-galaxy

Implementation Steps

  1. autogalaxy/analysis/adapt_images/adapt_images.py: galaxy_name_image_dict_via_result_from(result, use_model_images=False, minimum_percent: Optional[float] = None); None reads general.adapt.adapt_minimum_percent; the floor is minimum_percent * max, so 0.0 sets only negatives to 0. Docstring: why HilbertSNR needs 0.0 (above peak S/N 200 the 1% floor lifts sky over S/N 2).
  2. Same module: galaxy_name_soft_image_dict_from(galaxy_name_image_dict, galaxy_names=None) → {name: Array2D(values=aa.image_mesh.adapt_image_soft_from(image), mask=image.mask)} for every (or the named) galaxy; others passed through.
  3. Exports: autogalaxy/__init__.py, autolens/__init__.py.
  4. Tests in test_autogalaxy/analysis/test_adapt_images.py: default unchanged; minimum_percent=0.0 equals the cached raw map clipped at 0; soft dict equals adapt_image_soft_from; galaxy_names leaves others untouched.
  5. Equivalence: scratch copy of Science/development/adapt_snr_cap/scripts/slam.py with the unified arm on these calls, test mode, compared with the saved pilot fit.

Key Files

  • autogalaxy/analysis/adapt_images/adapt_images.py
  • test_autogalaxy/analysis/test_adapt_images.py
  • autogalaxy/__init__.py, autolens/__init__.py

Heart RED override (development only)

Authorized by the human in the live session, 2026-11-26, for this task (phase 2 PyAutoGalaxy of adapt-mesh-weighting), after the RED reasons below were shown: asked "Override Heart RED for phase 2 development?", answered "Override, proceed". Scope per AUTONOMY.md "Human override for Heart RED (development only)": commit, push and the pending-release PR. Not a release, not a merge on red; merge needs every required check green and a separate human /prm. This branch does not claim to fix Heart. Passed branch gates are added at PR-open.

Heart verdict at authorization (verbatim)
Heart: RED — Release RED; monitoring RED · 14/100 · 132 unresolved (updated 12m ago)
  [red] PyAutoFit: CI failure — https://api.github.com/repos/PyAutoLabs/PyAutoFit/actions/runs/45821676293
  [red] release validation FAILED (stage integrate)
  [red] PyAutoFit: PyAutoFit: CI failure
  [red] PyAutoFit/Tests: failure
  [red] PyAutoFit/workflows/Tests: failure
  [red] PyAutoHeart/workflows/Release Integrate: failure
  [red] PyAutoHeart/workflows/Workspace Smoke: failure
  [red] Release readiness: release validation FAILED (stage integrate)
  [red] PyAutoFit: PyAutoFit: CI failure
  [red] autofit: red
  [red] autogalaxy_test: red
  [red] Workspace validation: NOT ready — 1581p / 2f / 120s @ cloud#45815945322
  [red] test_run: red
  [red] PyAutoGalaxy/test_autogalaxy/aggregator/test_dataset_setup.py::test__imaging_from__setup_json__reapplied: red
  [red] Unit-test timing: 1 test regressions (>3× baseline), 1 slow (>1.5×)
  [red] autofit: red
  [red] autofit_test: red
  [red] autogalaxy_test: red
  [red] autolens: red
  [red] Release validation: NOT release_ready — v2026.11.26.1.dev89801 profile=release (2026-11-26T10:32:12+00:00)
  [red] validation_report/stages/integrate: fail
  [red] PyAutoFit: red
  [red] PyAutoGalaxy: red
  [red] PyAutoLens: red
  [red] autolens_inference: red
  [red] autolens_workspace_developer: red
  [red] Worktree drift: 0 orphan / 0 missing / 5 dirty

Original Prompt

Click to expand starting prompt

Adapt mesh weighting phase 2: one call for the HilbertSNR mesh input and soft AdaptSplit image

Type: feature
Target: PyAutoGalaxy
Repos:

  • PyAutoGalaxy
    Difficulty: medium
    Autonomy: supervised
    Priority: high
    Consequence: judge
    Parent: complete/2026/11/adapt-mesh-weighting-library.md (PyAutoArray#716, phase 1 PR PyAutoArray#717)
    Filed: 2026-11-26

Phase 2 of making the adapt-mesh-weighting result the default everywhere (human, 2026-11-26:
"make this the default everywhere (but keep BC via Hilbert ..., ensure AdaptSplit retains BC
too), so all workspaces use the new one and a user doesnt need to supply weight_power=3.5 and
weight_floor=0.01"). Needs PyAutoArray#717 merged (image_mesh.HilbertSNR,
image_mesh.soft_snr_from, image_mesh.adapt_image_soft_from).

Problem

autogalaxy/analysis/adapt_images/adapt_images.py galaxy_name_image_dict_via_result_from
floors every adapt image at adapt_minimum_percent (1%) of its maximum. HilbertSNR and the
soft AdaptSplit image need the source S/N map before that floor (above a peak S/N of 200 the
floor lifts empty sky over S/N 2 and it is weighted as source). The raw map is already cached
(files/galaxy_images_snr.fits, _galaxy_image_dict_from_cache), but only private helpers
reach it. A workspace script today has to do what the science project's slam.py
unfloored_source_snr_from does by hand.

What to do

  • A public way to get the per-galaxy S/N maps before the floor (e.g. a
    galaxy_name_image_dict_via_result_from(result, minimum_percent=None) override, or a sibling
    function), reading the existing cache, negatives set to 0.
  • A one-call helper for SLaM / workspace scripts returning both what the mesh needs (the
    unfloored S/N map, for HilbertSNR.image_plane_mesh_grid_from) and the adapt-image dict whose
    source entry is adapt_image_soft_from of it (for AdaptImages → AdaptSplit). Other
    galaxies' entries keep the floored map.
  • Backward compatibility: the existing function's default output is unchanged, so every
    current AdaptSplit fit is unchanged.
  • Tests; and check the science project's slam.py unified arm can be rewritten onto these
    calls with the same mesh and adapt image (0.0 difference on a test-mode lens).

Reference: ~/Science/Science/development/adapt_snr_cap/scripts/slam.py
(unfloored_source_snr_from, galaxy_name_image_dict_from, source_pix_2).

Activity

  1. Jammy2211 commented on Nov 26, 2026

    @Jammy2211
    CollaboratorAuthor

    Library PRs Created

    API (settled with the human): galaxy_snr_maps_from, soft_snr_maps_from, AdaptImages.from_result, short galaxy keys ("source"); HilbertSNR(background=, peak=, edge_pixels=), edge_pixels= on Hilbert / Overlay, image_mesh.soft_snr_map_from. Existing calls unchanged.

    Gates: PyAutoArray 2625 passed, PyAutoGalaxy 1692 passed; test-mode SLaM fit with AdaptImages.from_result equals the science project's reference mesh and AdaptSplit map (0.0).

    Heart: the scoped dev gate (--repos PyAutoArray,PyAutoGalaxy) was GREEN at PR-open, so the development-only RED override the human authorized above was not exercised. Shown non-blocking reasons are in the PR bodies.

    Next: phase 3 (workspaces + the al. export of the two functions) after both PRs merge; PyAutoLens was claimed by cluster-family-fit-figures.

  2. Jammy2211 commented on Nov 26, 2026

    @Jammy2211
    CollaboratorAuthor

    PyAutoLens: PyAutoLabs/PyAutoLens#897 adds the al.galaxy_snr_maps_from / al.soft_snr_maps_from exports (PyAutoLens was freed). PyAutoArray#718 also gained the HilbertSNR 8-point-per-pixel cap and the frame-independent interpolation (on for HilbertSNR, opt-in for Hilbert). Merge order: PyAutoArray#718, then #763 (rerun its CI first), then PyAutoLens#897.

  3. Jammy2211 commented on Nov 26, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped

    All pending-release. A pipeline stage is now HilbertSNR(pixels=..., edge_pixels=30) + AdaptImages.from_result(result=..., image_mesh={"source": image_mesh}); HilbertSNR caps points per image pixel at 8 and interpolates frame-independently (opt-in for Hilbert, which is otherwise unchanged; AdaptSplit unchanged). #718 also fixes Mind draft/bug/autoarray/hilbert_image_mesh_frame_independent.md.

    Next: phase 3, the workspaces switch to the new default (Mind draft/feature/autolens_workspace/adapt_mesh_weighting_workspace_default.md).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions