Skip to content

feat: persist the interferometer primary beam through analysis save and aggregator rebuild - #655

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/interferometer-primary-beam-persistence
Oct 21, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/interferometer-primary-beam-persistence

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Closes #654. Follow-up of PyAutoLabs/PyAutoArray#644 (primary beam; hub PyAutoLabs/.github#35, @HRSAstro).

Summary

The interferometer primary beam was saved nowhere by AnalysisInterferometer.save_attributes, so an aggregator-rebuilt Interferometer / FitInterferometer lost it and the likelihood changed. interferometer_hdu_list_from now appends the beam (float64 native array, masked pixels 0) as a trailing PRIMARY_BEAM HDU in both the in-memory and array-free layouts (after any fine-grid HDUs; legacy positions 0-3 unchanged; a beamless dataset writes exactly the same file as before). The aggregator's _interferometer_from detects it by name only (_has_hdu, never positional) and passes primary_beam= into both from_sparse_terms and aa.Interferometer, so InterferometerAgg and FitInterferometerAgg reproduce the beamed likelihood.

PyAutoLens reuses both functions and needs no source change; its docstring line and mirror test are deferred to a follow-up (checkout claimed by another task).

API Changes

None — internal changes only (one new optional HDU in dataset.fits; old outputs without it still load with primary_beam=None).

Test Plan

test_autogalaxy/interferometer/model/test_analysis_interferometer.py, five new tests with a Gaussian beam (FWHM 2.2") on interferometer_7 spanning 1 → ~0.32:

  • in-memory beamed round trip: PRIMARY_BEAM last; primary_beam_slim and transformer.primary_beam_slim identical; log_likelihood rel 1e-10 for light-profile and pixelization galaxies, differing from the beamless value;
  • array-free beamed round trip via from_stream(primary_beam=): sparse_operator.primary_beam_slim identical; log_evidence rel 1e-10 and differs from beamless; figure_of_merit equal;
  • beamless both layouts: no extra HDU, count pinned at 4, reload primary_beam is None;
  • old outputs (HDU removed; legacy file with EXTNAMEs stripped) reload with primary_beam=None;
  • control: forcing _primary_beam_from to None makes the round-trip tests fail.
    Worktree runs: pytest test_autogalaxy/interferometer -q → 82 passed; pytest test_autogalaxy -q → 1362 passed.

Heart YELLOW acknowledged by the human on 2026-10-21 (manifest drift 1 mismatch; release validation stale: source moved since rehearsal (PyAutoArray)).

Full API Changes (for automation & release notes)

Changed Behaviour

  • autogalaxy.interferometer.model.analysis.interferometer_hdu_list_from — appends an optional trailing PRIMARY_BEAM HDU when the dataset carries a primary beam.
  • autogalaxy.aggregator.interferometer._interferometer_from — reloads primary_beam when the HDU is present.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

… and aggregator rebuild

interferometer_hdu_list_from appends the primary beam (native float64, masked
pixels 0) as a trailing PRIMARY_BEAM HDU in both the in-memory and array-free
layouts, so legacy positional indices are unchanged and beamless datasets write
the same file as before. The aggregator detects the HDU by name and passes
primary_beam= into Interferometer / from_sparse_terms, so a rebuilt dataset and
fit reproduce the beamed likelihood. Old outputs without the HDU reload with
primary_beam=None.

Refs #654

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Jammy2211
Jammy2211 merged commit e00b5e7 into main Oct 21, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/interferometer-primary-beam-persistence branch October 21, 2026 12:09
@Jammy2211 Jammy2211 added pending-release PR queued for the next release build and removed pending-release PR queued for the next release build labels Oct 21, 2026
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.

feat: persist the interferometer primary beam through analysis save and aggregator rebuild

1 participant