예제 #1
0
    def __init__(
            self,
            dataset_line: DatasetLine,
            mat_plot_1d: aplt.MatPlot1D = aplt.MatPlot1D(),
            visuals_1d: aplt.Visuals1D = aplt.Visuals1D(),
            include_1d: aplt.Include1D = aplt.Include1D(),
    ):
        """
        Plots the attributes of `DatasetLine` objects using the matplotlib method `line()` and many other matplotlib
        functions which customize the plot's appearance.

        The `mat_plot_1d` attribute wraps matplotlib function calls to make the figure. By default, the settings
        passed to every matplotlib function called are those specified in the `config/visualize/mat_wrap/*.ini` files,
        but a user can manually input values into `MatPlot1d` to customize the figure's appearance.

        Overlaid on the figure are visuals, contained in the `Visuals1D` object. Attributes may be extracted from
        the `Imaging` and plotted via the visuals object, if the corresponding entry is `True` in the `Include1D`
        object or the `config/visualize/include.ini` file.

        Parameters
        ----------
        imaging
            The charge injection line imaging dataset the plotter plots.
        mat_plot_1d
            Contains objects which wrap the matplotlib function calls that make 1D plots.
        visuals_1d
            Contains 1D visuals that can be overlaid on 1D plots.
        include_1d
            Specifies which attributes of the `ImagingCI` are extracted and plotted as visuals for 1D plots.
        """
        super().__init__(mat_plot_1d=mat_plot_1d,
                         include_1d=include_1d,
                         visuals_1d=visuals_1d)

        self.dataset_line = dataset_line
    def test__subplot_of_plotter_list_figure(self, imaging_7x7, plot_path,
                                             plot_patch):

        mat_plot_1d = aplt.MatPlot1D(
            output=aplt.Output(plot_path, format="png"))

        plotter_0 = MockYX1DPlotter(
            y=np.array([1.0, 2.0, 3.0]),
            x=np.array([0.5, 1.0, 1.5]),
            mat_plot_1d=mat_plot_1d,
        )

        plotter_1 = MockYX1DPlotter(
            y=np.array([1.0, 2.0, 4.0]),
            x=np.array([0.5, 1.0, 1.5]),
            mat_plot_1d=mat_plot_1d,
        )

        plotter_list = [plotter_0, plotter_1]

        multi_plotter = aplt.MultiYX1DPlotter(plotter_list=plotter_list)
        multi_plotter.figure_1d(func_name="figures_1d",
                                figure_name="figure_name")

        assert path.join(plot_path,
                         "multi_figure_name.png") in plot_patch.paths
예제 #3
0
    def __init__(
        self,
        fit: FitImagingCI,
        mat_plot_2d: aplt.MatPlot2D = aplt.MatPlot2D(),
        visuals_2d: aplt.Visuals2D = aplt.Visuals2D(),
        include_2d: aplt.Include2D = aplt.Include2D(),
        mat_plot_1d: aplt.MatPlot1D = aplt.MatPlot1D(),
        visuals_1d: aplt.Visuals1D = aplt.Visuals1D(),
        include_1d: aplt.Include1D = aplt.Include1D(),
    ):
        """
        Plots the attributes of `FitImagingCI` objects using the matplotlib methods `imshow()`, `plot()` and many other 
        matplotlib functions which customize the plot's appearance.

        The `mat_plot_1d` and `mat_plot_2d` attribute wraps matplotlib function calls to make the figure. By default, 
        the settings passed to every matplotlib function called are those specified in 
        the `config/visualize/mat_wrap/*.ini` files, but a user can manually input values into `MatPlot1D` and 
        `MatPlot2D` to customize the figure's appearance.

        Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` object. Attributes may be 
        extracted from the `FitImagingCI` and plotted via the visuals object, if the corresponding entry 
        is `True` in the `Include1D` and `Include2D` object or the `config/visualize/include.ini` file.

        Parameters
        ----------
        fit
            The fit to an imaging dataset the plotter plots.
        get_visuals_2d
            A function which extracts from the `FitImaging` the 2D visuals which are plotted on figures.
        mat_plot_2d
            Contains objects which wrap the matplotlib function calls that make the plot.
        visuals_2d
            Contains visuals that can be overlaid on the plot.
        include_2d
            Specifies which attributes of the `Array2D` are extracted and plotted as visuals.
        mat_plot_1d
            Contains objects which wrap the matplotlib function calls that make 1D plots.
        visuals_1d
            Contains 1D visuals that can be overlaid on 1D plots.
        include_1d
            Specifies which attributes of the `ImagingCI` are extracted and plotted as visuals for 1D plots.            
        """
        super().__init__(
            mat_plot_2d=mat_plot_2d, include_2d=include_2d, visuals_2d=visuals_2d
        )

        self.visuals_1d = visuals_1d
        self.include_1d = include_1d
        self.mat_plot_1d = mat_plot_1d

        self.fit = fit

        self._fit_imaging_meta_plotter = FitImagingPlotterMeta(
            fit=self.fit,
            get_visuals_2d=self.get_visuals_2d,
            mat_plot_2d=self.mat_plot_2d,
            include_2d=self.include_2d,
            visuals_2d=self.visuals_2d,
        )
def test__individual_attributes_are_output(interferometer_7, plot_path,
                                           plot_patch):

    interferometer_plotter = aplt.InterferometerPlotter(
        interferometer=interferometer_7,
        mat_plot_1d=aplt.MatPlot1D(
            output=aplt.Output(path=plot_path, format="png")),
        mat_plot_2d=aplt.MatPlot2D(
            output=aplt.Output(path=plot_path, format="png")),
    )

    interferometer_plotter.figures_2d(
        visibilities=True,
        noise_map=True,
        u_wavelengths=True,
        v_wavelengths=True,
        uv_wavelengths=True,
        amplitudes_vs_uv_distances=True,
        phases_vs_uv_distances=True,
        dirty_image=True,
        dirty_noise_map=True,
        dirty_signal_to_noise_map=True,
        dirty_inverse_noise_map=True,
    )

    assert path.join(plot_path, "visibilities.png") in plot_patch.paths
    assert path.join(plot_path, "noise_map.png") in plot_patch.paths
    assert path.join(plot_path, "u_wavelengths.png") in plot_patch.paths
    assert path.join(plot_path, "v_wavelengths.png") in plot_patch.paths
    assert path.join(plot_path, "uv_wavelengths.png") in plot_patch.paths
    assert path.join(plot_path,
                     "amplitudes_vs_uv_distances.png") in plot_patch.paths
    assert path.join(plot_path,
                     "phases_vs_uv_distances.png") in plot_patch.paths
    assert path.join(plot_path, "dirty_image_2d.png") in plot_patch.paths
    assert path.join(plot_path, "dirty_noise_map_2d.png") in plot_patch.paths
    assert path.join(plot_path,
                     "dirty_signal_to_noise_map_2d.png") in plot_patch.paths
    assert path.join(plot_path,
                     "dirty_inverse_noise_map_2d.png") in plot_patch.paths

    plot_patch.paths = []

    interferometer_plotter.figures_2d(
        visibilities=True,
        u_wavelengths=False,
        v_wavelengths=True,
        amplitudes_vs_uv_distances=True,
    )

    assert path.join(plot_path, "visibilities.png") in plot_patch.paths
    assert not path.join(plot_path, "u_wavelengths.png") in plot_patch.paths
    assert path.join(plot_path, "v_wavelengths.png") in plot_patch.paths
    assert path.join(plot_path,
                     "amplitudes_vs_uv_distances.png") in plot_patch.paths
    assert path.join(plot_path,
                     "phases_vs_uv_distances.png") not in plot_patch.paths
    def __init__(
            self,
            y,
            x,
            mat_plot_1d: aplt.MatPlot1D = aplt.MatPlot1D(),
            visuals_1d: aplt.Visuals1D = aplt.Visuals1D(),
            include_1d: aplt.Include1D = aplt.Include1D(),
    ):

        super().__init__(
            y=y,
            x=x,
            mat_plot_1d=mat_plot_1d,
            visuals_1d=visuals_1d,
            include_1d=include_1d,
        )
def test__subplots_are_output(interferometer_7, plot_path, plot_patch):

    interferometer_plotter = aplt.InterferometerPlotter(
        interferometer=interferometer_7,
        mat_plot_1d=aplt.MatPlot1D(
            output=aplt.Output(path=plot_path, format="png")),
        mat_plot_2d=aplt.MatPlot2D(
            output=aplt.Output(path=plot_path, format="png")),
    )

    interferometer_plotter.subplot_interferometer()

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

    interferometer_plotter.subplot_dirty_images()

    assert path.join(plot_path, "subplot_dirty_images.png") in plot_patch.paths
def test__fit_sub_plots(fit_interferometer_7, plot_path, plot_patch):

    fit_interferometer_plotter = aplt.FitInterferometerPlotter(
        fit=fit_interferometer_7,
        mat_plot_1d=aplt.MatPlot1D(
            output=aplt.Output(path=plot_path, format="png")),
        mat_plot_2d=aplt.MatPlot2D(
            output=aplt.Output(path=plot_path, format="png")),
    )

    fit_interferometer_plotter.subplot_fit_interferometer()

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

    fit_interferometer_plotter.subplot_fit_dirty_images()

    assert path.join(plot_path,
                     "subplot_fit_dirty_images.png") in plot_patch.paths
예제 #8
0
    def test__plot_yx_line__works_with_all_extras_included(
            self, plot_path, plot_patch):

        visuals_1d = aplt.Visuals1D(vertical_line=1.0)

        mat_plot_1d = aplt.MatPlot1D(
            yx_plot=aplt.YXPlot(plot_axis_type="loglog", c="k"),
            vertical_line_axvline=aplt.AXVLine(c="k"),
            output=aplt.Output(path=plot_path, filename="yx_1", format="png"),
        )

        yx_1d_plotter = aplt.YX1DPlotter(
            y=np.array([1.0, 2.0, 3.0]),
            x=np.array([0.5, 1.0, 1.5]),
            mat_plot_1d=mat_plot_1d,
            visuals_1d=visuals_1d,
        )

        yx_1d_plotter.figure_1d()

        assert path.join(plot_path, "yx_1.png") in plot_patch.paths
def test__fit_quantities_are_output(fit_interferometer_7, plot_path,
                                    plot_patch):

    fit_interferometer_plotter = aplt.FitInterferometerPlotter(
        fit=fit_interferometer_7,
        mat_plot_1d=aplt.MatPlot1D(
            output=aplt.Output(path=plot_path, format="png")),
        mat_plot_2d=aplt.MatPlot2D(
            output=aplt.Output(path=plot_path, format="png")),
    )

    fit_interferometer_plotter.figures_2d(
        visibilities=True,
        noise_map=True,
        signal_to_noise_map=True,
        model_visibilities=True,
        residual_map_real=True,
        residual_map_imag=True,
        normalized_residual_map_real=True,
        normalized_residual_map_imag=True,
        chi_squared_map_real=True,
        chi_squared_map_imag=True,
        dirty_image=True,
        dirty_noise_map=True,
        dirty_signal_to_noise_map=True,
        dirty_model_image=True,
        dirty_residual_map=True,
        dirty_normalized_residual_map=True,
        dirty_chi_squared_map=True,
    )

    assert path.join(plot_path, "visibilities.png") in plot_patch.paths
    assert path.join(plot_path, "noise_map.png") in plot_patch.paths
    assert path.join(plot_path, "signal_to_noise_map.png") 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")
            in plot_patch.paths)
    assert (path.join(plot_path, "real_residual_map_vs_uv_distances.png")
            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,
                      "imag_normalized_residual_map_vs_uv_distances.png")
            in plot_patch.paths)
    assert (path.join(plot_path, "imag_chi_squared_map_vs_uv_distances.png")
            in plot_patch.paths)
    assert (path.join(plot_path, "imag_chi_squared_map_vs_uv_distances.png")
            in plot_patch.paths)
    assert path.join(plot_path, "dirty_image_2d.png") in plot_patch.paths
    assert path.join(plot_path, "dirty_noise_map_2d.png") in plot_patch.paths
    assert path.join(plot_path,
                     "dirty_signal_to_noise_map_2d.png") in plot_patch.paths
    assert path.join(plot_path, "dirty_model_image_2d.png") in plot_patch.paths
    assert path.join(plot_path,
                     "dirty_residual_map_2d.png") in plot_patch.paths
    assert (path.join(plot_path, "dirty_normalized_residual_map_2d.png")
            in plot_patch.paths)
    assert path.join(plot_path,
                     "dirty_chi_squared_map_2d.png") in plot_patch.paths

    plot_patch.paths = []

    fit_interferometer_plotter.figures_2d(
        visibilities=True,
        noise_map=False,
        signal_to_noise_map=False,
        model_visibilities=True,
        chi_squared_map_real=True,
        chi_squared_map_imag=True,
    )

    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, "imag_residual_map_vs_uv_distances.png")
            not in plot_patch.paths)
    assert (path.join(plot_path,
                      "real_normalized_residual_map_vs_uv_distances.png")
            not in plot_patch.paths)
    assert (path.join(plot_path,
                      "imag_normalized_residual_map_vs_uv_distances.png")
            not in plot_patch.paths)
    assert (path.join(plot_path, "real_chi_squared_map_vs_uv_distances.png")
            in plot_patch.paths)
    assert (path.join(plot_path, "imag_chi_squared_map_vs_uv_distances.png")
            in plot_patch.paths)