コード例 #1
0
    def visualize_contribution_maps(self, tracer: Tracer):
        """
        Visualizes the contribution maps that are used for hyper features which adapt a model to the dataset it is
        fitting.

        Images are output to the `image` folder of the `visualize_path` in a subfolder called `hyper`. When
        used with a non-linear search the `visualize_path` points to the search's results folder and this function
        visualizes the maximum log likelihood contribution maps inferred by the search so far.

        Visualization includes individual images of attributes of the hyper dataset (e.g. the contribution map of
        each galaxy) and a subplot of all contribution maps on the same figure.

        The images output by the `Visualizer` are customized using the file `config/visualize/plots.ini` under the
        [hyper] header.

        Parameters
        ----------
        tracer
            The maximum log likelihood `Tracer` of the non-linear search which is used to plot the contribution maps.
        """

        def should_plot(name):
            return plot_setting(section="hyper", name=name)

        mat_plot_2d = self.mat_plot_2d_from(subfolders="hyper")

        hyper_plotter = aplt.HyperPlotter(
            mat_plot_2d=mat_plot_2d, include_2d=self.include_2d
        )

        if hasattr(tracer, "contribution_map_list"):
            if should_plot("contribution_map_list"):
                hyper_plotter.subplot_contribution_map_list(
                    contribution_map_list_list=tracer.contribution_map_list
                )
コード例 #2
0
def test__plot_hyper_images_of_galaxies(hyper_galaxy_image_path_dict_7x7,
                                        mask_2d_7x7, include_2d_all, plot_path,
                                        plot_patch):

    hyper_plotter = aplt.HyperPlotter(
        include_2d=include_2d_all,
        mat_plot_2d=aplt.MatPlot2D(
            output=aplt.Output(plot_path, format="png")),
    )

    hyper_plotter.subplot_hyper_images_of_galaxies(
        hyper_galaxy_image_path_dict=hyper_galaxy_image_path_dict_7x7)
    assert (path.join(plot_path, "subplot_hyper_images_of_galaxies.png")
            in plot_patch.paths)
コード例 #3
0
def test__plot_contribution_map_list(
    contribution_map_7x7, mask_2d_7x7, include_2d_all, plot_path, plot_patch
):

    hyper_plotter = aplt.HyperPlotter(
        include_2d=include_2d_all,
        mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")),
    )

    hyper_plotter.subplot_contribution_map_list(
        contribution_map_list_list=[contribution_map_7x7, contribution_map_7x7, None]
    )

    assert path.join(plot_path, "subplot_contribution_map_list.png") in plot_patch.paths
コード例 #4
0
    def visualize_hyper_images(
        self,
        hyper_galaxy_image_path_dict: {str, aa.Array2D},
        hyper_model_image: aa.Array2D,
    ):
        """
        Visualizes the hyper-images and hyper dataset inferred by a model-fit.

        Images are output to the `image` folder of the `visualize_path` in a subfolder called `hyper`. When
        used with a non-linear search the `visualize_path` points to the search's results folder.

        Visualization includes individual images of attributes of the hyper dataset (e.g. the hyper model image) and
        a subplot of all hyper galaxy images on the same figure.

        The images output by the `Visualizer` are customized using the file `config/visualize/plots.ini` under the
        [hyper] header.

        Parameters
        ----------
        hyper_galaxy_image_path_dict
            A dictionary mapping the path to each galaxy (e.g. its name) to its corresponding hyper galaxy image.
        hyper_model_image
            The hyper model image which corresponds to the sum of hyper galaxy images.
        """

        def should_plot(name):
            return plot_setting(section="hyper", name=name)

        mat_plot_2d = self.mat_plot_2d_from(subfolders="hyper")

        hyper_plotter = aplt.HyperPlotter(
            mat_plot_2d=mat_plot_2d, include_2d=self.include_2d
        )

        if should_plot("model_image"):
            hyper_plotter.figure_hyper_model_image(hyper_model_image=hyper_model_image)

        if should_plot("images_of_galaxies"):

            hyper_plotter.subplot_hyper_images_of_galaxies(
                hyper_galaxy_image_path_dict=hyper_galaxy_image_path_dict
            )
コード例 #5
0
def test__plot_individual_images(
    hyper_galaxy_image_0_7x7,
    contribution_map_7x7,
    include_2d_all,
    plot_path,
    plot_patch,
):

    hyper_plotter = aplt.HyperPlotter(
        include_2d=include_2d_all,
        mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")),
    )

    hyper_plotter.figure_hyper_galaxy_image(galaxy_image=hyper_galaxy_image_0_7x7)

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

    hyper_plotter.figure_contribution_map(contribution_map=contribution_map_7x7)

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