From 1d20ddaa7456b8e466ceef3ed44bdf9d798d09b5 Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Fri, 20 Dec 2024 12:10:28 +0000 Subject: [PATCH] fix bug --- autoarray/config/visualize/plots.yaml | 4 ++-- autoarray/dataset/abstract/dataset.py | 12 ++++++++++ autoarray/dataset/imaging/dataset.py | 23 +++++++++++++++++++ autoarray/dataset/imaging/simulator.py | 4 +++- .../pixelization/border_relocator.py | 4 ++-- .../pixelization/mappers/abstract.py | 2 +- 6 files changed, 43 insertions(+), 6 deletions(-) diff --git a/autoarray/config/visualize/plots.yaml b/autoarray/config/visualize/plots.yaml index 1f2185b2..da0e330e 100644 --- a/autoarray/config/visualize/plots.yaml +++ b/autoarray/config/visualize/plots.yaml @@ -8,8 +8,8 @@ dataset: # Settings for plots of all datasets data: false # Plot the individual data of every dataset? noise_map: false # Plot the individual noise-map of every dataset? signal_to_noise_map: false # Plot the individual signal-to-noise-map of every dataset? - over_sampling: false # Plot the over-sampling sub-size, used to evaluate light profiles, of every dataset? - over_sampling_pixelization: false # Plot the over-sampling sub-size, used to evaluate pixelizations, of every dataset? + over_sample_size_lp: false # Plot the over-sampling size, used to evaluate light profiles, of every dataset? + over_sample_size_pixelization: false # Plot the over-sampling size, used to evaluate pixelizations, of every dataset? imaging: # Settings for plots of imaging datasets (e.g. ImagingPlotter) psf: false fit: # Settings for plots of all fits (e.g. FitImagingPlotter, FitInterferometerPlotter). diff --git a/autoarray/dataset/abstract/dataset.py b/autoarray/dataset/abstract/dataset.py index eca0d7c8..726211e7 100644 --- a/autoarray/dataset/abstract/dataset.py +++ b/autoarray/dataset/abstract/dataset.py @@ -206,4 +206,16 @@ def trimmed_after_convolution_from(self, kernel_shape) -> "AbstractDataset": kernel_shape=kernel_shape ) + dataset.over_sample_size_lp = ( + dataset.over_sample_size_lp.trimmed_after_convolution_from( + kernel_shape=kernel_shape + ) + ) + + dataset.over_sample_size_pixelization = ( + dataset.over_sample_size_pixelization.trimmed_after_convolution_from( + kernel_shape=kernel_shape + ) + ) + return dataset diff --git a/autoarray/dataset/imaging/dataset.py b/autoarray/dataset/imaging/dataset.py index 938a812d..9fe0bd96 100644 --- a/autoarray/dataset/imaging/dataset.py +++ b/autoarray/dataset/imaging/dataset.py @@ -15,6 +15,7 @@ from autoarray import type as ty from autoarray import exc +from autoarray.operators.over_sampling import over_sample_util from autoarray.inversion.inversion.imaging import inversion_imaging_util logger = logging.getLogger(__name__) @@ -97,6 +98,28 @@ def __init__( kernel_shape_native=psf.shape_native ) except exc.MaskException: + over_sample_size_lp = ( + over_sample_util.over_sample_size_convert_to_array_2d_from( + over_sample_size=over_sample_size_lp, mask=data.mask + ) + ) + over_sample_size_lp = ( + over_sample_size_lp.padded_before_convolution_from( + kernel_shape=psf.shape_native, mask_pad_value=1 + ) + ) + print(over_sample_size_lp.shape_native) + over_sample_size_pixelization = ( + over_sample_util.over_sample_size_convert_to_array_2d_from( + over_sample_size=over_sample_size_pixelization, mask=data.mask + ) + ) + over_sample_size_pixelization = ( + over_sample_size_pixelization.padded_before_convolution_from( + kernel_shape=psf.shape_native, mask_pad_value=1 + ) + ) + data = data.padded_before_convolution_from( kernel_shape=psf.shape_native, mask_pad_value=1 ) diff --git a/autoarray/dataset/imaging/simulator.py b/autoarray/dataset/imaging/simulator.py index a43cc614..449a3d4b 100644 --- a/autoarray/dataset/imaging/simulator.py +++ b/autoarray/dataset/imaging/simulator.py @@ -171,6 +171,8 @@ def via_image_from( ) if over_sample_size is not None: - dataset = dataset.apply_over_sampling(over_sample_size_lp=over_sample_size) + dataset = dataset.apply_over_sampling( + over_sample_size_lp=over_sample_size.native + ) return dataset diff --git a/autoarray/inversion/pixelization/border_relocator.py b/autoarray/inversion/pixelization/border_relocator.py index da6d2812..50acf10e 100644 --- a/autoarray/inversion/pixelization/border_relocator.py +++ b/autoarray/inversion/pixelization/border_relocator.py @@ -211,7 +211,7 @@ def sub_border_slim(self) -> np.ndarray: print(derive_indexes_2d.sub_border_slim) """ return sub_border_pixel_slim_indexes_from( - mask_2d=np.array(self.mask), sub_size=self.sub_size + mask_2d=np.array(self.mask), sub_size=np.array(self.sub_size).astype("int") ).astype("int") @cached_property @@ -235,7 +235,7 @@ def sub_border_grid(self) -> np.ndarray: sub_grid = over_sample_util.grid_2d_slim_over_sampled_via_mask_from( mask_2d=np.array(self.mask), pixel_scales=self.mask.pixel_scales, - sub_size=np.array(self.sub_size), + sub_size=np.array(self.sub_size).astype("int"), origin=self.mask.origin, ) diff --git a/autoarray/inversion/pixelization/mappers/abstract.py b/autoarray/inversion/pixelization/mappers/abstract.py index 192fa4f5..fd0ec103 100644 --- a/autoarray/inversion/pixelization/mappers/abstract.py +++ b/autoarray/inversion/pixelization/mappers/abstract.py @@ -260,7 +260,7 @@ def unique_mappings(self) -> UniqueMappings: pix_sizes_for_sub_slim_index=self.pix_sizes_for_sub_slim_index, pix_weights_for_sub_slim_index=self.pix_weights_for_sub_slim_index, pix_pixels=self.params, - sub_size=np.array(self.over_sampler.sub_size), + sub_size=np.array(self.over_sampler.sub_size).astype("int"), ) return UniqueMappings(