Skip to content

Commit 7cd4931

Browse files
Jammy2211Jammy2211
authored andcommitted
update FFT padding defaults to go odd x odd image if FFT not used
1 parent 8270894 commit 7cd4931

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

autoarray/config/general.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ jax:
22
use_jax: true # If True, uses JAX internally, whereas False uses normal Numpy.
33
fits:
44
flip_for_ds9: false # If True, the image is flipped before output to a .fits file, which is useful for viewing in DS9.
5+
psf:
6+
use_fft_default: true # If True, PSFs are convolved using FFTs by default, which is faster and uses less memory in all cases except for very small PSFs, False uses direct convolution.
57
inversion:
68
check_reconstruction: true # If True, the inversion's reconstruction is checked to ensure the solution of a meshs's mapper is not an invalid solution where the values are all the same.
79
use_positive_only_solver: true # If True, inversion's use a positive-only linear algebra solver by default, which is slower but prevents unphysical negative values in the reconstructed solutuion.

autoarray/dataset/imaging/dataset.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import Optional, Union
55

66
from autoconf import cached_property
7+
from autoconf import instance
78

89
from autoarray.dataset.abstract.dataset import AbstractDataset
910
from autoarray.dataset.grids import GridsDataset
@@ -95,6 +96,10 @@ def __init__(
9596

9697
if psf is not None and not disable_fft_pad and data.mask.shape != fft_shape:
9798

99+
# If using real-space convolution instead of FFT, enforce odd-odd shapes
100+
if not psf.use_fft:
101+
fft_shape = tuple(s + 1 if s % 2 == 0 else s for s in fft_shape)
102+
98103
logger.info(
99104
f"Imaging data has been trimmed or padded for FFT convolution.\n"
100105
f" - Original shape : {data.mask.shape}\n"
@@ -345,10 +350,13 @@ def apply_mask(self, mask: Mask2D, disable_fft_pad: bool = False) -> "Imaging":
345350
mask
346351
The 2D mask that is applied to the image.
347352
"""
348-
if not self.data.mask.is_all_false:
353+
invalid = np.logical_and(self.data.mask, np.logical_not(mask))
354+
355+
if np.any(invalid):
349356
raise exc.DatasetException(
350-
"The mask has already been applied to the dataset, therefore a new mask cannot be applied. "
351-
"If you wish to apply a new mask, please reload the dataset from .fits files."
357+
"The new mask overlaps with pixels that are already unmasked in the dataset. "
358+
"You cannot apply a new mask on top of an existing one. "
359+
"If you wish to apply a different mask, please reload the dataset from .fits files."
352360
)
353361

354362
data = Array2D(values=self.data.native, mask=mask)

test_autoarray/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ def pytest_configure():
1414
from autoconf import conf
1515

1616

17+
18+
19+
1720
class PlotPatch:
1821
def __init__(self):
1922
self.paths = []

0 commit comments

Comments
 (0)