Skip to content

fix: AggregateFITS resolves FITS sources through result.fits, not value() - #1633

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/catalogue-mass-maps-fits
Sep 16, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/catalogue-mass-maps-fits

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

af.AggregateFITS could not read a FITS output whose name is shared with a JSON output. AggregateFITS._hdus resolved the source file with SearchOutput.value(name), and value searches jsons before fits. Every PyAutoLens fit writes both files/tracer.json (the max-log-likelihood Tracer) and image/tracer.fits, so extract_fits(hdus=[al.agg.fits_tracer.convergence]) received the Tracer object and died:

File "autofit/aggregator/summary/aggregate_fits.py", line 74, in _hdus
    source_hdu = source[source.index_of(hdu.value)]
AttributeError: 'Tracer' object has no attribute 'index_of'

Found while collecting per-lens convergence/potential/deflections maps for the Euclid DR1 catalogue (euclid_strong_lens_modeling_pipeline#80, PR #81), where the producer had to carry a stand-in copy of the extraction loop. This PR fixes the resolution in PyAutoFit so that stand-in is deleted.

Fix. New module-level fits_source(result, name) in autofit/aggregator/summary/aggregate_fits.py looks the FITS output up by name in result.fits, where FITS files are unambiguously FITS files, and raises FileNotFoundError when none exists. _hdus and extract_csv use it. SearchOutput.value keeps its JSON-first order; nothing else changes.

API Changes

None for callers. AggregateFITS.extract_fits / extract_csv / output_to_folder keep their signatures and return types; a missing FITS output now raises FileNotFoundError instead of an AttributeError on None. One new public helper, autofit.aggregator.summary.aggregate_fits.fits_source.
See full details below.

Test Plan

  • test_json_does_not_shadow_fits: copy of the aggregate_summary fixture with a files/fit.json beside each image/fit.fits; red on main (AttributeError: 'dict' object has no attribute 'index_of'), green here
  • test_fits_source_missing: FileNotFoundError for an unknown name
  • pytest test_autofit/aggregator -q: 85 passed; summary_files: 36 passed; test_autofit/database/test_file_types.py: 7 passed
  • Real-data witness in the pipeline worktree: the DR1 dr1_sep1 mass maps produced through af.AggregateFITS on this branch are byte-identical to the stand-in's output (27 files), 18 result zips untouched
  • Full PyAutoFit CI green
Full API Changes (for automation & release notes)

Added

  • autofit.aggregator.summary.aggregate_fits.fits_source(result, name) — the opened HDUList of the FITS output called name for one SearchOutput, resolved through result.fits; raises FileNotFoundError when absent.

Changed

  • AggregateFITS._hdus and AggregateFITS.extract_csv resolve their source file via fits_source instead of SearchOutput.value. Behaviour is identical when no same-named JSON exists; when one does, the FITS file is now read rather than the JSON object.

Migration

  • None.

Downstream: euclid_strong_lens_modeling_pipeline PR #81 (branch of the same name) drops its AggregateTracerFITS stand-in and depends on this fix; library-first merge.

Heart was RED at ship time for reasons unrelated to this change (TestPyPI install verification; release-validation integrate stage); PR opened on the human's acknowledgement.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

…ue()

SearchOutput.value searches JSON outputs before FITS outputs. A search that
writes both files/<name>.json and image/<name>.fits (every PyAutoLens fit
writes files/tracer.json beside image/tracer.fits) therefore made
AggregateFITS._hdus receive the JSON object and fail with
"'Tracer' object has no attribute 'index_of'", so al.agg.fits_tracer was
unusable through AggregateFITS. Found while collecting per-lens mass maps for
the Euclid DR1 catalogue (euclid_strong_lens_modeling_pipeline#80).

New module-level fits_source(result, name) looks the FITS output up by name
in result.fits and raises FileNotFoundError when absent; _hdus and
extract_csv use it. SearchOutput.value keeps its JSON-first order.

Regression test copies the aggregate_summary fixture, drops a files/fit.json
beside image/fit.fits and asserts extraction still returns the HDUs (red on
main: AttributeError 'dict' object has no attribute 'index_of').

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Workspace PR: PyAutoLabs/euclid_strong_lens_modeling_pipeline#81 — drops its AggregateTracerFITS stand-in on this fix; library-first merge (this PR first).

@Jammy2211
Jammy2211 merged commit db08723 into main Sep 16, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/catalogue-mass-maps-fits branch September 16, 2026 23:05
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 26, 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