From 451968fbd9033349d746c4f4213f70b29c8e982c Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Sun, 15 Jun 2025 16:08:31 +0100 Subject: [PATCH 1/3] fix all fit imaging --- autogalaxy/profiles/light/linear/abstract.py | 41 +------------------- test_autogalaxy/imaging/test_fit_imaging.py | 12 +++--- 2 files changed, 7 insertions(+), 46 deletions(-) diff --git a/autogalaxy/profiles/light/linear/abstract.py b/autogalaxy/profiles/light/linear/abstract.py index 403cc9829..e74726d2e 100644 --- a/autogalaxy/profiles/light/linear/abstract.py +++ b/autogalaxy/profiles/light/linear/abstract.py @@ -269,44 +269,6 @@ def mapping_matrix(self) -> np.ndarray: return mapping_matrix - # @cached_property - # def operated_mapping_matrix_override(self) -> Optional[np.ndarray]: - # """ - # The inversion object takes the `mapping_matrix` of each linear object and combines it with the `Convolver` - # operator to perform a 2D convolution and compute the `operated_mapping_matrix`. - # - # If this property is overwritten this operation is not performed, with the `operated_mapping_matrix` output this - # property automatically used instead. - # - # This is used for a linear light profile because the in-built mapping matrix convolution does not account for - # how light profile images have flux outside the masked region which is blurred into the masked region. This - # flux is outside the region that defines the `mapping_matrix` and thus this override is required to properly - # incorporate it. - # - # Returns - # ------- - # A blurred mapping matrix of dimensions (total_mask_pixels, 1) which overrides the mapping matrix calculations - # performed in the linear equation solvers. - # """ - # - # if isinstance(self.light_profile_list[0], LightProfileOperated): - # return self.mapping_matrix - # - # operated_mapping_matrix = np.zeros(shape=(self.pixels_in_mask, self.params)) - # - # for pixel, light_profile in enumerate(self.light_profile_list): - # image_2d = light_profile.image_2d_from(grid=self.grid) - # - # blurring_image_2d = light_profile.image_2d_from(grid=self.blurring_grid) - # - # blurred_image_2d = self.convolver.convolve_image( - # image=image_2d, blurring_image=blurring_image_2d - # ) - # - # operated_mapping_matrix[:, pixel] = blurred_image_2d - # - # return operated_mapping_matrix - @cached_property def operated_mapping_matrix_override(self) -> Optional[np.ndarray]: """ @@ -343,5 +305,4 @@ def operated_mapping_matrix_override(self) -> Optional[np.ndarray]: blurred_image_2d_list.append(blurred_image_2d.array) - # return jnp.stack(blurred_image_2d_list, axis=1) - return np.stack(blurred_image_2d_list, axis=1) + return jnp.stack(blurred_image_2d_list, axis=1) diff --git a/test_autogalaxy/imaging/test_fit_imaging.py b/test_autogalaxy/imaging/test_fit_imaging.py index 461f8323c..a85dda675 100644 --- a/test_autogalaxy/imaging/test_fit_imaging.py +++ b/test_autogalaxy/imaging/test_fit_imaging.py @@ -289,8 +289,8 @@ def test__galaxy_model_image_dict(masked_imaging_7x7): ) assert (fit.galaxy_model_image_dict[g3] == np.zeros(9)).all() - assert fit.model_data.native == pytest.approx( - fit.galaxy_model_image_dict[g0_linear].native, 1.0e-4 + assert fit.model_data.native.array == pytest.approx( + fit.galaxy_model_image_dict[g0_linear].native.array, 1.0e-4 ) # Pixelization + Regularizaiton only @@ -357,7 +357,7 @@ def test__galaxy_model_image_dict(masked_imaging_7x7): ) assert mapped_reconstructed_image == pytest.approx( - fit.inversion.mapped_reconstructed_image, 1.0e-4 + fit.inversion.mapped_reconstructed_image.array, 1.0e-4 ) assert fit.model_data == pytest.approx( @@ -385,11 +385,11 @@ def test__model_images_of_galaxies_list(masked_imaging_7x7): assert fit.model_images_of_galaxies_list[0] == pytest.approx( fit.galaxy_model_image_dict[galaxy_light].array, 1.0e-4 ) - assert fit.model_images_of_galaxies_list[1] == pytest.approx( - fit.galaxy_model_image_dict[galaxy_linear], 1.0e-4 + assert fit.model_images_of_galaxies_list[1].array == pytest.approx( + fit.galaxy_model_image_dict[galaxy_linear].array, 1.0e-4 ) assert fit.model_images_of_galaxies_list[2] == pytest.approx( - fit.galaxy_model_image_dict[galaxy_pix], 1.0e-4 + fit.galaxy_model_image_dict[galaxy_pix].array, 1.0e-4 ) From 877a8a10b336a29f03b3ed44470340edf2e5ec36 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Sun, 15 Jun 2025 16:14:42 +0100 Subject: [PATCH 2/3] fix interferometry --- test_autogalaxy/interferometer/test_fit_interferometer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test_autogalaxy/interferometer/test_fit_interferometer.py b/test_autogalaxy/interferometer/test_fit_interferometer.py index 6de6afc67..a7ead0b7c 100644 --- a/test_autogalaxy/interferometer/test_fit_interferometer.py +++ b/test_autogalaxy/interferometer/test_fit_interferometer.py @@ -187,8 +187,8 @@ def test___galaxy_model_image_dict(interferometer_7): assert (fit.galaxy_model_image_dict[g0].native == 0.0 + 0.0j * np.zeros((7,))).all() - assert fit.galaxy_model_image_dict[galaxy_pix_0] == pytest.approx( - inversion.mapped_reconstructed_image.slim, 1.0e-4 + assert fit.galaxy_model_image_dict[galaxy_pix_0].array == pytest.approx( + inversion.mapped_reconstructed_image.slim.array, 1.0e-4 ) # Linear Light PRofiles + Pixelization + Regularizaiton @@ -223,8 +223,8 @@ def test___galaxy_model_image_dict(interferometer_7): + fit.galaxy_model_image_dict[galaxy_pix_1] ) - assert mapped_reconstructed_image == pytest.approx( - fit.inversion.mapped_reconstructed_image, 1.0e-4 + assert mapped_reconstructed_image.array == pytest.approx( + fit.inversion.mapped_reconstructed_image.array, 1.0e-4 ) From 31079d6bcd93ffaae24005016eeffa9b0890fd90 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Sun, 15 Jun 2025 16:28:20 +0100 Subject: [PATCH 3/3] fin --- .../files/array/output_test/noise_map.fits | Bin 5760 -> 5760 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test_autogalaxy/quantity/files/array/output_test/noise_map.fits b/test_autogalaxy/quantity/files/array/output_test/noise_map.fits index 3c732e540eadc64253747f10746c71b34a0e26b2..9a8e8e0cb2789aba96d26ef925ebd3282922980c 100644 GIT binary patch delta 75 zcmZqBZP4A|!fkWr%$c(eGHGDoAONKmjKRSE<4h2kM^1!H3eAm9Gu%$W;7;v!IShBIdlfcO$X{^myR L|6G$NaI*jat4tGh