Skip to content

Commit 2bb3a6a

Browse files
Jammy2211claude
authored andcommitted
fix: handle off-centre masks in convolver and blurring grid padding
When the mask is near the image edge, the PSF blurring region can extend beyond the array boundary. The convolver now accounts for asymmetric mask positions when computing fft_shape, and the blurring grid passes allow_padding=True so off-centre datasets no longer raise MaskException. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 81c368b commit 2bb3a6a

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

autoarray/operators/convolver.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,14 @@ class determines how masked real-space data are embedded into a padded array,
116116
s1 + s2 - 1 for s1, s2 in zip(mask_shape, self.kernel.shape_native)
117117
)
118118
import scipy.fft
119+
from autoarray.mask.mask_2d_util import required_shape_for_kernel
119120

120-
fft_shape = tuple(scipy.fft.next_fast_len(s, real=True) for s in full_shape)
121+
min_blur_shape = required_shape_for_kernel(mask, self.kernel.shape_native)
122+
123+
fft_shape = tuple(
124+
scipy.fft.next_fast_len(max(s, r), real=True)
125+
for s, r in zip(full_shape, min_blur_shape)
126+
)
121127

122128
self.fft_shape = fft_shape
123129
self.mask = mask.resized_from(self.fft_shape, pad_value=1)

autoarray/structures/grids/uniform_2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ def blurring_grid_from(
710710
"""
711711

712712
blurring_mask = mask.derive_mask.blurring_from(
713-
kernel_shape_native=kernel_shape_native
713+
kernel_shape_native=kernel_shape_native, allow_padding=True
714714
)
715715

716716
return cls.from_mask(

0 commit comments

Comments
 (0)