Skip to content

Commit c2c4e11

Browse files
authored
Merge pull request #221 from Jammy2211/feature/odd_size_fft_fix
perform fix by not linking state blurring grid to dataset grid
2 parents 7844633 + df1f2d5 commit c2c4e11

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

autoarray/dataset/grids.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,13 @@ def blurring(self):
9999
if self.psf is None:
100100
self._blurring = None
101101
else:
102+
103+
blurring_mask = self.mask.derive_mask.blurring_from(
104+
kernel_shape_native=self.psf.kernel.shape_native
105+
)
106+
102107
self._blurring = Grid2D.from_mask(
103-
mask=self.psf._state.blurring_mask,
108+
mask=blurring_mask,
104109
over_sample_size=1,
105110
)
106111

autoarray/operators/convolver.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
import warnings
1313

1414
from autoconf import conf
15-
from autoconf.fitsable import header_obj_from
16-
17-
from autoarray.structures.arrays.uniform_2d import AbstractArray2D
1815
from autoarray.structures.arrays.uniform_2d import Array2D
1916
from autoarray.structures.grids.uniform_2d import Grid2D
2017
from autoarray.structures.header import Header
@@ -123,10 +120,6 @@ class determines how masked real-space data are embedded into a padded array,
123120
)
124121
fft_shape = tuple(scipy.fft.next_fast_len(s, real=True) for s in full_shape)
125122

126-
# make fft_shape odd x odd to avoid wrap-around artefacts with even kernels
127-
# TODO : Fix this so it pads corrrectly internally
128-
fft_shape = tuple(s + 1 if s % 2 == 0 else s for s in fft_shape)
129-
130123
self.fft_shape = fft_shape
131124
self.mask = mask.resized_from(self.fft_shape, pad_value=1)
132125
self.blurring_mask = self.mask.derive_mask.blurring_from(
@@ -248,11 +241,16 @@ def use_fft(self):
248241
return self._use_fft
249242

250243
@property
251-
def normalized(self) -> "Kernel2D":
244+
def normalized(self) -> "Convolver":
252245
"""
253-
Normalize the Kernel2D such that its data_vector values sum to unity.
246+
Normalize the Convolver such that its data_vector values sum to unity.
247+
248+
A copy of the kernel is used to avoid mutating the original kernel instance,
249+
and no existing state is reused so that any cached FFTs are recomputed for
250+
the normalized kernel.
254251
"""
255-
return Convolver(kernel=self.kernel, state=self._state, normalize=True)
252+
kernel_copy = self.kernel.copy()
253+
return Convolver(kernel=kernel_copy, state=None, normalize=True)
256254

257255
@classmethod
258256
def no_blur(cls, pixel_scales):

autoarray/plot/wrap/two_d/delaunay_drawer.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,9 @@ def draw_delaunay_pixels(
6262
"""
6363

6464
if pixel_values is None:
65-
raise ValueError(
66-
"pixel_values input to DelaunayPlotter are None and thus cannot be plotted."
67-
)
65+
pixel_values = np.zeros(shape=mapper.source_plane_mesh_grid.shape[0])
6866

69-
if pixel_values is not None:
70-
pixel_values = np.asarray(pixel_values)
67+
pixel_values = np.asarray(pixel_values)
7168

7269
if ax is None:
7370
ax = plt.gca()

0 commit comments

Comments
 (0)