Skip to content

Feature/unconvolved images#386

Merged
Jammy2211 merged 10 commits intomainfrom
feature/unconvolved_images
Feb 9, 2026
Merged

Feature/unconvolved images#386
Jammy2211 merged 10 commits intomainfrom
feature/unconvolved_images

Conversation

@Jammy2211
Copy link
Owner

This pull request makes it so that images which have not been operated on (e.g. before PSF convolution) can be computed and extracted easily from inversions, with the end goal making it so that these images can be easily output to .fits files during autolens lens modling.

This pull request refactors the terminology and internal logic related to reconstructed data in the inversion modules, aiming for clearer distinctions between operated (PSF-convolved) and unoperated (unconvolved) data. The changes update property and variable names, unify implementation patterns, and improve documentation. No core algorithms are changed, but naming is clarified throughout the codebase to avoid confusion between different forms of reconstructed data.

Key changes include:

Core Functionality: Galaxy Image Handling

  • Added a new galaxy_image_dict property to FitImaging and FitInterferometer, which provides galaxy images before any operation (e.g., without PSF convolution), and updated galaxy_model_image_dict to clarify its use for operated/model images. [1] [2] [3]
  • Updated the methods for combining reconstructed data to use mapped_reconstructed_operated_data for model data and use_operated flags for correct image types in both imaging and interferometer fits. [1] [2] [3] [4] [5]

Plotting and Output

  • Changed plotter methods to use reconstructed_operated_data instead of reconstructed_image, ensuring outputs match the intended data form. [1] [2] [3] [4]

Configuration Updates

  • Split the configuration options for outputting galaxy images in plots.yaml into fits_galaxy_images (without PSF convolution) and fits_model_galaxy_images (with PSF convolution), and updated relevant test configs for clarity and consistency. [1] [2]
  • Added a new use_border_relocator option to the inversion configuration, allowing control over pixel relocation behavior.
  • Changed the default for fits_are_zoomed in the main config to false to avoid zooming FITS outputs by default.

Testing and Validation

  • Updated and expanded tests to cover the new galaxy_image_dict property, and adjusted expected values in several tests to reflect the improved logic and new default settings. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]

These changes collectively improve clarity, flexibility, and correctness in how galaxy images are handled, output, and tested throughout the codebase.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors inversion “reconstructed data” terminology to clearly separate operated (e.g., PSF-convolved / transformed) vs unoperated (pre-operation) outputs, and introduces explicit accessors/config for exporting unconvolved galaxy images for FITS output workflows.

Changes:

  • Add / update fit-level galaxy image dictionary accessors to distinguish unoperated galaxy images from model/operated images.
  • Rename and propagate reconstructed-data accessors in fits and plotters (e.g., mapped_reconstructed_operated_data, reconstructed_operated_data).
  • Update visualize configuration and adjust/extend tests to reflect the new naming and defaults.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
test_autolens/lens/test_to_inversion.py Updates test to new inversion reconstructed-data accessor name.
test_autolens/interferometer/test_fit_interferometer.py Updates expected values; still references old galaxy image dict property name.
test_autolens/imaging/test_simulate_and_fit_imaging.py Passes new inversion settings option and updates expected likelihood/reconstruction assertions.
test_autolens/imaging/test_fit_imaging.py Adds new galaxy_image_dict test and updates expected values.
test_autolens/config/visualize.yaml Updates test visualization config to include new FITS galaxy image options.
test_autolens/config/general.yaml Adds use_border_relocator to inversion config in test configuration.
test_autolens/analysis/test_result.py Updates expected source-plane centre value.
test_autolens/analysis/test_analysis.py Updates expected grid values for border relocator test.
autolens/interferometer/plot/fit_interferometer_plotters.py Switches plotting calls to reconstructed_operated_data.
autolens/interferometer/fit_interferometer.py Switches model data to operated reconstructed data; introduces galaxy_image_dict property.
autolens/imaging/plot/fit_imaging_plotters.py Switches pixelization plotting to reconstructed_operated_data.
autolens/imaging/fit_imaging.py Uses operated reconstructed data in model_data; adds galaxy_image_dict; updates linear-object dict flag naming.
autolens/config/visualize/plots.yaml Splits FITS galaxy-image outputs and changes default fits_are_zoomed to false.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

-0.14416215690290285, 1.0e-4
)

# Normal light + Linear Light PRofiles + Pixelization + Regularizaiton
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: Regularizaiton should be Regularization.

Suggested change
# Normal light + Linear Light PRofiles + Pixelization + Regularizaiton
# Normal light + Linear Light PRofiles + Pixelization + Regularization

Copilot uses AI. Check for mistakes.
Comment on lines 162 to 166
@property
def galaxy_model_image_dict(self) -> Dict[ag.Galaxy, np.ndarray]:
def galaxy_image_dict(self) -> Dict[ag.Galaxy, np.ndarray]:
"""
A dictionary which associates every galaxy in the tracer with its `image`.

Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FitInterferometer defines galaxy_image_dict but the previous galaxy_model_image_dict property appears to have been removed. The test suite (e.g. test_fit_interferometer.py::test___galaxy_model_image_dict) still references galaxy_model_image_dict, and this is also likely part of the public API. Please either reintroduce galaxy_model_image_dict (e.g. as an alias to galaxy_image_dict for backwards compatibility) or update all call sites/tests and document the breaking change.

Copilot uses AI. Check for mistakes.
Comment on lines 208 to 212
assert (fit.galaxy_model_image_dict[g0_no_light].native == np.zeros((7, 7))).all()

assert fit.galaxy_model_image_dict[galaxy_pix_0][0] == pytest.approx(
-0.15950206, 1.0e-4
-0.14416215690290285, 1.0e-4
)
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test still calls fit.galaxy_model_image_dict, but FitInterferometer now exposes galaxy_image_dict (and no longer defines galaxy_model_image_dict). Update the test to use the correct property (or re-add a backwards-compatible alias in FitInterferometer).

Copilot uses AI. Check for mistakes.
Comment on lines 121 to +124

grid = fit.inversion.linear_obj_list[0].source_plane_data_grid.over_sampled

assert grid[2] == pytest.approx([-82.89544515, 52.7491249], 1.0e-4)
assert grid[2] == pytest.approx([-82.991148773, 52.81254921], 1.0e-4)
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both assertions in this test currently expect (effectively) the same grid[2] value for use_border_relocator=False and use_border_relocator=True, so the test no longer verifies that the flag changes behavior. Consider asserting that the two grids differ (or checking a specific relocation effect) so the setting is actually exercised.

Copilot uses AI. Check for mistakes.
)
assert (fit.galaxy_image_dict[g2] == np.zeros(9)).all()

# Normal light + Linear Light PRofiles + Pixelization + Regularizaiton
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: PRofiles should be Profiles.

Suggested change
# Normal light + Linear Light PRofiles + Pixelization + Regularizaiton
# Normal light + Linear Light Profiles + Pixelization + Regularizaiton

Copilot uses AI. Check for mistakes.
)
assert (fit.galaxy_image_dict[g2] == np.zeros(9)).all()

# Normal light + Linear Light PRofiles + Pixelization + Regularizaiton
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: Regularizaiton should be Regularization.

Suggested change
# Normal light + Linear Light PRofiles + Pixelization + Regularizaiton
# Normal light + Linear Light PRofiles + Pixelization + Regularization

Copilot uses AI. Check for mistakes.
-0.14416215690290285, 1.0e-4
)

# Normal light + Linear Light PRofiles + Pixelization + Regularizaiton
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: PRofiles should be Profiles.

Suggested change
# Normal light + Linear Light PRofiles + Pixelization + Regularizaiton
# Normal light + Linear Light Profiles + Pixelization + Regularizaiton

Copilot uses AI. Check for mistakes.
@Jammy2211 Jammy2211 merged commit 983af2b into main Feb 9, 2026
0 of 8 checks passed
@Jammy2211 Jammy2211 deleted the feature/unconvolved_images branch February 13, 2026 13:43
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

Comments