Skip to content

feat: persist SparseTerms oversample fine grids in dataset.fits (opt-in) - #650

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/sparse-terms-oversampled-fine-grids
Oct 7, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/sparse-terms-oversampled-fine-grids

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Depends on PyAutoLabs/PyAutoArray#621 (merge that first). It adds the SparseTerms fine-grid fields this PR persists.

This PR adds FITS persistence for the oversample=q fine grids of array-free interferometer datasets, requested by @HRSAstro in Discussion #13 (comment item 1); tracking issue PyAutoLabs/PyAutoArray#620.

interferometer_hdu_list_from(dataset, include_fine_grids=False) writes the fine grids as HDUs PRECISION_OPERATOR_FINE and DIRTY_IMAGE_FINE, after SPARSE_TERMS_SCALARS. It does so only when the terms carry them and include_fine_grids=True. Alongside them it writes oversample / oversample_pad, appended to SPARSE_TERMS_SCALARS_ORDER (append-only, NaN = unrecorded), and header cards OVERSAMP / OVERSPAD.

Why off by default: dataset.fits is written into every search's output by save_attributes, and the grids grow as q². At 400 px and q=8 that is ~840 MB per search output. save_attributes therefore keeps the default, and a default write is identical to that of terms without fine grids (oversampling scalars NaN).

The aggregator loader reads the HDUs via the existing _has_hdu pattern. A file without them (default writes, or files written before this change) reloads all four fields as None, so a reloaded SparseTerms never claims an oversample without its grids.

API Changes

Additive only.

  • autogalaxy.interferometer.model.analysis.interferometer_hdu_list_from(dataset, include_fine_grids=False) gains a new keyword.
  • SPARSE_TERMS_SCALARS_ORDER gets oversample and oversample_pad appended, and SPARSE_TERMS_HEADER_KEYS gets OVERSAMP and OVERSPAD. The SPARSE_TERMS_SCALARS HDU now has 9 entries; readers of the first 7 are unaffected.
    See full details below.

Test Plan

  • Fine grids are written only when opted in; default writes keep the old HDU layout with NaN oversampling scalars and no OVERSAMP card; opting in on terms without fine grids writes nothing extra.
  • Disk round trip (writeto / fits.open) of both fine grids, oversample (as int) and oversample_pad. Reloaded terms still refuse to sum with a different q, and a default-written file reloads with None.
  • A file predating the fine grids (7-entry scalars, no HDUs/cards) reloads None for all four fields, with other terms intact.
  • Witness tests run red on unfixed source first (3 failed; the legacy-file guard passes before and after).
  • Full test_autogalaxy: 1357 passed (with PyAutoArray#621).
  • Smoke: autolens_workspace/scripts/interferometer/features/datacube/modeling_array_free.py passes.
Full API Changes (for automation & release notes)

Added

  • interferometer_hdu_list_from(dataset, include_fine_grids: bool = False) — opt-in writing of PRECISION_OPERATOR_FINE / DIRTY_IMAGE_FINE.
  • SPARSE_TERMS_SCALARS_ORDER += ("oversample", "oversample_pad"); SPARSE_TERMS_HEADER_KEYS["oversample"] = "OVERSAMP", ["oversample_pad"] = "OVERSPAD".
  • autogalaxy.aggregator.interferometer.interferometer._sparse_terms_from reloads the fine grids when present.

Migration

  • None.

Requested by @HRSAstro — https://github.com/orgs/PyAutoLabs/discussions/13 (https://github.com/orgs/PyAutoLabs/discussions/13#discussioncomment-18741903).

Tier: judge — merge mode: human /prm (after PyAutoArray#621). Heart readiness at ship: YELLOW (manifest drift: shared-standards blocks; release validation stale), acknowledged.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

`interferometer_hdu_list_from(dataset, include_fine_grids=False)` writes the
`oversample` fine grids of array-free terms as HDUs PRECISION_OPERATOR_FINE and
DIRTY_IMAGE_FINE, with `oversample` / `oversample_pad` appended to
SPARSE_TERMS_SCALARS_ORDER (append-only, NaN = unrecorded) and header cards
OVERSAMP / OVERSPAD, only when opted in: dataset.fits is written into every
search's output and the grids grow as q^2 (~840 MB at 400 px, q = 8), so
save_attributes keeps the default. The aggregator loader reads them via
_has_hdu; files without them (default writes, pre-change files) reload the four
fields as None.

Depends on PyAutoArray feature/sparse-terms-oversampled-fine-grids (SparseTerms
fine-grid fields). Refs PyAutoLabs/PyAutoArray#620

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Oct 7, 2026
@Jammy2211
Jammy2211 merged commit 0cee03f into main Oct 7, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/sparse-terms-oversampled-fine-grids branch October 7, 2026 10:55
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Oct 7, 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.

1 participant