Skip to content

fix: restore unconditional dataset.fits output for aggregator (save_attributes) #478

Description

@Jammy2211

Summary

The aggregator result guides (guides/results/aggregator/models.py) fail in both autogalaxy_workspace and autolens_workspace with:

PyAutoGalaxy/autogalaxy/aggregator/agg_util.py:101
  header = aa.Header(header_sci_obj=fit.value(name=name)[0].header)
TypeError: 'NoneType' object is not subscriptable

Surfaced by the 2026-07-08 full workspace-validation sweep (5 failed / 613 passed).

Root cause

fit.value(name="dataset") returns None: the fit no longer persists the dataset.fits the aggregator loaders require.

Pre-overhaul, AnalysisDataset.save_attributes wrote dataset.fits to the files/ folder unconditionally (before every fit). The "Visualization overhaul: fits API" commit (081bbd84, via 825544bf "move save attributes stuff to plotter interface") removed that write and left only the plotter-interface copy in image/, which is gated on the fits_dataset visualization setting. Any fit that does not emit that visualization output (test-mode / minimal searches / older runs) has no dataset.fits, so ImagingAgg / InterferometerAgg / agg_util.mask_header_from break.

fit.value scans both files/ and image/, so where visualization ran the file is found — the failure is on fits where it did not.

PyAutoLens's analysis never had a save_attributes producer at all (it relied entirely on the visualization copy), so the same gap affects autolens_workspace.

Fix (restore the producer; both libraries)

Re-add an unconditional paths.save_fits(name="dataset", ...) to save_attributes, honouring the documented HDU contract (mask/data/noise_map/psf/over_sample_size_* for imaging; mask/data/noise_map/uv_wavelengths for interferometer), using the current plotter accessors (.native_for_fits, .header_dict):

  • PyAutoGalaxy AnalysisImaging + AnalysisInterferometer.save_attributes
  • PyAutoLens AnalysisImaging (new override) + AnalysisInterferometer.save_attributes

No consumer-side None-guard (fix the producer). The plotter's image/dataset.fits write is unchanged.

Verification

  • autogalaxy and autolens guides/results/aggregator/models.py both run to completion (exit 0), TypeError gone.
  • New regression tests assert save_attributes writes files/dataset.fits with [MASK, DATA, NOISE_MAP, PSF].
  • Existing analysis suites pass (PyAutoGalaxy 5, PyAutoLens 10).

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