Skip to content

Add side-by-side map and cutout grid to --compare-residuals - #95

Open
Athanaseus wants to merge 2 commits into
res-plotfrom
res-cutouts
Open

Athanaseus wants to merge 2 commits into
res-plotfrom
res-cutouts

Conversation

@Athanaseus

Copy link
Copy Markdown
Owner

Numbers alone can't show what changed between two images or where. --compare-residuals now also writes SourceResidualCutouts.html (with -catalog) or RandomResidualCutouts.html (without): a side-by-side map, then a grid of the 18 biggest changes as stamp pairs. The existing noise-ratio plot is unchanged. Image-agnostic: two self-cal rounds, DI vs DD, anything on the same pixel grid.

Side-by-side map

preview_map
  • Both images downsampled for display, each marking in red only where it is deeper than the other image — marking every negative puts the same clumps on both panels, since negatives cluster around the same bright sources.
  • Marks come from block minima, not means, so downsampling cannot erase a hole.
  • One threshold for both, 5× the noisier image's MAD noise, so the cleaner image can't pick a threshold that flatters it. Each title gives that image's pixel count below it: here 36,405 vs 58,066.
  • The 18 grid positions are circled and labelled; hover gives the values; zooming one panel zooms the other.

Cutout grid — with a catalogue

preview_grid
  • Full-resolution 64×64 stamps (never downsampled: a negative bowl is a few beams across), image 1 and 2 touching, one colour scale per pair.
  • Picks the sources whose deepest negative changed most, in either direction, so image order doesn't matter — swapping the images picks the same sources and flips which one is reported worse. Overlapping stamps are skipped, so a close pair doesn't show the same bowl twice.
  • Here: SRC1523 is the over-subtracted peeled source; SRC739 nearly vanishes; most others show new ripple structure in image 2.
  • --reference-position adds one extra pair at that position, on its own row above the grid (top row here).

Cutout grid — without a catalogue

preview_nocat_grid
  • The 18 biggest pixel changes anywhere (image 2 − image 1), either direction. This answers "where did the sky change most" rather than "where did new artefacts appear", because a few mJy of flux change outranks a sub-mJy ripple.
  • Here the top entries are the bright sources the DD run peeled (its output is named brighptsrc5). Bright sources saturate on the negative-driven colour scale, so the size of each drop is in the title.

Options

  • -cr: everything in one tabbed ResidualReport.html (Noise ratio · Cutouts). -cr previously covered only catalogue comparisons.
  • -svg: also writes the map (…_map.svg) and grid (….svg) through matplotlib, which is optional; a warning if it's missing.
  • --reference-position is checked before any work: a position off either image or on blanked pixels raises immediately, as it already does for dynamic range. That check is now one shared helper.

Also fixed

  • The CLI never passed -svg or -cr to --compare-residuals.
  • Once -svg reached it, bokeh's SVG export of the noise-ratio plot aborted the run on machines without a browser driver. It now warns and continues; the matplotlib SVGs need no browser.
  • --reference-position help didn't mention that sexagesimal is accepted.

Notes

  • Both images must share a pixel grid (size, projection, reference pixel, pixel scale). If they don't, the cutouts are skipped with a warning and the rest of the run goes ahead.
  • Per-source rows gain ra_deg and dec_deg, appended at the end, so stamps don't rely on catalogue names being unique.
  • On two 6075² images: ~30 s, ~800 MB peak memory, ~6.5 MB HTML (mostly the two map images).

Numbers alone could not show what changed or where. --compare-residuals now also
writes <kind>ResidualCutouts.html: both images side by side, each marking only
where it is deeper than the other (block minima, so downsampling cannot erase a
hole), and the 18 biggest changes as touching stamp pairs. With -catalog these
are the sources whose deepest negative changed most; without, the biggest pixel
changes anywhere. Ranked by size of change either way, so image order does not
matter. Needs both images on one pixel grid, otherwise skipped with a warning.

--reference-position adds a stamp pair at that spot. -cr combines everything into
ResidualReport.html. -svg writes the map and grid via matplotlib.

The CLI never passed -svg or -cr to --compare-residuals. Passing -svg exposed
bokeh's SVG export, which aborts without a browser driver; it now warns and
continues. Rows carry ra_deg/dec_deg, and the off-image check is shared with
image_dynamic_range.
@Athanaseus
Athanaseus added this pull request to stack #92 September 15, 2026 19:24

This branch has not been deployed

No deployments
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