コード例 #1
0
def test__visualize_hyper_images__uses_config(
    masked_imaging_7x7,
    hyper_model_image_7x7,
    include_2d_all,
    hyper_galaxy_image_path_dict_7x7,
    fit_imaging_x2_galaxy_inversion_7x7,
    plot_path,
    plot_patch,
):

    visualizer = vis.Visualizer(visualize_path=plot_path)

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

    plot_path = path.join(plot_path, "hyper")

    assert path.join(plot_path, "hyper_model_image.png") in plot_patch.paths
    assert (
        path.join(plot_path, "subplot_hyper_images_of_galaxies.png") in plot_patch.paths
    )

    visualizer.visualize_contribution_maps(
        plane=fit_imaging_x2_galaxy_inversion_7x7.plane
    )

    assert (
        path.join(plot_path, "subplot_contribution_map_list.png")
        not in plot_patch.paths
    )
コード例 #2
0
    def visualize(self, paths: af.DirectoryPaths, instance, during_analysis):

        self.associate_hyper_images(instance=instance)
        plane = self.plane_for_instance(instance=instance)
        hyper_background_noise = self.hyper_background_noise_for_instance(
            instance=instance)

        fit = self.fit_interferometer_for_plane(
            plane=plane, hyper_background_noise=hyper_background_noise)

        visualizer = vis.Visualizer(visualize_path=paths.image_path)
        visualizer.visualize_interferometer(interferometer=self.interferometer)
        visualizer.visualize_fit_interferometer(
            fit=fit, during_analysis=during_analysis)
        if fit.inversion is not None:
            visualizer.visualize_inversion(inversion=fit.inversion,
                                           during_analysis=during_analysis)

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

        if visualizer.plot_fit_no_hyper:
            fit = self.fit_interferometer_for_plane(
                plane=plane,
                hyper_background_noise=None,
                use_hyper_scalings=False)

            visualizer.visualize_fit_interferometer(
                fit=fit,
                during_analysis=during_analysis,
                subfolders="fit_no_hyper")
コード例 #3
0
    def test__visualizes_fit_interferometer__uses_configs(
        self,
        interferometer_7,
        fit_interferometer_x2_galaxy_inversion_7x7,
        include_2d_all,
        plot_path,
        plot_patch,
    ):
        visualizer = vis.Visualizer(visualize_path=plot_path)

        visualizer.visualize_fit_interferometer(
            fit=fit_interferometer_x2_galaxy_inversion_7x7, during_analysis=True
        )

        plot_path = path.join(plot_path, "fit_interferometer")

        assert (
            path.join(plot_path, "subplot_fit_interferometer.png") in plot_patch.paths
        )
        assert path.join(plot_path, "visibilities.png") in plot_patch.paths
        assert path.join(plot_path, "noise_map.png") not in plot_patch.paths
        assert path.join(plot_path, "signal_to_noise_map.png") not in plot_patch.paths
        assert path.join(plot_path, "model_visibilities.png") in plot_patch.paths
        assert (
            path.join(plot_path, "real_residual_map_vs_uv_distances.png")
            not in plot_patch.paths
        )
        assert (
            path.join(plot_path, "real_normalized_residual_map_vs_uv_distances.png")
            in plot_patch.paths
        )
        assert (
            path.join(plot_path, "real_chi_squared_map_vs_uv_distances.png")
            in plot_patch.paths
        )
コード例 #4
0
def test__visualizes_interferometer__uses_configs(
    interferometer_7, include_2d_all, plot_path, plot_patch
):

    visualizer = vis.Visualizer(visualize_path=plot_path)

    visualizer.visualize_interferometer(interferometer=interferometer_7)

    plot_path = path.join(plot_path, "interferometer")

    assert path.join(plot_path, "subplot_interferometer.png") in plot_patch.paths
    assert path.join(plot_path, "visibilities.png") in plot_patch.paths
    assert path.join(plot_path, "u_wavelengths.png") not in plot_patch.paths
    assert path.join(plot_path, "v_wavelengths.png") not in plot_patch.paths
コード例 #5
0
    def test__visualizes_fit_imaging__uses_configs(
        self,
        masked_imaging_7x7,
        fit_imaging_x2_galaxy_inversion_7x7,
        include_2d_all,
        plot_path,
        plot_patch,
    ):

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

        visualizer = vis.Visualizer(visualize_path=plot_path)

        visualizer.visualize_fit_imaging(
            fit=fit_imaging_x2_galaxy_inversion_7x7, during_analysis=False
        )

        plot_path = path.join(plot_path, "fit_imaging")

        assert path.join(plot_path, "subplot_fit_imaging.png") in plot_patch.paths
        assert path.join(plot_path, "image_2d.png") in plot_patch.paths
        assert path.join(plot_path, "noise_map.png") not in plot_patch.paths
        assert path.join(plot_path, "signal_to_noise_map.png") not in plot_patch.paths
        assert path.join(plot_path, "model_image.png") in plot_patch.paths
        assert path.join(plot_path, "residual_map.png") not in plot_patch.paths
        assert path.join(plot_path, "normalized_residual_map.png") in plot_patch.paths
        assert path.join(plot_path, "chi_squared_map.png") in plot_patch.paths
        assert (
            path.join(plot_path, "subtracted_image_of_galaxy_0.png") in plot_patch.paths
        )
        assert (
            path.join(plot_path, "subtracted_image_of_galaxy_1.png") in plot_patch.paths
        )

        assert (
            path.join(plot_path, "model_image_of_galaxy_0.png") not in plot_patch.paths
        )
        assert (
            path.join(plot_path, "model_image_of_galaxy_1.png") not in plot_patch.paths
        )

        image = ag.util.array_2d.numpy_array_2d_from_fits(
            file_path=path.join(plot_path, "fits", "image_2d.fits"), hdu=0
        )

        assert image.shape == (5, 5)
コード例 #6
0
    def test__visualize_inversion__uses_configs(
        self,
        masked_imaging_7x7,
        voronoi_inversion_9_3x3,
        include_2d_all,
        plot_path,
        plot_patch,
    ):

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

        visualizer = vis.Visualizer(visualize_path=plot_path)

        visualizer.visualize_inversion(
            inversion=voronoi_inversion_9_3x3, during_analysis=True
        )

        plot_path = path.join(plot_path, "inversion")

        assert path.join(plot_path, "subplot_inversion.png") in plot_patch.paths
        assert path.join(plot_path, "reconstructed_image.png") in plot_patch.paths
        assert path.join(plot_path, "reconstruction.png") in plot_patch.paths
        # assert path.join(plot_path,"inversion","errors.png") not in plot_patch.paths

        assert path.join(plot_path, "residual_map.png") not in plot_patch.paths
        assert (
            path.join(plot_path, "normalized_residual_map.png") not in plot_patch.paths
        )
        assert path.join(plot_path, "chi_squared_map.png") in plot_patch.paths
        assert (
            path.join(plot_path, "regularization_weight_list.png")
            not in plot_patch.paths
        )
        assert (
            path.join(plot_path, "interpolated_reconstruction.png") in plot_patch.paths
        )
        assert path.join(plot_path, "interpolated_errors.png") in plot_patch.paths
コード例 #7
0
def test__visualizes_imaging__uses_configs(
    imaging_7x7, include_2d_all, plot_path, plot_patch
):

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

    visualizer = vis.Visualizer(visualize_path=plot_path)

    visualizer.visualize_imaging(imaging=imaging_7x7)

    plot_path = path.join(plot_path, "imaging")

    assert path.join(plot_path, "subplot_imaging.png") in plot_patch.paths
    assert path.join(plot_path, "image_2d.png") in plot_patch.paths
    assert path.join(plot_path, "noise_map.png") not in plot_patch.paths
    assert path.join(plot_path, "psf.png") in plot_patch.paths
    assert path.join(plot_path, "inverse_noise_map.png") in plot_patch.paths
    assert path.join(plot_path, "signal_to_noise_map.png") not in plot_patch.paths
    assert (
        path.join(plot_path, "absolute_signal_to_noise_map.png") not in plot_patch.paths
    )
    assert path.join(plot_path, "potential_chi_squared_map.png") in plot_patch.paths