Conversation
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Typo in comment: Regularizaiton should be Regularization.
| # Normal light + Linear Light PRofiles + Pixelization + Regularizaiton | |
| # Normal light + Linear Light PRofiles + Pixelization + Regularization |
| @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`. | ||
|
|
There was a problem hiding this comment.
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.
| 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 | ||
| ) |
There was a problem hiding this comment.
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).
|
|
||
| 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) |
There was a problem hiding this comment.
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.
| ) | ||
| assert (fit.galaxy_image_dict[g2] == np.zeros(9)).all() | ||
|
|
||
| # Normal light + Linear Light PRofiles + Pixelization + Regularizaiton |
There was a problem hiding this comment.
Typo in comment: PRofiles should be Profiles.
| # Normal light + Linear Light PRofiles + Pixelization + Regularizaiton | |
| # Normal light + Linear Light Profiles + Pixelization + Regularizaiton |
| ) | ||
| assert (fit.galaxy_image_dict[g2] == np.zeros(9)).all() | ||
|
|
||
| # Normal light + Linear Light PRofiles + Pixelization + Regularizaiton |
There was a problem hiding this comment.
Typo in comment: Regularizaiton should be Regularization.
| # Normal light + Linear Light PRofiles + Pixelization + Regularizaiton | |
| # Normal light + Linear Light PRofiles + Pixelization + Regularization |
| -0.14416215690290285, 1.0e-4 | ||
| ) | ||
|
|
||
| # Normal light + Linear Light PRofiles + Pixelization + Regularizaiton |
There was a problem hiding this comment.
Typo in comment: PRofiles should be Profiles.
| # Normal light + Linear Light PRofiles + Pixelization + Regularizaiton | |
| # Normal light + Linear Light Profiles + Pixelization + Regularizaiton |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…utoLens into feature/unconvolved_images
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
galaxy_image_dictproperty toFitImagingandFitInterferometer, which provides galaxy images before any operation (e.g., without PSF convolution), and updatedgalaxy_model_image_dictto clarify its use for operated/model images. [1] [2] [3]mapped_reconstructed_operated_datafor model data anduse_operatedflags for correct image types in both imaging and interferometer fits. [1] [2] [3] [4] [5]Plotting and Output
reconstructed_operated_datainstead ofreconstructed_image, ensuring outputs match the intended data form. [1] [2] [3] [4]Configuration Updates
plots.yamlintofits_galaxy_images(without PSF convolution) andfits_model_galaxy_images(with PSF convolution), and updated relevant test configs for clarity and consistency. [1] [2]use_border_relocatoroption to the inversion configuration, allowing control over pixel relocation behavior.fits_are_zoomedin the main config tofalseto avoid zooming FITS outputs by default.Testing and Validation
galaxy_image_dictproperty, 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.