99from autoarray .dataset .grids import GridsDataset
1010from autoarray .dataset .imaging .w_tilde import WTildeImaging
1111from autoarray .structures .arrays .uniform_2d import Array2D
12- from autoarray .operators .convolver import Convolver
1312from autoarray .structures .arrays .kernel_2d import Kernel2D
1413from autoarray .mask .mask_2d import Mask2D
1514from autoarray import type as ty
@@ -30,7 +29,7 @@ def __init__(
3029 noise_covariance_matrix : Optional [np .ndarray ] = None ,
3130 over_sample_size_lp : Union [int , Array2D ] = 4 ,
3231 over_sample_size_pixelization : Union [int , Array2D ] = 4 ,
33- pad_for_convolver : bool = False ,
32+ pad_for_psf : bool = False ,
3433 use_normalized_psf : Optional [bool ] = True ,
3534 check_noise_map : bool = True ,
3635 ):
@@ -77,7 +76,7 @@ def __init__(
7776 over_sample_size_pixelization
7877 How over sampling is performed for the grid which is associated with a pixelization, which is therefore
7978 passed into the calculations performed in the `inversion` module.
80- pad_for_convolver
79+ pad_for_psf
8180 The PSF convolution may extend beyond the edges of the image mask, which can lead to edge effects in the
8281 convolved image. If `True`, the image and noise-map are padded to ensure the PSF convolution does not
8382 extend beyond the edge of the image.
@@ -90,9 +89,9 @@ def __init__(
9089
9190 self .unmasked = None
9291
93- self .pad_for_convolver = pad_for_convolver
92+ self .pad_for_psf = pad_for_psf
9493
95- if pad_for_convolver and psf is not None :
94+ if pad_for_psf and psf is not None :
9695 try :
9796 data .mask .derive_mask .blurring_from (
9897 kernel_shape_native = psf .shape_native
@@ -162,11 +161,15 @@ def __init__(
162161
163162 if psf is not None and use_normalized_psf :
164163 psf = Kernel2D .no_mask (
165- values = psf .native , pixel_scales = psf .pixel_scales , normalize = True
164+ values = psf .native . _array , pixel_scales = psf .pixel_scales , normalize = True
166165 )
167166
168167 self .psf = psf
169168
169+ if psf is not None :
170+ if psf .mask .shape [0 ] % 2 == 0 or psf .mask .shape [1 ] % 2 == 0 :
171+ raise exc .KernelException ("Kernel2D Kernel2D must be odd" )
172+
170173 @cached_property
171174 def grids (self ):
172175 return GridsDataset (
@@ -176,25 +179,6 @@ def grids(self):
176179 psf = self .psf ,
177180 )
178181
179- @cached_property
180- def convolver (self ):
181- """
182- Returns a `Convolver` from a mask and 2D PSF kernel.
183-
184- The `Convolver` stores in memory the array indexing between the mask and PSF, enabling efficient 2D PSF
185- convolution of images and matrices used for linear algebra calculations (see `operators.convolver`).
186-
187- This uses lazy allocation such that the calculation is only performed when the convolver is used, ensuring
188- efficient set up of the `Imaging` class.
189-
190- Returns
191- -------
192- Convolver
193- The convolver given the masked imaging data's mask and PSF.
194- """
195-
196- return Convolver (mask = self .mask , kernel = self .psf )
197-
198182 @cached_property
199183 def w_tilde (self ):
200184 """
@@ -220,9 +204,9 @@ def w_tilde(self):
220204 indexes ,
221205 lengths ,
222206 ) = inversion_imaging_util .w_tilde_curvature_preload_imaging_from (
223- noise_map_native = np .array (self .noise_map .native ),
224- kernel_native = np .array (self .psf .native ),
225- native_index_for_slim_index = self .mask .derive_indexes .native_for_slim ,
207+ noise_map_native = np .array (self .noise_map .native . array ). astype ( "float64" ),
208+ kernel_native = np .array (self .psf .native . array ). astype ( "float64" ),
209+ native_index_for_slim_index = np . array ( self .mask .derive_indexes .native_for_slim ). astype ( "int" ) ,
226210 )
227211
228212 return WTildeImaging (
@@ -370,7 +354,7 @@ def apply_mask(self, mask: Mask2D) -> "Imaging":
370354 noise_covariance_matrix = noise_covariance_matrix ,
371355 over_sample_size_lp = over_sample_size_lp ,
372356 over_sample_size_pixelization = over_sample_size_pixelization ,
373- pad_for_convolver = True ,
357+ pad_for_psf = True ,
374358 )
375359
376360 dataset .unmasked = unmasked_dataset
@@ -425,20 +409,20 @@ def apply_noise_scaling(
425409 """
426410
427411 if signal_to_noise_value is None :
428- noise_map = self .noise_map .native
429- noise_map [mask == False ] = noise_value
412+ noise_map = np . array ( self .noise_map .native . array )
413+ noise_map [mask . array == False ] = noise_value
430414 else :
431415 noise_map = np .where (
432416 mask == False ,
433- np .median (self .data .native [mask .derive_mask .edge == False ])
417+ np .median (self .data .native . array [mask .derive_mask .edge == False ])
434418 / signal_to_noise_value ,
435- self .noise_map .native ,
419+ self .noise_map .native . array ,
436420 )
437421
438422 if should_zero_data :
439- data = np .where (np .invert (mask ), 0.0 , self .data .native )
423+ data = np .where (np .invert (mask . array ), 0.0 , self .data .native . array )
440424 else :
441- data = self .data .native
425+ data = self .data .native . array
442426
443427 data_unmasked = Array2D .no_mask (
444428 values = data ,
@@ -463,7 +447,7 @@ def apply_noise_scaling(
463447 noise_covariance_matrix = self .noise_covariance_matrix ,
464448 over_sample_size_lp = self .over_sample_size_lp ,
465449 over_sample_size_pixelization = self .over_sample_size_pixelization ,
466- pad_for_convolver = False ,
450+ pad_for_psf = False ,
467451 check_noise_map = False ,
468452 )
469453
@@ -511,7 +495,7 @@ def apply_over_sampling(
511495 over_sample_size_lp = over_sample_size_lp or self .over_sample_size_lp ,
512496 over_sample_size_pixelization = over_sample_size_pixelization
513497 or self .over_sample_size_pixelization ,
514- pad_for_convolver = False ,
498+ pad_for_psf = False ,
515499 check_noise_map = False ,
516500 )
517501
0 commit comments