예제 #1
0
def test__2d__via_light_obj_from(lp_0, grid_2d_7x7):

    visuals_2d = aplt.Visuals2D(vectors=2)
    include_2d = aplt.Include2D(origin=True,
                                mask=True,
                                border=True,
                                light_profile_centres=True)

    get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d)

    visuals_2d_via = get_visuals.via_light_obj_from(light_obj=lp_0,
                                                    grid=grid_2d_7x7)

    assert visuals_2d_via.origin.in_list == [(0.0, 0.0)]
    assert (visuals_2d_via.mask == grid_2d_7x7.mask).all()
    assert (visuals_2d_via.border == grid_2d_7x7.mask.border_grid_sub_1.binned
            ).all()
    assert visuals_2d_via.light_profile_centres.in_list == [lp_0.centre]
    assert visuals_2d_via.vectors == 2

    include_2d = aplt.Include2D(origin=False,
                                mask=False,
                                border=False,
                                light_profile_centres=False)

    get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d)

    visuals_2d_via = get_visuals.via_light_obj_from(light_obj=lp_0,
                                                    grid=grid_2d_7x7)

    assert visuals_2d_via.origin is None
    assert visuals_2d_via.mask is None
    assert visuals_2d_via.border is None
    assert visuals_2d_via.light_profile_centres is None
    assert visuals_2d_via.vectors == 2
예제 #2
0
def test__2d__via_light_mass_obj(gal_x1_lp_x1_mp, grid_2d_7x7):

    visuals_2d = aplt.Visuals2D(vectors=2)
    include_2d = aplt.Include2D(
        origin=True,
        mask=True,
        border=True,
        light_profile_centres=True,
        mass_profile_centres=True,
        critical_curves=True,
    )

    get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d)

    visuals_2d_via = get_visuals.via_light_mass_obj_from(
        light_mass_obj=gal_x1_lp_x1_mp, grid=grid_2d_7x7)

    assert visuals_2d_via.origin.in_list == [(0.0, 0.0)]
    assert (visuals_2d_via.mask == grid_2d_7x7.mask).all()
    assert (visuals_2d_via.border == grid_2d_7x7.mask.border_grid_sub_1.binned
            ).all()
    assert visuals_2d_via.light_profile_centres.in_list == [
        gal_x1_lp_x1_mp.light_profile_0.centre
    ]
    assert visuals_2d_via.mass_profile_centres.in_list == [
        gal_x1_lp_x1_mp.mass_profile_0.centre
    ]
    assert (visuals_2d_via.critical_curves[0] ==
            gal_x1_lp_x1_mp.critical_curves_from(grid=grid_2d_7x7)[0]).all()
    assert visuals_2d_via.vectors == 2

    include_2d = aplt.Include2D(
        origin=False,
        mask=False,
        border=False,
        light_profile_centres=False,
        mass_profile_centres=False,
        critical_curves=False,
    )

    get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d)

    visuals_2d_via = get_visuals.via_light_mass_obj_from(
        light_mass_obj=gal_x1_lp_x1_mp, grid=grid_2d_7x7)

    assert visuals_2d_via.origin is None
    assert visuals_2d_via.mask is None
    assert visuals_2d_via.border is None
    assert visuals_2d_via.light_profile_centres is None
    assert visuals_2d_via.mass_profile_centres is None
    assert visuals_2d_via.critical_curves is None
    assert visuals_2d_via.vectors == 2
예제 #3
0
def test__via_fit_imaging_from(fit_imaging_x2_galaxy_7x7, grid_2d_7x7):

    visuals_2d = aplt.Visuals2D(origin=(1.0, 1.0), vectors=2)
    include_2d = aplt.Include2D(
        origin=True,
        mask=True,
        border=True,
        light_profile_centres=True,
        mass_profile_centres=True,
        critical_curves=True,
    )

    get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d)

    visuals_2d_via = get_visuals.via_fit_imaging_from(
        fit=fit_imaging_x2_galaxy_7x7)

    assert visuals_2d_via.origin == (1.0, 1.0)
    assert (visuals_2d_via.mask == fit_imaging_x2_galaxy_7x7.mask).all()
    assert (visuals_2d_via.border ==
            fit_imaging_x2_galaxy_7x7.mask.border_grid_sub_1.binned).all()
    assert visuals_2d_via.light_profile_centres.in_list == [(0.0, 0.0),
                                                            (0.0, 0.0)]
    assert visuals_2d_via.mass_profile_centres.in_list == [(0.0, 0.0)]
    assert (visuals_2d_via.critical_curves[0] == fit_imaging_x2_galaxy_7x7.
            plane.critical_curves_from(grid=grid_2d_7x7)[0]).all()
    assert visuals_2d_via.vectors == 2

    include_2d = aplt.Include2D(
        origin=False,
        mask=False,
        border=False,
        light_profile_centres=False,
        mass_profile_centres=False,
        critical_curves=False,
    )

    get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d)

    visuals_2d_via = get_visuals.via_fit_imaging_from(
        fit=fit_imaging_x2_galaxy_7x7)

    assert visuals_2d_via.origin == (1.0, 1.0)
    assert visuals_2d_via.mask is None
    assert visuals_2d_via.border is None
    assert visuals_2d_via.light_profile_centres is None
    assert visuals_2d_via.mass_profile_centres is None
    assert visuals_2d_via.critical_curves is None
    assert visuals_2d_via.vectors == 2
예제 #4
0
def test__visuals_with_include_2d(gal_x1_lp_x1_mp, grid_2d_7x7):

    visuals_2d = aplt.Visuals2D(vector_field=2)

    include = aplt.Include2D(
        origin=True,
        mask=True,
        border=True,
        light_profile_centres=True,
        mass_profile_centres=True,
        critical_curves=True,
        caustics=True,
    )

    galaxy_plotter = aplt.GalaxyPlotter(
        galaxy=gal_x1_lp_x1_mp,
        grid=grid_2d_7x7,
        visuals_2d=visuals_2d,
        include_2d=include,
    )

    assert galaxy_plotter.visuals_with_include_2d.origin.in_list == [(0.0, 0.0)
                                                                     ]
    assert (
        galaxy_plotter.visuals_with_include_2d.mask == grid_2d_7x7.mask).all()
    assert (galaxy_plotter.visuals_with_include_2d.border ==
            grid_2d_7x7.mask.border_grid_sub_1.binned).all()
    assert galaxy_plotter.visuals_with_include_2d.light_profile_centres.in_list == [
        gal_x1_lp_x1_mp.light_profile_0.centre
    ]
    assert galaxy_plotter.visuals_with_include_2d.mass_profile_centres.in_list == [
        gal_x1_lp_x1_mp.mass_profile_0.centre
    ]
    assert galaxy_plotter.visuals_with_include_2d.vector_field == 2

    include = aplt.Include2D(origin=False, mask=False, border=False)

    galaxy_plotter = aplt.GalaxyPlotter(
        galaxy=gal_x1_lp_x1_mp,
        grid=grid_2d_7x7,
        visuals_2d=visuals_2d,
        include_2d=include,
    )

    assert galaxy_plotter.visuals_with_include_2d.origin == None
    assert galaxy_plotter.visuals_with_include_2d.mask == None
    assert galaxy_plotter.visuals_with_include_2d.border == None
    assert galaxy_plotter.visuals_with_include_2d.vector_field == 2
예제 #5
0
def test__visuals_with_include_2d(lp_0, grid_2d_7x7):

    visuals_2d = aplt.Visuals2D(vector_field=2)

    include = aplt.Include2D(
        origin=True,
        mask=True,
        border=True,
        light_profile_centres=True,
        critical_curves=True,
        caustics=True,
    )

    light_profile_plotter = aplt.LightProfilePlotter(
        light_profile=lp_0, grid=grid_2d_7x7, visuals_2d=visuals_2d, include_2d=include
    )

    assert light_profile_plotter.visuals_with_include_2d.origin.in_list == [(0.0, 0.0)]
    assert (
        light_profile_plotter.visuals_with_include_2d.mask == grid_2d_7x7.mask
    ).all()
    assert (
        light_profile_plotter.visuals_with_include_2d.border
        == grid_2d_7x7.mask.border_grid_sub_1.binned
    ).all()
    assert (
        light_profile_plotter.visuals_with_include_2d.light_profile_centres.in_list
        == [lp_0.centre]
    )
    assert light_profile_plotter.visuals_with_include_2d.vector_field == 2

    include = aplt.Include2D(origin=False, mask=False, border=False)

    light_profile_plotter = aplt.LightProfilePlotter(
        light_profile=lp_0, grid=grid_2d_7x7, visuals_2d=visuals_2d, include_2d=include
    )

    assert light_profile_plotter.visuals_with_include_2d.origin == None
    assert light_profile_plotter.visuals_with_include_2d.mask == None
    assert light_profile_plotter.visuals_with_include_2d.border == None
    assert light_profile_plotter.visuals_with_include_2d.vector_field == 2
예제 #6
0
    def __init__(
            self,
            fit: FitImaging,
            mat_plot_2d: aplt.MatPlot2D = aplt.MatPlot2D(),
            visuals_2d: aplt.Visuals2D = aplt.Visuals2D(),
            include_2d: aplt.Include2D = aplt.Include2D(),
    ):
        """
        Plots the attributes of `FitImaging` objects using the matplotlib method `imshow()` and many other matplotlib
        functions which customize the plot's appearance.

        The `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 `MatPlot2d` to customize the figure's appearance.

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

        Parameters
        ----------
        fit
            The fit to an imaging dataset the plotter plots.
        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.
        """
        super().__init__(mat_plot_2d=mat_plot_2d,
                         include_2d=include_2d,
                         visuals_2d=visuals_2d)

        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,
        )

        self.figures_2d = self._fit_imaging_meta_plotter.figures_2d
        self.subplot = self._fit_imaging_meta_plotter.subplot
        self.subplot_fit_imaging = self._fit_imaging_meta_plotter.subplot_fit_imaging
예제 #7
0
    def __init__(
            self,
            subhalo_result: SubhaloResult,
            fit_imaging_detect,
            use_log_evidences: bool = True,
            use_stochastic_log_likelihoods: bool = False,
            mat_plot_2d: aplt.MatPlot2D = aplt.MatPlot2D(),
            visuals_2d: aplt.Visuals2D = aplt.Visuals2D(),
            include_2d: aplt.Include2D = aplt.Include2D(),
    ):
        super().__init__(mat_plot_2d=mat_plot_2d,
                         include_2d=include_2d,
                         visuals_2d=visuals_2d)

        self.subhalo_result = subhalo_result
        self.fit_imaging_detect = fit_imaging_detect
        self.use_log_evidences = use_log_evidences
        self.use_stochastic_log_likelihoods = use_stochastic_log_likelihoods
예제 #8
0
    def __init__(
            self,
            fit: FitPointDataset,
            mat_plot_1d: aplt.MatPlot1D = aplt.MatPlot1D(),
            visuals_1d: aplt.Visuals1D = aplt.Visuals1D(),
            include_1d: aplt.Include1D = aplt.Include1D(),
            mat_plot_2d: aplt.MatPlot2D = aplt.MatPlot2D(),
            visuals_2d: aplt.Visuals2D = aplt.Visuals2D(),
            include_2d: aplt.Include2D = aplt.Include2D(),
    ):
        super().__init__(
            mat_plot_1d=mat_plot_1d,
            visuals_1d=visuals_1d,
            include_1d=include_1d,
            mat_plot_2d=mat_plot_2d,
            include_2d=include_2d,
            visuals_2d=visuals_2d,
        )

        self.fit = fit
예제 #9
0
    def __init__(
            self,
            point_dict: PointDict,
            mat_plot_1d: aplt.MatPlot1D = aplt.MatPlot1D(),
            visuals_1d: aplt.Visuals1D = aplt.Visuals1D(),
            include_1d: aplt.Include1D = aplt.Include1D(),
            mat_plot_2d: aplt.MatPlot2D = aplt.MatPlot2D(),
            visuals_2d: aplt.Visuals2D = aplt.Visuals2D(),
            include_2d: aplt.Include2D = aplt.Include2D(),
    ):
        super().__init__(
            mat_plot_1d=mat_plot_1d,
            visuals_1d=visuals_1d,
            include_1d=include_1d,
            mat_plot_2d=mat_plot_2d,
            include_2d=include_2d,
            visuals_2d=visuals_2d,
        )

        self.point_dict = point_dict
예제 #10
0
    def __init__(
            self,
            tracer: Tracer,
            grid: aa.type.Grid2DLike,
            mat_plot_1d: aplt.MatPlot1D = aplt.MatPlot1D(),
            visuals_1d: aplt.Visuals1D = aplt.Visuals1D(),
            include_1d: aplt.Include1D = aplt.Include1D(),
            mat_plot_2d: aplt.MatPlot2D = aplt.MatPlot2D(),
            visuals_2d: aplt.Visuals2D = aplt.Visuals2D(),
            include_2d: aplt.Include2D = aplt.Include2D(),
    ):
        """
        Plots the attributes of `Tracer` objects using the matplotlib methods `plot()` and `imshow()` and many 
        other matplotlib functions which customize the plot's appearance.

        The `mat_plot_1d` and `mat_plot_2d` attributes wrap 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 `MatPlot2D` to 
        customize the figure's appearance.

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

        Parameters
        ----------
        tracer
            The tracer the plotter plots.
        grid
            The 2D (y,x) grid of coordinates used to evaluate the tracer's light and mass quantities that are plotted.
        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 `MassProfile` are extracted and plotted as visuals for 1D plots.
        mat_plot_2d
            Contains objects which wrap the matplotlib function calls that make 2D plots.
        visuals_2d
            Contains 2D visuals that can be overlaid on 2D plots.
        include_2d
            Specifies which attributes of the `MassProfile` are extracted and plotted as visuals for 2D plots.
        """
        super().__init__(
            mat_plot_1d=mat_plot_1d,
            visuals_1d=visuals_1d,
            include_1d=include_1d,
            mat_plot_2d=mat_plot_2d,
            include_2d=include_2d,
            visuals_2d=visuals_2d,
        )

        self.tracer = tracer
        self.grid = grid

        self._mass_plotter = MassPlotter(
            mass_obj=self.tracer,
            grid=self.grid,
            get_visuals_2d=self.get_visuals_2d,
            mat_plot_2d=self.mat_plot_2d,
            include_2d=self.include_2d,
            visuals_2d=self.visuals_2d,
        )