示例#1
0
    def test__voronoi_drawer__from_config_or_via_manual_input(self):

        plotter = aplt.Plotter()

        assert plotter.voronoi_drawer.edgewidth == 0.3
        assert plotter.voronoi_drawer.edgecolor == "k"
        assert plotter.voronoi_drawer.alpha == 0.7

        plotter = aplt.Plotter(voronoi_drawer=aplt.VoronoiDrawer(
            edgewidth=0.5, edgecolor="r", alpha=1.0))

        assert plotter.voronoi_drawer.edgewidth == 0.5
        assert plotter.voronoi_drawer.edgecolor == "r"
        assert plotter.voronoi_drawer.alpha == 1.0

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.voronoi_drawer.edgewidth == 1.0
        assert sub_plotter.voronoi_drawer.edgecolor == "r"
        assert sub_plotter.voronoi_drawer.alpha == 0.5

        sub_plotter = aplt.SubPlotter(
            voronoi_drawer=aplt.VoronoiDrawer.sub(edgecolor="r", alpha=1.0))

        assert sub_plotter.voronoi_drawer.edgewidth == 1.0
        assert sub_plotter.voronoi_drawer.edgecolor == "r"
        assert sub_plotter.voronoi_drawer.alpha == 1.0
示例#2
0
def test__individual_attributes_are_output(imaging_7x7, positions_7x7,
                                           mask_7x7, plot_path, plot_patch):

    aplt.imaging.image(
        imaging=imaging_7x7,
        positions=positions_7x7,
        mask=mask_7x7,
        include=aplt.Include(mask=True),
        plotter=aplt.Plotter(output=aplt.Output(plot_path, format="png")),
    )

    assert plot_path + "image.png" in plot_patch.paths

    aplt.imaging.noise_map(
        imaging=imaging_7x7,
        mask=mask_7x7,
        plotter=aplt.Plotter(output=aplt.Output(plot_path, format="png")),
    )

    assert plot_path + "noise_map.png" in plot_patch.paths

    aplt.imaging.psf(
        imaging=imaging_7x7,
        plotter=aplt.Plotter(output=aplt.Output(plot_path, format="png")),
    )

    assert plot_path + "psf.png" in plot_patch.paths

    aplt.imaging.signal_to_noise_map(
        imaging=imaging_7x7,
        mask=mask_7x7,
        plotter=aplt.Plotter(output=aplt.Output(plot_path, format="png")),
    )

    assert plot_path + "signal_to_noise_map.png" in plot_patch.paths
示例#3
0
    def test__pixelization_grid_scatterer__from_config_or_via_manual_input(
            self):

        plotter = aplt.Plotter()

        assert plotter.pixelization_grid_scatterer.size == 5
        assert plotter.pixelization_grid_scatterer.marker == "."
        assert plotter.pixelization_grid_scatterer.colors == ["r"]

        plotter = aplt.Plotter(
            pixelization_grid_scatterer=aplt.PixelizationGridScatterer(
                size=1, marker="x", colors="k"))

        assert plotter.pixelization_grid_scatterer.size == 1
        assert plotter.pixelization_grid_scatterer.marker == "x"
        assert plotter.pixelization_grid_scatterer.colors == ["k"]

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.pixelization_grid_scatterer.size == 6
        assert sub_plotter.pixelization_grid_scatterer.marker == "o"
        assert sub_plotter.pixelization_grid_scatterer.colors == ["g"]

        sub_plotter = aplt.SubPlotter(
            pixelization_grid_scatterer=aplt.PixelizationGridScatterer.sub(
                marker="o", colors="r"))

        assert sub_plotter.pixelization_grid_scatterer.size == 6
        assert sub_plotter.pixelization_grid_scatterer.marker == "o"
        assert sub_plotter.pixelization_grid_scatterer.colors == ["r"]
示例#4
0
    def test__liner__from_config_or_via_manual_input(self):

        plotter = aplt.Plotter()

        assert plotter.liner.width == 3
        assert plotter.liner.style == "-"
        assert plotter.liner.colors == ["k", "w"]
        assert plotter.liner.pointsize == 2

        plotter = aplt.Plotter(liner=aplt.Liner(
            width=1, style=".", colors=["k", "b"], pointsize=3))

        assert plotter.liner.width == 1
        assert plotter.liner.style == "."
        assert plotter.liner.colors == ["k", "b"]
        assert plotter.liner.pointsize == 3

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.liner.width == 1
        assert sub_plotter.liner.style == "-"
        assert sub_plotter.liner.colors == ["k"]
        assert sub_plotter.liner.pointsize == 20

        sub_plotter = aplt.SubPlotter(
            liner=aplt.Liner.sub(style=".", colors="r", pointsize=21))

        assert sub_plotter.liner.width == 1
        assert sub_plotter.liner.style == "."
        assert sub_plotter.liner.colors == ["r"]
        assert sub_plotter.liner.pointsize == 21
示例#5
0
    def test__positions_scatterer__from_config_or_via_manual_input(self):

        plotter = aplt.Plotter()

        assert plotter.positions_scatterer.size == 15
        assert plotter.positions_scatterer.marker == "o"
        assert plotter.positions_scatterer.colors == ["r", "g", "b"]

        plotter = aplt.Plotter(positions_scatterer=aplt.PositionsScatterer(
            size=1, marker="x", colors="k"))

        assert plotter.positions_scatterer.size == 1
        assert plotter.positions_scatterer.marker == "x"
        assert plotter.positions_scatterer.colors == ["k"]

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.positions_scatterer.size == 5
        assert sub_plotter.positions_scatterer.marker == "."
        assert sub_plotter.positions_scatterer.colors == ["c", "g", "b"]

        sub_plotter = aplt.SubPlotter(
            positions_scatterer=aplt.PositionsScatterer.sub(marker="o",
                                                            colors=["r", "b"]))

        assert sub_plotter.positions_scatterer.size == 5
        assert sub_plotter.positions_scatterer.marker == "o"
        assert sub_plotter.positions_scatterer.colors == ["r", "b"]
示例#6
0
    def test__index_scatterer__from_config_or_via_manual_input(self):

        plotter = aplt.Plotter()

        assert plotter.index_scatterer.size == 20
        assert plotter.index_scatterer.marker == "."
        assert plotter.index_scatterer.colors == ["r", "g", "b", "y", "k", "w"]

        plotter = aplt.Plotter(index_scatterer=aplt.IndexScatterer(
            size=1, marker="x", colors="k"))

        assert plotter.index_scatterer.size == 1
        assert plotter.index_scatterer.marker == "x"
        assert plotter.index_scatterer.colors == ["k"]

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.index_scatterer.size == 21
        assert sub_plotter.index_scatterer.marker == "+"
        assert sub_plotter.index_scatterer.colors == [
            "r", "g", "b", "y", "w", "k"
        ]

        sub_plotter = aplt.SubPlotter(
            index_scatterer=aplt.IndexScatterer.sub(marker="o", colors="r"))

        assert sub_plotter.index_scatterer.size == 21
        assert sub_plotter.index_scatterer.marker == "o"
        assert sub_plotter.index_scatterer.colors == ["r"]
示例#7
0
    def test__border_scatterer__from_config_or_via_manual_input(self):

        plotter = aplt.Plotter()

        assert plotter.border_scatterer.size == 13
        assert plotter.border_scatterer.marker == "+"
        assert plotter.border_scatterer.colors == ["c"]

        plotter = aplt.Plotter(border_scatterer=aplt.BorderScatterer(
            size=1, marker="x", colors="k"))

        assert plotter.border_scatterer.size == 1
        assert plotter.border_scatterer.marker == "x"
        assert plotter.border_scatterer.colors == ["k"]

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.border_scatterer.size == 7
        assert sub_plotter.border_scatterer.marker == "."
        assert sub_plotter.border_scatterer.colors == ["k"]

        sub_plotter = aplt.SubPlotter(
            border_scatterer=aplt.BorderScatterer.sub(marker="o",
                                                      colors=["r", "b"]))

        assert sub_plotter.border_scatterer.size == 7
        assert sub_plotter.border_scatterer.marker == "o"
        assert sub_plotter.border_scatterer.colors == ["r", "b"]
示例#8
0
    def test__grid_scatterer__from_config_or_via_manual_input(self):

        plotter = aplt.Plotter()

        assert plotter.grid_scatterer.size == 14
        assert plotter.grid_scatterer.marker == "x"
        assert plotter.grid_scatterer.colors == ["y"]

        plotter = aplt.Plotter(
            grid_scatterer=aplt.GridScatterer(size=1, marker="x", colors="k"))

        assert plotter.grid_scatterer.size == 1
        assert plotter.grid_scatterer.marker == "x"
        assert plotter.grid_scatterer.colors == ["k"]

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.grid_scatterer.size == 6
        assert sub_plotter.grid_scatterer.marker == "."
        assert sub_plotter.grid_scatterer.colors == ["r"]

        sub_plotter = aplt.SubPlotter(grid_scatterer=aplt.GridScatterer.sub(
            marker="o", colors=["r", "b"]))

        assert sub_plotter.grid_scatterer.size == 6
        assert sub_plotter.grid_scatterer.marker == "o"
        assert sub_plotter.grid_scatterer.colors == ["r", "b"]
示例#9
0
    def test__units__from_config_or_via_manual_input(self):

        plotter = aplt.Plotter()

        assert plotter.units.use_scaled == True
        assert plotter.units.in_kpc == False
        assert plotter.units.conversion_factor == None

        plotter = aplt.Plotter(
            units=aplt.Units(in_kpc=True, conversion_factor=2.0))

        assert plotter.units.use_scaled == True
        assert plotter.units.in_kpc == True
        assert plotter.units.conversion_factor == 2.0

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.units.use_scaled == True
        assert sub_plotter.units.in_kpc == False
        assert sub_plotter.units.conversion_factor == None

        sub_plotter = aplt.SubPlotter(
            units=aplt.Units(use_scaled=False, conversion_factor=2.0))

        assert sub_plotter.units.use_scaled == False
        assert sub_plotter.units.in_kpc == False
        assert sub_plotter.units.conversion_factor == 2.0
示例#10
0
    def test__mask_scatterer__from_config_or_via_manual_input(self):

        plotter = aplt.Plotter()

        assert plotter.mask_scatterer.size == 12
        assert plotter.mask_scatterer.marker == "."
        assert plotter.mask_scatterer.colors == ["g"]

        plotter = aplt.Plotter(
            mask_scatterer=aplt.MaskScatterer(size=1, marker="x", colors="k"))

        assert plotter.mask_scatterer.size == 1
        assert plotter.mask_scatterer.marker == "x"
        assert plotter.mask_scatterer.colors == ["k"]

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.mask_scatterer.size == 8
        assert sub_plotter.mask_scatterer.marker == "."
        assert sub_plotter.mask_scatterer.colors == ["w"]

        sub_plotter = aplt.SubPlotter(mask_scatterer=aplt.MaskScatterer.sub(
            marker="o", colors=["r", "b"]))

        assert sub_plotter.mask_scatterer.size == 8
        assert sub_plotter.mask_scatterer.marker == "o"
        assert sub_plotter.mask_scatterer.colors == ["r", "b"]
示例#11
0
    def test__origin_scatterer__from_config_or_via_manual_input(self):

        plotter = aplt.Plotter()

        assert plotter.origin_scatterer.size == 80
        assert plotter.origin_scatterer.marker == "x"
        assert plotter.origin_scatterer.colors == ["k"]

        plotter = aplt.Plotter(origin_scatterer=aplt.OriginScatterer(
            size=1, marker=".", colors="k"))

        assert plotter.origin_scatterer.size == 1
        assert plotter.origin_scatterer.marker == "."
        assert plotter.origin_scatterer.colors == ["k"]

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.origin_scatterer.size == 81
        assert sub_plotter.origin_scatterer.marker == "."
        assert sub_plotter.origin_scatterer.colors == ["r"]

        sub_plotter = aplt.SubPlotter(
            origin_scatterer=aplt.OriginScatterer.sub(marker="o",
                                                      colors=["r", "b"]))

        assert sub_plotter.origin_scatterer.size == 81
        assert sub_plotter.origin_scatterer.marker == "o"
        assert sub_plotter.origin_scatterer.colors == ["r", "b"]
示例#12
0
    def test__ticks__from_config_or_via_manual_input(self):

        plotter = aplt.Plotter()

        assert plotter.ticks.ysize == 14
        assert plotter.ticks.xsize == 15
        assert plotter.ticks.y_manual == None
        assert plotter.ticks.x_manual == None

        plotter = aplt.Plotter(ticks=aplt.Ticks(
            ysize=24, xsize=25, y_manual=[1.0, 2.0], x_manual=[3.0, 4.0]))

        assert plotter.ticks.ysize == 24
        assert plotter.ticks.xsize == 25
        assert plotter.ticks.y_manual == [1.0, 2.0]
        assert plotter.ticks.x_manual == [3.0, 4.0]

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.ticks.ysize == 24
        assert sub_plotter.ticks.xsize == 25
        assert sub_plotter.ticks.y_manual == None
        assert sub_plotter.ticks.x_manual == None

        sub_plotter = aplt.SubPlotter(ticks=aplt.Ticks.sub(
            xsize=25, y_manual=[1.0, 2.0], x_manual=[3.0, 4.0]))

        assert sub_plotter.ticks.ysize == 24
        assert sub_plotter.ticks.xsize == 25
        assert sub_plotter.ticks.y_manual == [1.0, 2.0]
        assert sub_plotter.ticks.x_manual == [3.0, 4.0]
示例#13
0
    def test__output__correctly(self):

        plotter = aplt.Plotter()

        assert plotter.output.path == None
        assert plotter.output._format == None
        assert plotter.output.format == "show"
        assert plotter.output.filename == None

        plotter = aplt.Plotter(
            output=aplt.Output(path="Path", format="png", filename="file"))

        assert plotter.output.path == "Path"
        assert plotter.output._format == "png"
        assert plotter.output.format == "png"
        assert plotter.output.filename == "file"

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.output.path == None
        assert sub_plotter.output._format == None
        assert sub_plotter.output.format == "show"
        assert sub_plotter.output.filename == None

        sub_plotter = aplt.SubPlotter(
            output=aplt.Output(path="Path", format="png", filename="file"))

        assert sub_plotter.output.path == "Path"
        assert sub_plotter.output._format == "png"
        assert sub_plotter.output.format == "png"
        assert sub_plotter.output.filename == "file"
示例#14
0
    def test__plot_array__works_with_all_extras_included(
            self, plot_path, plot_patch):

        array = aa.array.ones(shape_2d=(31, 31),
                              pixel_scales=(1.0, 1.0),
                              sub_size=2)

        mask = aa.mask.circular(
            shape_2d=array.shape_2d,
            pixel_scales=array.pixel_scales,
            radius=5.0,
            centre=(2.0, 2.0),
        )

        grid = aa.grid.uniform(shape_2d=(11, 11), pixel_scales=0.5)

        plotter = aplt.Plotter(output=aplt.Output(
            path=plot_path, filename="array1", format="png"))

        plotter.plot_array(
            array=array,
            mask=mask,
            grid=grid,
            positions=[(-1.0, -1.0)],
            lines=[(1.0, 1.0), (2.0, 2.0)],
            include_origin=True,
            include_border=True,
        )

        assert plot_path + "array1.png" in plot_patch.paths

        plotter = aplt.Plotter(output=aplt.Output(
            path=plot_path, filename="array2", format="png"))

        plotter.plot_array(
            array=array,
            mask=mask,
            grid=grid,
            positions=[[(1.0, 1.0), (2.0, 2.0)], [(-1.0, -1.0)]],
            lines=[[(1.0, 1.0), (2.0, 2.0)], [(2.0, 4.0), (5.0, 6.0)]],
            include_origin=True,
            include_border=True,
        )

        assert plot_path + "array2.png" in plot_patch.paths

        aplt.array(
            array=array,
            mask=mask,
            grid=grid,
            positions=[(-1.0, -1.0)],
            lines=[(1.0, 1.0), (2.0, 2.0)],
            include=aplt.Include(origin=True, border=True),
            plotter=aplt.Plotter(output=aplt.Output(
                path=plot_path, filename="array3", format="png")),
        )

        assert plot_path + "array3.png" in plot_patch.paths
def test__fit_individuals__source_and_lens__depedent_on_input(
        fit_imaging_7x7, plot_path, plot_patch):

    aplt.fit_imaging.individuals(
        fit=fit_imaging_7x7,
        include=aplt.Include(mask=True),
        plot_image=True,
        plot_noise_map=False,
        plot_signal_to_noise_map=False,
        plot_model_image=True,
        plot_chi_squared_map=True,
        plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")),
    )

    assert plot_path + "image.png" in plot_patch.paths

    assert plot_path + "noise_map.png" not in plot_patch.paths

    assert plot_path + "signal_to_noise_map.png" not in plot_patch.paths

    assert plot_path + "model_image.png" in plot_patch.paths

    assert plot_path + "residual_map.png" not in plot_patch.paths

    assert plot_path + "normalized_residual_map.png" not in plot_patch.paths

    assert plot_path + "chi_squared_map.png" in plot_patch.paths

    aplt.fit_imaging.individuals(
        fit=fit_imaging_7x7,
        plot_image=True,
        plot_noise_map=False,
        plot_signal_to_noise_map=False,
        plot_model_image=True,
        plot_chi_squared_map=True,
        plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")),
    )

    assert plot_path + "image.png" in plot_patch.paths

    assert plot_path + "noise_map.png" not in plot_patch.paths

    assert plot_path + "signal_to_noise_map.png" not in plot_patch.paths

    assert plot_path + "model_image.png" in plot_patch.paths

    assert plot_path + "residual_map.png" not in plot_patch.paths

    assert plot_path + "normalized_residual_map.png" not in plot_patch.paths

    assert plot_path + "chi_squared_map.png" in plot_patch.paths
示例#16
0
def test__individual_attributes_are_output(interferometer_7, plot_path,
                                           plot_patch):

    aplt.interferometer.visibilities(
        interferometer=interferometer_7,
        plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")),
    )

    assert plot_path + "visibilities.png" in plot_patch.paths

    aplt.interferometer.noise_map(
        interferometer=interferometer_7,
        plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")),
    )

    assert plot_path + "noise_map.png" in plot_patch.paths

    aplt.interferometer.u_wavelengths(
        interferometer=interferometer_7,
        plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")),
    )

    assert plot_path + "u_wavelengths.png" in plot_patch.paths

    aplt.interferometer.v_wavelengths(
        interferometer=interferometer_7,
        plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")),
    )

    assert plot_path + "v_wavelengths.png" in plot_patch.paths

    aplt.interferometer.uv_wavelengths(
        interferometer=interferometer_7,
        plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")),
    )

    assert plot_path + "uv_wavelengths.png" in plot_patch.paths

    aplt.interferometer.amplitudes_vs_uv_distances(
        interferometer=interferometer_7,
        plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")),
    )

    assert plot_path + "amplitudes_vs_uv_distances.png" in plot_patch.paths

    aplt.interferometer.phases_vs_uv_distances(
        interferometer=interferometer_7,
        plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")),
    )

    assert plot_path + "phases_vs_uv_distances.png" in plot_patch.paths

    aplt.interferometer.primary_beam(
        interferometer=interferometer_7,
        plotter=aplt.Plotter(output=aplt.Output(plot_path, format="png")),
    )

    assert plot_path + "primary_beam.png" in plot_patch.paths
示例#17
0
def test__fit_individuals__dependent_on_input(fit_interferometer_7, plot_path,
                                              plot_patch):

    aplt.fit_interferometer.individuals(
        fit=fit_interferometer_7,
        plot_visibilities=True,
        plot_noise_map=False,
        plot_signal_to_noise_map=False,
        plot_model_visibilities=True,
        plot_chi_squared_map=True,
        plotter=aplt.Plotter(output=aplt.Output(plot_path, format="png")),
    )

    assert plot_path + "visibilities.png" in plot_patch.paths

    assert plot_path + "noise_map.png" not in plot_patch.paths

    assert plot_path + "signal_to_noise_map.png" not in plot_patch.paths

    assert plot_path + "model_visibilities.png" in plot_patch.paths

    assert plot_path + "residual_map_vs_uv_distances_real.png" not in plot_patch.paths

    assert plot_path + "residual_map_vs_uv_distances_imag.png" not in plot_patch.paths

    assert (plot_path + "normalized_residual_map_vs_uv_distances_real.png"
            not in plot_patch.paths)

    assert (plot_path + "normalized_residual_map_vs_uv_distances_imag.png"
            not in plot_patch.paths)

    assert plot_path + "chi_squared_map_vs_uv_distances_real.png" in plot_patch.paths

    assert plot_path + "chi_squared_map_vs_uv_distances_imag.png" in plot_patch.paths
示例#18
0
    def test__plotter_with_new_outputs__new_outputs_are_setup_correctly_if_input(
            self):

        plotter = aplt.Plotter(
            output=aplt.Output(path="Path", format="png", filename="file"))

        plotter = plotter.plotter_with_new_output()

        assert plotter.output.path == "Path"
        assert plotter.output._format == "png"
        assert plotter.output.format == "png"
        assert plotter.output.filename == "file"

        plotter = plotter.plotter_with_new_output(path="Path0",
                                                  filename="file0")

        assert plotter.output.path == "Path0"
        assert plotter.output._format == "png"
        assert plotter.output.format == "png"
        assert plotter.output.filename == "file0"

        plotter = plotter.plotter_with_new_output(path="Path1",
                                                  filename="file1",
                                                  format="fits")

        assert plotter.output.path == "Path1"
        assert plotter.output._format == "fits"
        assert plotter.output.format == "fits"
        assert plotter.output.filename == "file1"
示例#19
0
    def test__plot_voronoi_mapper__works_with_all_extras_included(
            self, voronoi_mapper_9_3x3, plot_path, plot_patch):

        plotter = aplt.Plotter(output=aplt.Output(
            path=plot_path, filename="mapper1", format="png"))

        plotter.plot_voronoi_mapper(
            mapper=voronoi_mapper_9_3x3,
            include_pixelization_grid=True,
            include_grid=True,
            include_border=True,
            image_pixel_indexes=[[(0, 0), (0, 1)], [(1, 2)]],
            source_pixel_indexes=[[0, 1], [2]],
        )

        assert plot_path + "mapper1.png" in plot_patch.paths

        plotter = aplt.Plotter(output=aplt.Output(
            path=plot_path, filename="mapper2", format="png"))

        plotter.plot_voronoi_mapper(
            mapper=voronoi_mapper_9_3x3,
            include_pixelization_grid=True,
            include_grid=True,
            include_border=True,
            image_pixel_indexes=[[(0, 0), (0, 1)], [(1, 2)]],
            source_pixel_indexes=[[0, 1], [2]],
        )

        assert plot_path + "mapper2.png" in plot_patch.paths

        aplt.mapper_obj(
            mapper=voronoi_mapper_9_3x3,
            include=aplt.Include(
                inversion_pixelization_grid=True,
                inversion_grid=True,
                inversion_border=True,
            ),
            image_pixel_indexes=[[(0, 0), (0, 1)], [(1, 2)]],
            source_pixel_indexes=[[0, 1], [2]],
            plotter=aplt.Plotter(output=aplt.Output(
                path=plot_path, filename="mapper3", format="png")),
        )

        assert plot_path + "mapper3.png" in plot_patch.paths
示例#20
0
    def test__plot_grid__works_with_all_extras_included(
            self, plot_path, plot_patch):
        grid = aa.grid.uniform(shape_2d=(11, 11), pixel_scales=1.0)
        color_array = np.linspace(start=0.0, stop=1.0, num=grid.shape_1d)

        plotter = aplt.Plotter(
            output=aplt.Output(path=plot_path, filename="grid1", format="png"))

        plotter.plot_grid(
            grid=grid,
            color_array=color_array,
            axis_limits=[-1.5, 1.5, -2.5, 2.5],
            lines=[[(1.0, 1.0), (2.0, 2.0)], [(2.0, 4.0), (5.0, 6.0)]],
            indexes=[0, 1, 2, 14],
            symmetric_around_centre=False,
        )

        assert plot_path + "grid1.png" in plot_patch.paths

        plotter = aplt.Plotter(
            output=aplt.Output(path=plot_path, filename="grid2", format="png"))

        plotter.plot_grid(
            grid=grid,
            color_array=color_array,
            axis_limits=[-1.5, 1.5, -2.5, 2.5],
            lines=[[(1.0, 1.0), (2.0, 2.0)], [(2.0, 4.0), (5.0, 6.0)]],
            indexes=[0, 1, 2, 14],
            symmetric_around_centre=True,
        )

        assert plot_path + "grid2.png" in plot_patch.paths

        aplt.grid(
            grid=grid,
            color_array=color_array,
            axis_limits=[-1.5, 1.5, -2.5, 2.5],
            lines=[[(1.0, 1.0), (2.0, 2.0)], [(2.0, 4.0), (5.0, 6.0)]],
            indexes=[0, 1, 2, 14],
            symmetric_around_centre=True,
            plotter=aplt.Plotter(output=aplt.Output(
                path=plot_path, filename="grid3", format="png")),
        )

        assert plot_path + "grid3.png" in plot_patch.paths
示例#21
0
    def test__colormap__from_config_or_via_manual_input(self):
        plotter = aplt.Plotter()

        assert plotter.cmap.cmap == "jet"
        assert plotter.cmap.norm == "linear"
        assert plotter.cmap.norm_min == None
        assert plotter.cmap.norm_max == None
        assert plotter.cmap.linthresh == 1.0
        assert plotter.cmap.linscale == 2.0

        plotter = aplt.Plotter(cmap=aplt.ColorMap(
            cmap="cold",
            norm="log",
            norm_min=0.1,
            norm_max=1.0,
            linthresh=1.5,
            linscale=2.0,
        ))

        assert plotter.cmap.cmap == "cold"
        assert plotter.cmap.norm == "log"
        assert plotter.cmap.norm_min == 0.1
        assert plotter.cmap.norm_max == 1.0
        assert plotter.cmap.linthresh == 1.5
        assert plotter.cmap.linscale == 2.0

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.cmap.cmap == "jet"
        assert sub_plotter.cmap.norm == "linear"
        assert sub_plotter.cmap.norm_min == None
        assert sub_plotter.cmap.norm_max == None
        assert sub_plotter.cmap.linthresh == 1.0
        assert sub_plotter.cmap.linscale == 2.0

        sub_plotter = aplt.SubPlotter(cmap=aplt.ColorMap.sub(
            cmap="cold", norm="log", norm_min=0.1, norm_max=1.0, linscale=2.0))

        assert sub_plotter.cmap.cmap == "cold"
        assert sub_plotter.cmap.norm == "log"
        assert sub_plotter.cmap.norm_min == 0.1
        assert sub_plotter.cmap.norm_max == 1.0
        assert sub_plotter.cmap.linthresh == 1.0
        assert sub_plotter.cmap.linscale == 2.0
示例#22
0
    def test__labels__from_config_or_via_manual_input(self):

        plotter = aplt.Plotter()

        assert plotter.labels.title == None
        assert plotter.labels._yunits == None
        assert plotter.labels._xunits == None
        assert plotter.labels.titlesize == 11
        assert plotter.labels.ysize == 12
        assert plotter.labels.xsize == 13

        plotter = aplt.Plotter(labels=aplt.Labels(title="OMG",
                                                  yunits="hi",
                                                  xunits="hi2",
                                                  titlesize=1,
                                                  ysize=2,
                                                  xsize=3))

        assert plotter.labels.title == "OMG"
        assert plotter.labels._yunits == "hi"
        assert plotter.labels._xunits == "hi2"
        assert plotter.labels.titlesize == 1
        assert plotter.labels.ysize == 2
        assert plotter.labels.xsize == 3

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.labels.title == None
        assert sub_plotter.labels._yunits == None
        assert sub_plotter.labels._xunits == None
        assert sub_plotter.labels.titlesize == 15
        assert sub_plotter.labels.ysize == 22
        assert sub_plotter.labels.xsize == 23

        sub_plotter = aplt.SubPlotter(labels=aplt.Labels.sub(
            title="OMG", yunits="hi", xunits="hi2", ysize=2, xsize=3))

        assert sub_plotter.labels.title == "OMG"
        assert sub_plotter.labels._yunits == "hi"
        assert sub_plotter.labels._xunits == "hi2"
        assert sub_plotter.labels.titlesize == 15
        assert sub_plotter.labels.ysize == 2
        assert sub_plotter.labels.xsize == 3
示例#23
0
    def test__plot_line__works_with_all_extras_included(
            self, plot_path, plot_patch):

        plotter = aplt.Plotter(
            output=aplt.Output(path=plot_path, filename="line1", format="png"))

        plotter.plot_line(
            y=np.array([1.0, 2.0, 3.0]),
            x=np.array([0.5, 1.0, 1.5]),
            plot_axis_type="loglog",
            vertical_lines=[1.0, 2.0],
            label="line0",
            vertical_line_labels=["line1", "line2"],
        )

        assert plot_path + "line1.png" in plot_patch.paths

        plotter = aplt.Plotter(
            output=aplt.Output(path=plot_path, filename="line2", format="png"))

        plotter.plot_line(
            y=np.array([1.0, 2.0, 3.0]),
            x=np.array([0.5, 1.0, 1.5]),
            plot_axis_type="semilogy",
            vertical_lines=[1.0, 2.0],
            label="line0",
            vertical_line_labels=["line1", "line2"],
        )

        assert plot_path + "line2.png" in plot_patch.paths

        aplt.line(
            y=np.array([1.0, 2.0, 3.0]),
            x=np.array([0.5, 1.0, 1.5]),
            plot_axis_type="loglog",
            vertical_lines=[1.0, 2.0],
            label="line0",
            vertical_line_labels=["line1", "line2"],
            plotter=aplt.Plotter(output=aplt.Output(
                path=plot_path, filename="line3", format="png")),
        )

        assert plot_path + "line3.png" in plot_patch.paths
def test__fit_quantities_are_output(fit_imaging_7x7, plot_path, plot_patch):

    aplt.fit_imaging.image(
        fit=fit_imaging_7x7,
        include=aplt.Include(mask=True),
        plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")),
    )

    assert plot_path + "image.png" in plot_patch.paths

    aplt.fit_imaging.noise_map(
        fit=fit_imaging_7x7,
        include=aplt.Include(mask=True),
        plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")),
    )

    assert plot_path + "noise_map.png" in plot_patch.paths

    aplt.fit_imaging.signal_to_noise_map(
        fit=fit_imaging_7x7,
        include=aplt.Include(mask=True),
        plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")),
    )

    assert plot_path + "signal_to_noise_map.png" in plot_patch.paths

    aplt.fit_imaging.model_image(
        fit=fit_imaging_7x7,
        include=aplt.Include(mask=True),
        plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")),
    )

    assert plot_path + "model_image.png" in plot_patch.paths

    aplt.fit_imaging.residual_map(
        fit=fit_imaging_7x7,
        include=aplt.Include(mask=True),
        plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")),
    )

    assert plot_path + "residual_map.png" in plot_patch.paths

    aplt.fit_imaging.normalized_residual_map(
        fit=fit_imaging_7x7,
        include=aplt.Include(mask=True),
        plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")),
    )

    assert plot_path + "normalized_residual_map.png" in plot_patch.paths

    aplt.fit_imaging.chi_squared_map(
        fit=fit_imaging_7x7,
        include=aplt.Include(mask=True),
        plotter=aplt.Plotter(output=aplt.Output(path=plot_path, format="png")),
    )

    assert plot_path + "chi_squared_map.png" in plot_patch.paths
示例#25
0
    def test__legend__from_config_or_via_manual_input(self):

        plotter = aplt.Plotter()

        assert plotter.legend.include == True
        assert plotter.legend.fontsize == 12

        plotter = aplt.Plotter(legend=aplt.Legend(include=False, fontsize=11))

        assert plotter.legend.include == False
        assert plotter.legend.fontsize == 11

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.legend.include == False
        assert sub_plotter.legend.fontsize == 13

        sub_plotter = aplt.SubPlotter(legend=aplt.Legend.sub(include=True))

        assert sub_plotter.legend.include == True
        assert sub_plotter.legend.fontsize == 13
示例#26
0
    def test__figure__from_config_or_via_manual_input(self):

        plotter = aplt.Plotter()

        assert plotter.figure.figsize == (7, 7)
        assert plotter.figure.aspect == "auto"

        plotter = aplt.Plotter(figure=aplt.Figure(aspect="auto"))

        assert plotter.figure.figsize == (7, 7)
        assert plotter.figure.aspect == "auto"

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.figure.figsize == None
        assert sub_plotter.figure.aspect == "square"

        sub_plotter = aplt.SubPlotter(figure=aplt.Figure.sub(figsize=(6, 6)))

        assert sub_plotter.figure.figsize == (6, 6)
        assert sub_plotter.figure.aspect == "square"
示例#27
0
    def test__colorbar__from_config_or_via_manual_input(self):

        plotter = aplt.Plotter()

        assert plotter.cb.ticksize == 1
        assert plotter.cb.fraction == 3.0
        assert plotter.cb.pad == 4.0
        assert plotter.cb.tick_values == None
        assert plotter.cb.tick_labels == None

        plotter = aplt.Plotter(cb=aplt.ColorBar(
            ticksize=20,
            fraction=0.001,
            pad=10.0,
            tick_values=(1.0, 2.0),
            tick_labels=(3.0, 4.0),
        ))

        assert plotter.cb.ticksize == 20
        assert plotter.cb.fraction == 0.001
        assert plotter.cb.pad == 10.0
        assert plotter.cb.tick_values == (1.0, 2.0)
        assert plotter.cb.tick_labels == (3.0, 4.0)

        sub_plotter = aplt.SubPlotter()

        assert sub_plotter.cb.ticksize == 1
        assert sub_plotter.cb.fraction == 3.0
        assert sub_plotter.cb.pad == 4.0

        sub_plotter = aplt.SubPlotter(
            cb=aplt.ColorBar.sub(fraction=0.001, pad=10.0))

        assert sub_plotter.cb.ticksize == 1
        assert sub_plotter.cb.fraction == 0.001
        assert sub_plotter.cb.pad == 10.0
def test__output_as_fits__correct_output_format(fit_imaging_7x7, positions_7x7,
                                                mask_7x7, plot_path,
                                                plot_patch):

    aplt.fit_imaging.individuals(
        fit=fit_imaging_7x7,
        include=aplt.Include(mask=True),
        plot_image=True,
        plotter=aplt.Plotter(
            output=aplt.Output(path=plot_path, format="fits")),
    )

    image_from_plot = aa.util.array.numpy_array_2d_from_fits(
        file_path=plot_path + "image.fits", hdu=0)

    assert image_from_plot.shape == (5, 5)
示例#29
0
def test__output_as_fits__correct_output_format(imaging_7x7, positions_7x7,
                                                mask_7x7, plot_path,
                                                plot_patch):

    aplt.imaging.individual(
        imaging=imaging_7x7,
        plot_image=True,
        plot_psf=True,
        plot_absolute_signal_to_noise_map=True,
        plotter=aplt.Plotter(
            output=aplt.Output(path=plot_path, format="fits")),
    )

    image_from_plot = aa.util.array.numpy_array_2d_from_fits(
        file_path=plot_path + "image.fits", hdu=0)

    assert image_from_plot.shape == (7, 7)
示例#30
0
    def test__plotter_with_new_cmap__new_labels_if_input__sizes_dont_change(
            self):

        plotter = aplt.Plotter(cmap=aplt.ColorMap(
            cmap="cold",
            norm="log",
            norm_min=0.1,
            norm_max=1.0,
            linthresh=1.5,
            linscale=2.0,
        ))

        assert plotter.cmap.cmap == "cold"
        assert plotter.cmap.norm == "log"
        assert plotter.cmap.norm_min == 0.1
        assert plotter.cmap.norm_max == 1.0
        assert plotter.cmap.linthresh == 1.5
        assert plotter.cmap.linscale == 2.0

        plotter = plotter.plotter_with_new_cmap(
            cmap="jet",
            norm="linear",
            norm_min=0.12,
            norm_max=1.2,
            linthresh=1.2,
            linscale=2.2,
        )

        assert plotter.cmap.cmap == "jet"
        assert plotter.cmap.norm == "linear"
        assert plotter.cmap.norm_min == 0.12
        assert plotter.cmap.norm_max == 1.2
        assert plotter.cmap.linthresh == 1.2
        assert plotter.cmap.linscale == 2.2

        plotter = plotter.plotter_with_new_cmap(cmap="sand",
                                                norm="log",
                                                norm_min=0.13)

        assert plotter.cmap.cmap == "sand"
        assert plotter.cmap.norm == "log"
        assert plotter.cmap.norm_min == 0.13
        assert plotter.cmap.norm_max == 1.2
        assert plotter.cmap.linthresh == 1.2
        assert plotter.cmap.linscale == 2.2