Exemple #1
0
    def test__visualizer_with_preloaded_critical_curves_and_caustics_is_setup(
        self,
        masked_imaging_7x7,
        tracer_x2_plane_7x7,
        include_all,
        plot_path,
        plot_patch,
    ):
        visualizer = vis.PhaseDatasetVisualizer(
            masked_dataset=masked_imaging_7x7, image_path=plot_path)

        assert visualizer.include.preloaded_critical_curves == None
        assert visualizer.include.preloaded_caustics == None

        visualizer = visualizer.new_visualizer_with_preloaded_critical_curves_and_caustics(
            preloaded_critical_curves=1, preloaded_caustics=2)

        assert visualizer.include.preloaded_critical_curves == 1
        assert visualizer.include.preloaded_caustics == 2

        visualizer.include.critical_curves = False
        visualizer.include.caustics = False
        visualizer.visualize_ray_tracing(tracer=tracer_x2_plane_7x7,
                                         during_analysis=True)

        assert plot_path + "subplots/subplot_tracer.png" in plot_patch.paths
Exemple #2
0
    def test__visualize_stochastic_histogram(self, masked_imaging_7x7,
                                             plot_path, plot_patch):

        visualizer = vis.PhaseDatasetVisualizer(
            masked_dataset=masked_imaging_7x7)

        visualizer.visualize_stochastic_histogram(
            paths=af.Paths(),
            log_evidences=[1.0, 2.0, 1.0, 2.0, 3.0, 2.5],
            max_log_evidence=3.0,
        )
        assert (path.join(plot_path, "image", "other",
                          "stochastic_histogram.png") in plot_patch.paths)
Exemple #3
0
    def test__visualizes_ray_tracing_using_configs(
        self,
        masked_imaging_7x7,
        tracer_x2_plane_7x7,
        include_all,
        plot_path,
        plot_patch,
    ):

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

        visualizer = vis.PhaseDatasetVisualizer(
            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_ray_tracing(paths=af.Paths(),
                                         tracer=tracer_x2_plane_7x7,
                                         during_analysis=False)

        assert (path.join(plot_path, "image", "ray_tracing",
                          "subplot_tracer.png") in plot_patch.paths)
        assert (path.join(plot_path, "image", "ray_tracing", "image.png")
                in plot_patch.paths)
        assert (path.join(plot_path, "image", "ray_tracing",
                          "source_plane.png") in plot_patch.paths)
        assert (path.join(plot_path, "image", "ray_tracing", "convergence.png")
                in plot_patch.paths)
        assert (path.join(plot_path, "image", "ray_tracing", "potential.png")
                not in plot_patch.paths)
        assert (path.join(plot_path, "image", "ray_tracing",
                          "deflections_y.png") not in plot_patch.paths)
        assert (path.join(plot_path, "image", "ray_tracing",
                          "deflections_x.png") not in plot_patch.paths)
        assert (path.join(plot_path, "image", "ray_tracing",
                          "magnification.png") in plot_patch.paths)

        convergence = al.util.array.numpy_array_2d_from_fits(
            file_path=path.join(plot_path, "image", "ray_tracing", "fits",
                                "convergence.fits"),
            hdu=0,
        )

        assert convergence.shape == (5, 5)
Exemple #4
0
    def test__visualize_stochastic_histogram(self, masked_imaging_7x7,
                                             plot_path, plot_patch):

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

        visualizer.visualize_stochastic_histogram(
            log_evidences=[1.0, 2.0, 1.0, 2.0, 3.0, 2.5],
            max_log_evidence=3.0,
            during_analysis=True,
        )
        assert plot_path + "other/stochastic_histogram.png" not in plot_patch.paths

        visualizer.visualize_stochastic_histogram(
            log_evidences=[1.0, 2.0, 1.0, 2.0, 3.0, 2.5],
            max_log_evidence=3.0,
            during_analysis=False,
        )
        assert plot_path + "other/stochastic_histogram.png" in plot_patch.paths
    def test__visualizes_ray_tracing_using_configs(
        self,
        masked_imaging_7x7,
        tracer_x2_plane_7x7,
        include_all,
        plot_path,
        plot_patch,
    ):

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

        visualizer = vis.PhaseDatasetVisualizer(
            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_ray_tracing(
            tracer=tracer_x2_plane_7x7, during_analysis=False
        )

        assert plot_path + "subplots/subplot_tracer.png" in plot_patch.paths
        assert plot_path + "ray_tracing/profile_image.png" in plot_patch.paths
        assert plot_path + "ray_tracing/source_plane.png" in plot_patch.paths
        assert plot_path + "ray_tracing/convergence.png" in plot_patch.paths
        assert plot_path + "ray_tracing/potential.png" not in plot_patch.paths
        assert plot_path + "ray_tracing/deflections_y.png" not in plot_patch.paths
        assert plot_path + "ray_tracing/deflections_x.png" not in plot_patch.paths
        assert plot_path + "ray_tracing/magnification.png" in plot_patch.paths

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

        assert convergence.shape == (5, 5)