From 042d68681684db5a59fbc74ae1c71e01fa6ae929 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Wed, 25 Feb 2026 14:06:08 +0000 Subject: [PATCH 1/2] perform fix by not linking state blurring grid to dataset grid --- autoarray/dataset/grids.py | 7 ++++++- autoarray/operators/convolver.py | 11 ++--------- autoarray/plot/wrap/two_d/delaunay_drawer.py | 7 ++----- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/autoarray/dataset/grids.py b/autoarray/dataset/grids.py index b695ae1bf..4026d9b86 100644 --- a/autoarray/dataset/grids.py +++ b/autoarray/dataset/grids.py @@ -99,8 +99,13 @@ def blurring(self): if self.psf is None: self._blurring = None else: + + blurring_mask = self.mask.derive_mask.blurring_from( + kernel_shape_native=self.psf.kernel.shape_native + ) + self._blurring = Grid2D.from_mask( - mask=self.psf._state.blurring_mask, + mask=blurring_mask, over_sample_size=1, ) diff --git a/autoarray/operators/convolver.py b/autoarray/operators/convolver.py index de8665695..b81fa7730 100644 --- a/autoarray/operators/convolver.py +++ b/autoarray/operators/convolver.py @@ -12,9 +12,6 @@ import warnings from autoconf import conf -from autoconf.fitsable import header_obj_from - -from autoarray.structures.arrays.uniform_2d import AbstractArray2D from autoarray.structures.arrays.uniform_2d import Array2D from autoarray.structures.grids.uniform_2d import Grid2D from autoarray.structures.header import Header @@ -123,10 +120,6 @@ class determines how masked real-space data are embedded into a padded array, ) fft_shape = tuple(scipy.fft.next_fast_len(s, real=True) for s in full_shape) - # make fft_shape odd x odd to avoid wrap-around artefacts with even kernels - # TODO : Fix this so it pads corrrectly internally - fft_shape = tuple(s + 1 if s % 2 == 0 else s for s in fft_shape) - self.fft_shape = fft_shape self.mask = mask.resized_from(self.fft_shape, pad_value=1) self.blurring_mask = self.mask.derive_mask.blurring_from( @@ -248,9 +241,9 @@ def use_fft(self): return self._use_fft @property - def normalized(self) -> "Kernel2D": + def normalized(self) -> "Convolver": """ - Normalize the Kernel2D such that its data_vector values sum to unity. + Normalize the Convolver such that its data_vector values sum to unity. """ return Convolver(kernel=self.kernel, state=self._state, normalize=True) diff --git a/autoarray/plot/wrap/two_d/delaunay_drawer.py b/autoarray/plot/wrap/two_d/delaunay_drawer.py index 99f434119..915f5d660 100644 --- a/autoarray/plot/wrap/two_d/delaunay_drawer.py +++ b/autoarray/plot/wrap/two_d/delaunay_drawer.py @@ -62,12 +62,9 @@ def draw_delaunay_pixels( """ if pixel_values is None: - raise ValueError( - "pixel_values input to DelaunayPlotter are None and thus cannot be plotted." - ) + pixel_values = np.zeros(shape=mapper.source_plane_mesh_grid.shape[0]) - if pixel_values is not None: - pixel_values = np.asarray(pixel_values) + pixel_values = np.asarray(pixel_values) if ax is None: ax = plt.gca() From df1f2d501c3252331664894f0c389ddc17ee91ed Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Wed, 25 Feb 2026 14:29:52 +0000 Subject: [PATCH 2/2] Update autoarray/operators/convolver.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- autoarray/operators/convolver.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/autoarray/operators/convolver.py b/autoarray/operators/convolver.py index b81fa7730..bd6995a90 100644 --- a/autoarray/operators/convolver.py +++ b/autoarray/operators/convolver.py @@ -244,8 +244,13 @@ def use_fft(self): def normalized(self) -> "Convolver": """ Normalize the Convolver such that its data_vector values sum to unity. + + A copy of the kernel is used to avoid mutating the original kernel instance, + and no existing state is reused so that any cached FFTs are recomputed for + the normalized kernel. """ - return Convolver(kernel=self.kernel, state=self._state, normalize=True) + kernel_copy = self.kernel.copy() + return Convolver(kernel=kernel_copy, state=None, normalize=True) @classmethod def no_blur(cls, pixel_scales):