def test__visualizes_imaging_using_configs(
        self, masked_imaging_7x7, include_all, plot_path, plot_patch
    ):

        visualizer = vis.PhaseImagingVisualizer(
            masked_dataset=masked_imaging_7x7, image_path=plot_path
        )

        visualizer = visualizer.new_visualizer_with_preloaded_critical_curves_and_caustics(
            preloaded_critical_curves=include_all.preloaded_critical_curves,
            preloaded_caustics=include_all.preloaded_caustics,
        )

        visualizer.visualize_imaging()

        assert plot_path + "subplots/subplot_imaging.png" in plot_patch.paths
        assert plot_path + "imaging/image.png" in plot_patch.paths
        assert plot_path + "imaging/noise_map.png" not in plot_patch.paths
        assert plot_path + "imaging/psf.png" in plot_patch.paths
        assert plot_path + "imaging/signal_to_noise_map.png" not in plot_patch.paths
        assert (
            plot_path + "imaging/absolute_signal_to_noise_map.png"
            not in plot_patch.paths
        )
        assert plot_path + "imaging/potential_chi_squared_map.png" in plot_patch.paths
示例#2
0
    def test__visualizes_hyper_images_using_config(
        self,
        masked_imaging_7x7,
        hyper_model_image_7x7,
        include_all,
        hyper_galaxy_image_path_dict_7x7,
        plot_path,
        plot_patch,
    ):

        visualizer = vis.PhaseImagingVisualizer(
            masked_dataset=masked_imaging_7x7, image_path=plot_path)

        visualizer = visualizer.new_visualizer_with_preloaded_critical_curves_and_caustics(
            preloaded_critical_curves=include_all.preloaded_critical_curves,
            preloaded_caustics=include_all.preloaded_caustics,
        )

        visualizer.visualize_hyper_images(
            hyper_galaxy_image_path_dict=hyper_galaxy_image_path_dict_7x7,
            hyper_model_image=hyper_model_image_7x7,
        )

        assert plot_path + "hyper/hyper_model_image.png" in plot_patch.paths
        assert plot_path + "hyper/subplot_hyper_galaxy_images.png" in plot_patch.paths
示例#3
0
    def __init__(
        self,
        masked_imaging,
        settings,
        cosmology,
        image_path=None,
        results=None,
        log_likelihood_cap=None,
    ):

        super().__init__(
            settings=settings,
            cosmology=cosmology,
            results=results,
            log_likelihood_cap=log_likelihood_cap,
        )

        self.visualizer = visualizer.PhaseImagingVisualizer(
            masked_dataset=masked_imaging, image_path=image_path, results=results
        )

        self.visualizer.visualize_hyper_images(
            hyper_galaxy_image_path_dict=self.hyper_galaxy_image_path_dict,
            hyper_model_image=self.hyper_model_image,
        )

        self.masked_dataset = masked_imaging
示例#4
0
    def test__visualizes_hyper_images_using_config(
        self,
        masked_imaging_7x7,
        hyper_model_image_7x7,
        include_all,
        hyper_galaxy_image_path_dict_7x7,
        masked_imaging_fit_x2_plane_7x7,
        plot_path,
        plot_patch,
    ):

        visualizer = vis.PhaseImagingVisualizer(
            masked_dataset=masked_imaging_7x7)

        visualizer = visualizer.new_visualizer_with_preloaded_critical_curves_and_caustics(
            preloaded_critical_curves=include_all.preloaded_critical_curves,
            preloaded_caustics=include_all.preloaded_caustics,
        )

        visualizer.visualize_hyper_images(
            paths=af.Paths(),
            hyper_galaxy_image_path_dict=hyper_galaxy_image_path_dict_7x7,
            hyper_model_image=hyper_model_image_7x7,
            contribution_maps_of_galaxies=masked_imaging_fit_x2_plane_7x7.
            tracer.contribution_maps_of_planes,
        )

        assert (path.join(plot_path, "image", "hyper", "hyper_model_image.png")
                in plot_patch.paths)
        assert (path.join(plot_path, "image", "hyper",
                          "subplot_hyper_images_of_galaxies.png")
                in plot_patch.paths)
        assert (path.join(plot_path, "image", "hyper",
                          "subplot_contribution_maps_of_galaxies.png")
                not in plot_patch.paths)
示例#5
0
    def test__visualizes_imaging_using_configs(self, masked_imaging_7x7,
                                               include_all, plot_path,
                                               plot_patch):

        if os.path.exists(plot_path):
            shutil.rmtree(plot_path)

        visualizer = vis.PhaseImagingVisualizer(
            masked_dataset=masked_imaging_7x7)

        visualizer = visualizer.new_visualizer_with_preloaded_critical_curves_and_caustics(
            preloaded_critical_curves=include_all.preloaded_critical_curves,
            preloaded_caustics=include_all.preloaded_caustics,
        )

        visualizer.visualize_imaging(paths=af.Paths())

        assert (path.join(plot_path, "image", "imaging", "subplot_imaging.png")
                in plot_patch.paths)
        assert path.join(plot_path, "image", "imaging",
                         "image.png") in plot_patch.paths
        assert (path.join(plot_path, "image", "imaging", "noise_map.png")
                not in plot_patch.paths)
        assert path.join(plot_path, "image", "imaging",
                         "psf.png") in plot_patch.paths
        assert (path.join(plot_path, "image", "imaging",
                          "inverse_noise_map.png") in plot_patch.paths)
        assert (path.join(plot_path, "image", "imaging",
                          "signal_to_noise_map.png") not in plot_patch.paths)
        assert (path.join(plot_path, "image", "imaging",
                          "absolute_signal_to_noise_map.png")
                not in plot_patch.paths)
        assert (path.join(plot_path, "image", "imaging",
                          "potential_chi_squared_map.png") in plot_patch.paths)
示例#6
0
    def __init__(self, masked_imaging, settings, cosmology, results=None):

        super().__init__(
            masked_dataset=masked_imaging,
            settings=settings,
            cosmology=cosmology,
            results=results,
        )

        self.visualizer = visualizer.PhaseImagingVisualizer(
            masked_dataset=masked_imaging)
示例#7
0
    def __init__(self,
                 masked_imaging,
                 cosmology,
                 image_path=None,
                 results=None):

        super(Analysis, self).__init__(cosmology=cosmology, results=results)

        self.visualizer = visualizer.PhaseImagingVisualizer(
            masked_dataset=masked_imaging,
            image_path=image_path,
            results=results)

        self.masked_dataset = masked_imaging
示例#8
0
    def __init__(self,
                 masked_imaging,
                 cosmology,
                 image_path=None,
                 results=None):

        super(Analysis, self).__init__(cosmology=cosmology, results=results)

        self.visualizer = visualizer.PhaseImagingVisualizer(
            masked_dataset=masked_imaging,
            image_path=image_path,
            results=results)

        self.visualizer.visualize_hyper_images(
            hyper_galaxy_image_path_dict=self.hyper_galaxy_image_path_dict,
            hyper_model_image=self.hyper_model_image,
        )

        self.masked_dataset = masked_imaging
示例#9
0
    def test__source_and_lens__visualizes_fit_and_inversion_using_configs(
        self,
        masked_imaging_7x7,
        masked_imaging_fit_x2_plane_inversion_7x7,
        include_all,
        plot_path,
        plot_patch,
    ):

        if os.path.exists(plot_path):
            shutil.rmtree(plot_path)

        visualizer = vis.PhaseImagingVisualizer(
            masked_dataset=masked_imaging_7x7, image_path=plot_path)

        visualizer = visualizer.new_visualizer_with_preloaded_critical_curves_and_caustics(
            preloaded_critical_curves=include_all.preloaded_critical_curves,
            preloaded_caustics=include_all.preloaded_caustics,
        )

        visualizer.visualize_fit(fit=masked_imaging_fit_x2_plane_inversion_7x7,
                                 during_analysis=False)

        assert plot_path + "subplots/subplot_fit_imaging.png" in plot_patch.paths
        assert plot_path + "fit_imaging/image.png" in plot_patch.paths
        assert plot_path + "fit_imaging/noise_map.png" not in plot_patch.paths
        assert plot_path + "fit_imaging/signal_to_noise_map.png" not in plot_patch.paths
        assert plot_path + "fit_imaging/model_image.png" in plot_patch.paths
        assert plot_path + "fit_imaging/residual_map.png" not in plot_patch.paths
        assert plot_path + "fit_imaging/normalized_residual_map.png" in plot_patch.paths
        assert plot_path + "fit_imaging/chi_squared_map.png" in plot_patch.paths
        assert (plot_path + "fit_imaging/subtracted_image_of_plane_0.png"
                in plot_patch.paths)
        assert (plot_path + "fit_imaging/subtracted_image_of_plane_1.png"
                in plot_patch.paths)
        assert (plot_path + "fit_imaging/model_image_of_plane_0.png"
                not in plot_patch.paths)
        assert (plot_path + "fit_imaging/model_image_of_plane_1.png"
                not in plot_patch.paths)
        assert plot_path + "fit_imaging/plane_image_of_plane_0.png" in plot_patch.paths
        assert plot_path + "fit_imaging/plane_image_of_plane_1.png" in plot_patch.paths

        assert plot_path + "subplots/subplot_inversion.png" in plot_patch.paths
        assert plot_path + "inversion/reconstructed_image.png" in plot_patch.paths
        assert plot_path + "inversion/reconstruction.png" in plot_patch.paths
        assert plot_path + "inversion/errors.png" not in plot_patch.paths
        assert plot_path + "inversion/residual_map.png" not in plot_patch.paths
        assert (plot_path + "inversion/normalized_residual_map.png"
                not in plot_patch.paths)
        assert plot_path + "inversion/chi_squared_map.png" in plot_patch.paths
        assert (plot_path + "inversion/regularization_weight_map.png"
                not in plot_patch.paths)
        assert (plot_path + "inversion/interpolated_reconstruction.png"
                not in plot_patch.paths)
        assert plot_path + "inversion/interpolated_errors.png" in plot_patch.paths

        image = al.util.array.numpy_array_2d_from_fits(
            file_path=plot_path + "fit_imaging/fits/image.fits", hdu=0)

        assert image.shape == (5, 5)

        image = al.util.array.numpy_array_2d_from_fits(
            file_path=plot_path +
            "inversion/fits/interpolated_reconstruction.fits",
            hdu=0,
        )

        assert image.shape == (7, 7)