Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autogalaxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from autoarray.structures.grids.uniform_2d import Grid2D # noqa
from autoarray.structures.grids.irregular_2d import Grid2DIrregular # noqa
from autoarray.operators.over_sampling.over_sampler import OverSampler # noqa
from autoarray.operators.convolver import Convolver
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

Convolver is imported for public re-export like the other autoarray symbols, but it’s missing the # noqa marker. Without it, linting (unused import) may fail; align with the surrounding imports by adding # noqa (or otherwise ensuring it’s referenced in this module).

Suggested change
from autoarray.operators.convolver import Convolver
from autoarray.operators.convolver import Convolver # noqa

Copilot uses AI. Check for mistakes.
from autoarray.inversion.mesh.interpolator.rectangular import (
InterpolatorRectangular,
) # noqa
Expand All @@ -48,7 +49,6 @@
from autoarray.structures.vectors.irregular import VectorYX2DIrregular # noqa
from autoarray.layout.region import Region1D # noqa
from autoarray.layout.region import Region2D # noqa
from autoarray.structures.arrays.kernel_2d import Kernel2D # noqa
from autoarray.structures.visibilities import Visibilities # noqa
from autoarray.structures.visibilities import VisibilitiesNoiseMap # noqa
from autoarray.inversion.mesh.mesh_geometry.rectangular import (
Expand Down
4 changes: 3 additions & 1 deletion autogalaxy/aggregator/imaging/imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ def values_from(hdu: int, cls):
noise_map = values_from(hdu=2, cls=aa.Array2D)

try:
psf = values_from(hdu=3, cls=aa.Kernel2D)
kernel = values_from(hdu=3, cls=aa.Array2D)
psf = aa.Convolver(kernel=kernel)
except (TypeError, IndexError):
kernel = None
psf = None

dataset = aa.Imaging(
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/galaxy/galaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def set_snr_of_snr_light_profiles(
grid: aa.type.Grid2DLike,
exposure_time: float,
background_sky_level: float = 0.0,
psf: Optional[aa.Kernel2D] = None,
psf: Optional[aa.Convolver] = None,
):
"""
Iterate over every galaxy finding all `LightProfileSNR` light profiles and set their `intensity` values to
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/galaxy/to_inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _xp(self):
return np

@property
def psf(self) -> Optional[aa.Kernel2D]:
def psf(self) -> Optional[aa.Convolver]:
"""
Returns the PSF of the imaging dataset, if the inversion is performed on an imaging dataset.

Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/imaging/model/plotter_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def should_plot(name):
image_list = [
dataset.data.native_for_fits,
dataset.noise_map.native_for_fits,
dataset.psf.native_for_fits,
dataset.psf.kernel.native_for_fits,
dataset.grids.lp.over_sample_size.native_for_fits.astype("float"),
dataset.grids.pixelization.over_sample_size.native_for_fits.astype(
"float"
Expand Down
4 changes: 2 additions & 2 deletions autogalaxy/imaging/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def via_galaxies_from(
)

image = galaxies.padded_image_2d_from(
grid=grid, psf_shape_2d=self.psf.shape_native
grid=grid, psf_shape_2d=self.psf.kernel.shape_native
)

over_sample_size = grid.over_sample_size.resized_from(
Expand All @@ -58,5 +58,5 @@ def via_galaxies_from(
dataset = self.via_image_from(image=image, over_sample_size=over_sample_size)

return dataset.trimmed_after_convolution_from(
kernel_shape=self.psf.shape_native
kernel_shape=self.psf.kernel.shape_native
)
12 changes: 6 additions & 6 deletions autogalaxy/operate/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _blurred_image_2d_from(
self,
image_2d: aa.Array2D,
blurring_image_2d: aa.Array2D,
psf: aa.Kernel2D,
psf: aa.Convolver,
xp=np,
) -> aa.Array2D:

Expand All @@ -46,7 +46,7 @@ def blurred_image_2d_from(
self,
grid: aa.Grid2D,
blurring_grid: aa.Grid2D,
psf: aa.Kernel2D = None,
psf: aa.Convolver = None,
xp=np,
) -> aa.Array2D:
"""
Expand Down Expand Up @@ -138,7 +138,7 @@ def unmasked_blurred_image_2d_from(self, grid, psf):
psf
The PSF the light object 2D image is convolved with.
"""
padded_grid = grid.padded_grid_from(kernel_shape_native=psf.shape_native)
padded_grid = grid.padded_grid_from(kernel_shape_native=psf.kernel.shape_native)

padded_image_2d_not_operated = self.image_2d_from(
grid=padded_grid, operated_only=False
Expand Down Expand Up @@ -216,7 +216,7 @@ def blurred_image_2d_list_from(
self,
grid: aa.Grid2D,
blurring_grid: aa.Grid2D,
psf: aa.Kernel2D = None,
psf: aa.Convolver,
) -> List[aa.Array2D]:
"""
Evaluate the light object's list of 2D images from a input 2D grid of coordinates and convolve each image with
Expand Down Expand Up @@ -267,7 +267,7 @@ def blurred_image_2d_list_from(
return blurred_image_2d_list

def unmasked_blurred_image_2d_list_from(
self, grid: aa.Grid2D, psf: aa.Kernel2D
self, grid: aa.Grid2D, psf: aa.Convolver
) -> List[aa.Array2D]:
"""
Evaluate the light object's list of 2D images from a input 2D grid of coordinates and convolve it with a PSF,
Expand All @@ -290,7 +290,7 @@ def unmasked_blurred_image_2d_list_from(
psf
The PSF the light object 2D image is convolved with.
"""
padded_grid = grid.padded_grid_from(kernel_shape_native=psf.shape_native)
padded_grid = grid.padded_grid_from(kernel_shape_native=psf.kernel.shape_native)

padded_image_2d_list = self.image_2d_list_from(grid=padded_grid)

Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/profiles/light/linear/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def __init__(
self,
grid: aa.type.Grid1D2DLike,
blurring_grid: aa.type.Grid1D2DLike,
psf: Optional[aa.Kernel2D],
psf: Optional[aa.Convolver],
light_profile_list: List[LightProfileLinear],
regularization=Optional[aa.reg.Regularization],
settings=aa.Settings(),
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/profiles/light/snr/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def set_intensity_from(
grid: aa.type.Grid2DLike,
exposure_time: float,
background_sky_level: float = 0.0,
psf: Optional[aa.Kernel2D] = None,
psf: Optional[aa.Convolver] = None,
):
"""
Set the `intensity` of the light profile as follows:
Expand Down
6 changes: 3 additions & 3 deletions test_autogalaxy/imaging/test_simulate_and_fit_imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test__perfect_fit__chi_squared_0():
over_sample_size=1,
)

psf = ag.Kernel2D.from_gaussian(
psf = ag.Convolver.from_gaussian(
shape_native=(3, 3), pixel_scales=0.2, sigma=0.75, normalize=True
)

Expand Down Expand Up @@ -86,7 +86,7 @@ def test__perfect_fit__chi_squared_0():
def test__simulate_imaging_data_and_fit__known_likelihood():
grid = ag.Grid2D.uniform(shape_native=(31, 31), pixel_scales=0.2)

psf = ag.Kernel2D.from_gaussian(
psf = ag.Convolver.from_gaussian(
shape_native=(3, 3), pixel_scales=0.2, sigma=0.75, normalize=True
)

Expand Down Expand Up @@ -144,7 +144,7 @@ def test__simulate_imaging_data_and_fit__linear_light_profiles_agree_with_standa
over_sample_size=1,
)

psf = ag.Kernel2D.from_gaussian(
psf = ag.Convolver.from_gaussian(
shape_native=(3, 3), pixel_scales=0.2, sigma=0.75, normalize=True
)

Expand Down
11 changes: 6 additions & 5 deletions test_autogalaxy/imaging/test_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test__from_fits__all_imaging_data_structures_are_flipped_for_ds9():

assert (dataset.data.native == np.array([[0.0, 0.0], [1.0, 0.0]])).all()
assert (dataset.noise_map.native == np.array([[1.0, 1.0], [2.0, 1.0]])).all()
assert dataset.psf.native == pytest.approx(
assert dataset.psf.kernel.native == pytest.approx(
np.array([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.5, 0.5, 0.0]]), 1.0e-4
)

Expand Down Expand Up @@ -83,7 +83,7 @@ def test__from_fits__all_imaging_data_structures_are_flipped_for_ds9():


def test__simulator__via_galaxies_from():
psf = ag.Kernel2D.from_gaussian(shape_native=(7, 7), sigma=0.5, pixel_scales=0.05)
psf = ag.Convolver.from_gaussian(shape_native=(7, 7), sigma=0.5, pixel_scales=0.05)

grid = ag.Grid2D.uniform(shape_native=(20, 20), pixel_scales=0.05)

Expand Down Expand Up @@ -112,7 +112,7 @@ def test__simulator__via_galaxies_from():
assert dataset.data.native[10, 10] == pytest.approx(
imaging_via_image.data.native[10, 10], 1.0e-4
)
assert dataset.psf == pytest.approx(imaging_via_image.psf, 1.0e-4)
assert dataset.psf.kernel == pytest.approx(imaging_via_image.psf.kernel, 1.0e-4)
assert dataset.noise_map == pytest.approx(imaging_via_image.noise_map, 1.0e-4)


Expand All @@ -137,7 +137,8 @@ def test__simulator__simulate_imaging_from_galaxy__source_galaxy__compare_to_ima

grid = ag.Grid2D.uniform(shape_native=(11, 11), pixel_scales=0.2)

psf = ag.Kernel2D.no_mask(values=[[1.0]], pixel_scales=0.2)
kernel = ag.Array2D.no_mask(values=[[1.0]], pixel_scales=0.2)
psf = ag.Convolver(kernel=kernel)

simulator = ag.SimulatorImaging(
psf=psf,
Expand All @@ -157,5 +158,5 @@ def test__simulator__simulate_imaging_from_galaxy__source_galaxy__compare_to_ima

assert dataset.shape_native == (11, 11)
assert dataset.data.array == pytest.approx(imaging_via_image.data.array, 1.0e-4)
assert (dataset.psf == imaging_via_image.psf).all()
assert (dataset.psf.kernel == imaging_via_image.psf.kernel).all()
assert dataset.noise_map == pytest.approx(imaging_via_image.noise_map, 1.0e-4)
14 changes: 9 additions & 5 deletions test_autogalaxy/operate/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,14 @@ def test__x1_galaxies__padded_image__compare_to_galaxy_images_using_padded_grid_


def test__unmasked_blurred_image_2d_from():
psf = ag.Kernel2D.no_mask(

kernel = ag.Array2D.no_mask(
values=(np.array([[0.0, 3.0, 0.0], [0.0, 1.0, 2.0], [0.0, 0.0, 0.0]])),
pixel_scales=1.0,
)

psf = ag.Convolver(kernel=kernel)

mask = ag.Mask2D(
mask=[[True, True, True], [True, False, True], [True, True, True]],
pixel_scales=1.0,
Expand All @@ -126,7 +129,7 @@ def test__unmasked_blurred_image_2d_from():
light_not_operated = ag.lp.Gaussian(intensity=1.0)
light_operated = ag.lp_operated.Gaussian(intensity=1.0)

padded_grid = grid.padded_grid_from(kernel_shape_native=psf.shape_native)
padded_grid = grid.padded_grid_from(kernel_shape_native=psf.kernel.shape_native)

image_2d_not_operated = light_not_operated.image_2d_from(grid=padded_grid)

Expand All @@ -138,7 +141,7 @@ def test__unmasked_blurred_image_2d_from():

image_2d_operated = padded_grid.mask.unmasked_blurred_array_from(
padded_array=image_2d_operated,
psf=ag.Kernel2D.no_blur(pixel_scales=1.0),
psf=ag.Convolver.no_blur(pixel_scales=1.0),
image_shape=grid.mask.shape,
)

Expand Down Expand Up @@ -239,10 +242,11 @@ def test__blurred_image_2d_list_from(


def test__unmasked_blurred_image_2d_list_from():
psf = ag.Kernel2D.no_mask(
kernel = ag.Array2D.no_mask(
values=(np.array([[0.0, 3.0, 0.0], [0.0, 1.0, 2.0], [0.0, 0.0, 0.0]])),
pixel_scales=1.0,
)
psf = ag.Convolver(kernel=kernel)

mask = ag.Mask2D(
mask=[[True, True, True], [True, False, True], [True, True, True]],
Expand All @@ -254,7 +258,7 @@ def test__unmasked_blurred_image_2d_list_from():
lp_0 = ag.lp.Sersic(intensity=1.0)
lp_1 = ag.lp.Sersic(intensity=2.0)

padded_grid = grid.padded_grid_from(kernel_shape_native=psf.shape_native)
padded_grid = grid.padded_grid_from(kernel_shape_native=psf.kernel.shape_native)

manual_blurred_image_0 = lp_0.image_2d_from(grid=padded_grid)
manual_blurred_image_0 = psf.convolved_image_from(
Expand Down
2 changes: 1 addition & 1 deletion test_autogalaxy/profiles/light/test_snr.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test__signal_to_noise_via_simulator_correct():

assert 8.0 < dataset.signal_to_noise_max < 11.5

psf = ag.Kernel2D.from_gaussian(
psf = ag.Convolver.from_gaussian(
shape_native=(3, 3), sigma=2.0, pixel_scales=0.2, normalize=True
)

Expand Down
Loading