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..bd6995a90 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,11 +241,16 @@ 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. + + 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): 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()