From 57ff70d9629e676a7b41d93479eace2a4b56d2db Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 14 Jul 2025 21:39:41 +0100 Subject: [PATCH 1/4] all tests pass after removing Include --- autogalaxy/analysis/plotter_interface.py | 10 +- autogalaxy/config/visualize/include.yaml | 11 -- autogalaxy/ellipse/model/plotter_interface.py | 6 +- .../ellipse/plot/fit_ellipse_plotters.py | 6 - autogalaxy/fixtures.py | 22 --- autogalaxy/galaxy/plot/adapt_plotters.py | 6 +- autogalaxy/galaxy/plot/galaxies_plotters.py | 15 +- autogalaxy/galaxy/plot/galaxy_plotters.py | 35 +--- autogalaxy/imaging/model/plotter_interface.py | 12 +- .../imaging/plot/fit_imaging_plotters.py | 13 +- .../interferometer/model/plotter_interface.py | 2 - .../plot/fit_interferometer_plotters.py | 17 +- autogalaxy/operate/deflections.py | 1 + autogalaxy/plot/__init__.py | 2 - autogalaxy/plot/abstract_plotters.py | 12 +- autogalaxy/plot/get_visuals/one_d.py | 96 ++++------ autogalaxy/plot/get_visuals/two_d.py | 20 +- autogalaxy/plot/include/__init__.py | 0 autogalaxy/plot/include/one_d.py | 34 ---- autogalaxy/plot/include/two_d.py | 80 -------- autogalaxy/plot/mass_plotter.py | 6 +- autogalaxy/profiles/mass/total/power_law.py | 6 +- .../profiles/mass/total/power_law_core.py | 8 +- autogalaxy/profiles/plot/basis_plotters.py | 14 +- .../profiles/plot/light_profile_plotters.py | 24 +-- .../profiles/plot/mass_profile_plotters.py | 25 +-- .../quantity/model/plotter_interface.py | 1 - .../quantity/plot/fit_quantity_plotters.py | 17 +- .../analysis/test_plotter_interface.py | 5 +- test_autogalaxy/config/visualize.yaml | 63 ++----- test_autogalaxy/conftest.py | 10 - .../galaxy/plot/test_adapt_plotters.py | 3 +- .../galaxy/plot/test_galaxies_plotter.py | 10 +- .../galaxy/plot/test_galaxy_plotters.py | 16 +- test_autogalaxy/galaxy/test_galaxies.py | 4 +- test_autogalaxy/galaxy/test_galaxy.py | 18 +- .../model/test_plotter_interface_imaging.py | 3 +- .../imaging/plot/test_fit_imaging_plotters.py | 13 +- .../test_plotter_interface_interferometer.py | 3 +- .../plot/test_fit_interferometer_plotters.py | 3 - .../mat_wrap/config/visualize/include.ini | 16 -- .../plot/mat_wrap/test_get_visuals.py | 171 +----------------- test_autogalaxy/plot/mat_wrap/test_mat_obj.py | 8 +- .../profiles/mass/abstract/test_abstract.py | 24 +-- .../profiles/mass/total/test_isothermal.py | 16 +- .../mass/total/test_isothermal_cored.py | 4 +- .../profiles/mass/total/test_power_law.py | 4 +- .../mass/total/test_power_law_cored.py | 4 +- .../plot/test_light_profile_plotters.py | 5 - .../plot/test_mass_profile_plotters.py | 5 - test_autogalaxy/profiles/test_basis.py | 4 +- .../model/test_plotter_interface_quantity.py | 2 - .../plot/test_fit_quantity_plotters.py | 4 - 53 files changed, 158 insertions(+), 761 deletions(-) delete mode 100644 autogalaxy/config/visualize/include.yaml delete mode 100644 autogalaxy/plot/include/__init__.py delete mode 100644 autogalaxy/plot/include/one_d.py delete mode 100644 autogalaxy/plot/include/two_d.py delete mode 100644 test_autogalaxy/plot/mat_wrap/config/visualize/include.ini diff --git a/autogalaxy/analysis/plotter_interface.py b/autogalaxy/analysis/plotter_interface.py index c53321af0..b49e492d8 100644 --- a/autogalaxy/analysis/plotter_interface.py +++ b/autogalaxy/analysis/plotter_interface.py @@ -18,7 +18,6 @@ from autogalaxy.galaxy.plot.galaxies_plotters import GalaxiesPlotter from autogalaxy.galaxy.plot.adapt_plotters import AdaptPlotter -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.plot.mat_plot.one_d import MatPlot1D from autogalaxy.plot.mat_plot.two_d import MatPlot2D @@ -70,8 +69,6 @@ def __init__(self, image_path: Union[Path, str], title_prefix: str = None): self.image_path = Path(image_path) self.title_prefix = title_prefix - self.include_2d = Include2D() - os.makedirs(image_path, exist_ok=True) @property @@ -146,7 +143,6 @@ def should_plot(name): galaxies=galaxies, grid=grid, mat_plot_2d=mat_plot_2d, - include_2d=self.include_2d, ) if should_plot("subplot_galaxy_images"): @@ -158,7 +154,6 @@ def should_plot(name): galaxies=galaxies, grid=grid, mat_plot_2d=mat_plot_2d, - include_2d=self.include_2d, ) if should_plot("subplot_galaxies"): @@ -224,7 +219,8 @@ def should_plot(name): mat_plot_2d = self.mat_plot_2d_from() inversion_plotter = aplt.InversionPlotter( - inversion=inversion, mat_plot_2d=mat_plot_2d, include_2d=self.include_2d + inversion=inversion, + mat_plot_2d=mat_plot_2d, ) if should_plot("subplot_inversion"): @@ -291,7 +287,7 @@ def should_plot(name): mat_plot_2d = self.mat_plot_2d_from() adapt_plotter = AdaptPlotter( - mat_plot_2d=mat_plot_2d, include_2d=self.include_2d + mat_plot_2d=mat_plot_2d, ) if should_plot("subplot_adapt_images"): diff --git a/autogalaxy/config/visualize/include.yaml b/autogalaxy/config/visualize/include.yaml deleted file mode 100644 index 54497fe44..000000000 --- a/autogalaxy/config/visualize/include.yaml +++ /dev/null @@ -1,11 +0,0 @@ -include_1d: - einstein_radius: true - half_light_radius: true -include_2d: - tangential_critical_curves: true - tangential_caustics: true - radial_critical_curves: true - radial_caustics: true - light_profile_centres: true - mass_profile_centres: true - multiple_images: true diff --git a/autogalaxy/ellipse/model/plotter_interface.py b/autogalaxy/ellipse/model/plotter_interface.py index 3e5f6a1a9..d50b747ff 100644 --- a/autogalaxy/ellipse/model/plotter_interface.py +++ b/autogalaxy/ellipse/model/plotter_interface.py @@ -38,7 +38,8 @@ def should_plot(name): mat_plot_2d = self.mat_plot_2d_from() dataset_plotter = aplt.ImagingPlotter( - dataset=dataset, mat_plot_2d=mat_plot_2d, include_2d=self.include_2d + dataset=dataset, + mat_plot_2d=mat_plot_2d, ) if should_plot("subplot_dataset"): @@ -90,7 +91,8 @@ def should_plot(name): mat_plot_2d = self.mat_plot_2d_from() fit_plotter = FitEllipsePlotter( - fit_list=fit_list, mat_plot_2d=mat_plot_2d, include_2d=self.include_2d + fit_list=fit_list, + mat_plot_2d=mat_plot_2d, ) try: diff --git a/autogalaxy/ellipse/plot/fit_ellipse_plotters.py b/autogalaxy/ellipse/plot/fit_ellipse_plotters.py index 8ae0f792d..8a968569b 100644 --- a/autogalaxy/ellipse/plot/fit_ellipse_plotters.py +++ b/autogalaxy/ellipse/plot/fit_ellipse_plotters.py @@ -8,10 +8,8 @@ from autogalaxy.plot.abstract_plotters import Plotter from autogalaxy.plot.mat_plot.one_d import MatPlot1D from autogalaxy.plot.visuals.one_d import Visuals1D -from autogalaxy.plot.include.one_d import Include1D from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.two_d import Include2D class FitEllipsePlotter(Plotter): @@ -20,18 +18,14 @@ def __init__( fit_list: List[FitEllipse], mat_plot_1d: MatPlot1D = None, visuals_1d: Visuals1D = None, - include_1d: Include1D = None, mat_plot_2d: MatPlot2D = None, visuals_2d: Visuals2D = None, - include_2d: Include2D = None, ): super().__init__( mat_plot_1d=mat_plot_1d, visuals_1d=visuals_1d, - include_1d=include_1d, mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d, - include_2d=include_2d, ) self.fit_list = fit_list diff --git a/autogalaxy/fixtures.py b/autogalaxy/fixtures.py index 5ead16f63..e9a4c262a 100644 --- a/autogalaxy/fixtures.py +++ b/autogalaxy/fixtures.py @@ -282,25 +282,3 @@ def make_analysis_ellipse_7x7(): dataset=make_masked_imaging_7x7(), ) return analysis - - -def make_include_1d_all(): - return aplt.Include1D(half_light_radius=True) - - -def make_include_2d_all(): - return aplt.Include2D( - origin=True, - mask=True, - border=True, - positions=True, - light_profile_centres=True, - mass_profile_centres=True, - tangential_critical_curves=False, - radial_critical_curves=False, - tangential_caustics=False, - radial_caustics=False, - multiple_images=False, - mapper_source_plane_mesh_grid=True, - mapper_image_plane_mesh_grid=True, - ) diff --git a/autogalaxy/galaxy/plot/adapt_plotters.py b/autogalaxy/galaxy/plot/adapt_plotters.py index 0f2f39d2e..ef173339e 100644 --- a/autogalaxy/galaxy/plot/adapt_plotters.py +++ b/autogalaxy/galaxy/plot/adapt_plotters.py @@ -7,7 +7,6 @@ from autogalaxy.plot.abstract_plotters import Plotter from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.two_d import Include2D class AdaptPlotter(Plotter): @@ -15,11 +14,8 @@ def __init__( self, mat_plot_2d: MatPlot2D = None, visuals_2d: Visuals2D = None, - include_2d: Include2D = None, ): - super().__init__( - mat_plot_2d=mat_plot_2d, include_2d=include_2d, visuals_2d=visuals_2d - ) + super().__init__(mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d) def get_visuals_2d(self) -> Visuals2D: return self.visuals_2d diff --git a/autogalaxy/galaxy/plot/galaxies_plotters.py b/autogalaxy/galaxy/plot/galaxies_plotters.py index 473cb5c8a..dba5f0a83 100644 --- a/autogalaxy/galaxy/plot/galaxies_plotters.py +++ b/autogalaxy/galaxy/plot/galaxies_plotters.py @@ -8,8 +8,6 @@ from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.one_d import Visuals1D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.one_d import Include1D -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.plot.mass_plotter import MassPlotter from autogalaxy.galaxy.galaxy import Galaxy from autogalaxy.galaxy.galaxies import Galaxies @@ -25,10 +23,8 @@ def __init__( grid: aa.type.Grid1D2DLike, mat_plot_1d: MatPlot1D = None, visuals_1d: Visuals1D = None, - include_1d: Include1D = None, mat_plot_2d: MatPlot2D = None, visuals_2d: Visuals2D = None, - include_2d: Include2D = None, ): """ Plots the attributes of a list of galaxies using the matplotlib methods `plot()` and `imshow()` and many @@ -40,8 +36,7 @@ def __init__( 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. + extracted from the `MassProfile` and plotted via the visuals object. Parameters ---------- @@ -53,14 +48,10 @@ def __init__( 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. """ self.galaxies = Galaxies(galaxies=galaxies) @@ -76,10 +67,8 @@ def __init__( super().__init__( mat_plot_2d=mat_plot_2d, - include_2d=include_2d, visuals_2d=visuals_2d, mat_plot_1d=mat_plot_1d, - include_1d=include_1d, visuals_1d=visuals_1d, ) @@ -90,7 +79,6 @@ def __init__( 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, ) @@ -119,7 +107,6 @@ def galaxy_plotter_from(self, galaxy_index: int) -> GalaxyPlotter: grid=self.grid, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.get_visuals_2d_of_galaxy(galaxy_index=galaxy_index), - include_2d=self.include_2d, ) def figures_2d( diff --git a/autogalaxy/galaxy/plot/galaxy_plotters.py b/autogalaxy/galaxy/plot/galaxy_plotters.py index 06926ffca..afd19d5b6 100644 --- a/autogalaxy/galaxy/plot/galaxy_plotters.py +++ b/autogalaxy/galaxy/plot/galaxy_plotters.py @@ -10,8 +10,6 @@ from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.one_d import Visuals1D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.one_d import Include1D -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.plot.mass_plotter import MassPlotter from autogalaxy.profiles.light.abstract import LightProfile @@ -35,10 +33,8 @@ def __init__( grid: aa.type.Grid1D2DLike, mat_plot_1d: MatPlot1D = None, visuals_1d: Visuals1D = None, - include_1d: Include1D = None, mat_plot_2d: MatPlot2D = None, visuals_2d: Visuals2D = None, - include_2d: Include2D = None, ): """ Plots the attributes of `Galaxy` objects using the matplotlib methods `plot()` and `imshow()` and many @@ -50,8 +46,7 @@ def __init__( 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. + extracted from the `MassProfile` and plotted via the visuals object. Parameters ---------- @@ -63,14 +58,10 @@ def __init__( 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. """ from autogalaxy.profiles.light.linear import ( @@ -85,10 +76,8 @@ def __init__( super().__init__( mat_plot_2d=mat_plot_2d, - include_2d=include_2d, visuals_2d=visuals_2d, mat_plot_1d=mat_plot_1d, - include_1d=include_1d, visuals_1d=visuals_1d, ) @@ -100,7 +89,6 @@ def __init__( 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, ) @@ -143,10 +131,8 @@ def light_profile_plotter_from( visuals_2d=self.get_2d.via_light_obj_from( light_obj=light_profile, grid=self.grid ), - include_2d=self.include_2d, mat_plot_1d=self.mat_plot_1d, visuals_1d=self.get_1d.via_light_obj_from(light_obj=light_profile), - include_1d=self.include_1d, ) return LightProfilePlotter( @@ -154,7 +140,6 @@ def light_profile_plotter_from( grid=self.grid, mat_plot_1d=self.mat_plot_1d, visuals_1d=self.get_1d.via_light_obj_from(light_obj=light_profile), - include_1d=self.include_1d, ) def mass_profile_plotter_from( @@ -183,12 +168,10 @@ def mass_profile_plotter_from( visuals_2d=self.get_2d.via_mass_obj_from( mass_obj=mass_profile, grid=self.grid ), - include_2d=self.include_2d, mat_plot_1d=self.mat_plot_1d, visuals_1d=self.get_1d.via_mass_obj_from( mass_obj=mass_profile, grid=self.grid ), - include_1d=self.include_1d, ) return MassProfilePlotter( @@ -198,7 +181,6 @@ def mass_profile_plotter_from( visuals_1d=self.get_1d.via_mass_obj_from( mass_obj=mass_profile, grid=self.grid ), - include_1d=self.include_1d, ) @property @@ -537,10 +519,8 @@ def __init__( grid: aa.Grid2D, mat_plot_1d: MatPlot1D = None, visuals_1d: Visuals1D = None, - include_1d: Include1D = None, mat_plot_2d: MatPlot2D = None, visuals_2d: Visuals2D = None, - include_2d: Include2D = None, sigma: Optional[float] = 3.0, ): """ @@ -558,8 +538,7 @@ def __init__( customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` objects. Attributes may be - extracted from the `GalaxyProfile` 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. + extracted from the `GalaxyProfile` and plotted via the visuals object. Parameters ---------- @@ -571,14 +550,10 @@ def __init__( 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 `GalaxyProfile` 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 `GalaxyProfile` are extracted and plotted as visuals for 2D plots. sigma The confidence interval in terms of a sigma value at which the errors are computed (e.g. a value of sigma=3.0 uses confidence intevals at ~0.01 and 0.99 the PDF). @@ -587,10 +562,8 @@ def __init__( galaxy=None, grid=grid, mat_plot_2d=mat_plot_2d, - include_2d=include_2d, visuals_2d=visuals_2d, mat_plot_1d=mat_plot_1d, - include_1d=include_1d, visuals_1d=visuals_1d, ) @@ -645,10 +618,8 @@ def light_profile_pdf_plotter_from(self, index) -> LightProfilePDFPlotter: grid=self.grid, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.visuals_2d, - include_2d=self.include_2d, mat_plot_1d=self.mat_plot_1d, visuals_1d=self.visuals_1d, - include_1d=self.include_1d, ) @property @@ -693,10 +664,8 @@ def mass_profile_pdf_plotter_from(self, index) -> MassProfilePDFPlotter: grid=self.grid, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.visuals_2d, - include_2d=self.include_2d, mat_plot_1d=self.mat_plot_1d, visuals_1d=self.visuals_1d, - include_1d=self.include_1d, ) def figures_1d( diff --git a/autogalaxy/imaging/model/plotter_interface.py b/autogalaxy/imaging/model/plotter_interface.py index 97b91c42e..00fece1d9 100644 --- a/autogalaxy/imaging/model/plotter_interface.py +++ b/autogalaxy/imaging/model/plotter_interface.py @@ -105,7 +105,8 @@ def should_plot(name): mat_plot_2d = self.mat_plot_2d_from() dataset_plotter = aplt.ImagingPlotter( - dataset=dataset, mat_plot_2d=mat_plot_2d, include_2d=self.include_2d + dataset=dataset, + mat_plot_2d=mat_plot_2d, ) if should_plot("subplot_dataset"): @@ -164,7 +165,8 @@ def should_plot(name): mat_plot_2d = self.mat_plot_2d_from() fit_plotter = FitImagingPlotter( - fit=fit, mat_plot_2d=mat_plot_2d, include_2d=self.include_2d + fit=fit, + mat_plot_2d=mat_plot_2d, ) if should_plot("subplot_fit"): @@ -206,7 +208,8 @@ def should_plot(name): dataset_plotter_list = [ aplt.ImagingPlotter( - dataset=dataset, mat_plot_2d=mat_plot_2d, include_2d=self.include_2d + dataset=dataset, + mat_plot_2d=mat_plot_2d, ) for dataset in dataset_list ] @@ -260,7 +263,8 @@ def should_plot(name): fit_plotter_list = [ FitImagingPlotter( - fit=fit, mat_plot_2d=mat_plot_2d, include_2d=self.include_2d + fit=fit, + mat_plot_2d=mat_plot_2d, ) for fit in fit_list ] diff --git a/autogalaxy/imaging/plot/fit_imaging_plotters.py b/autogalaxy/imaging/plot/fit_imaging_plotters.py index 8c6575a21..94b96fee0 100644 --- a/autogalaxy/imaging/plot/fit_imaging_plotters.py +++ b/autogalaxy/imaging/plot/fit_imaging_plotters.py @@ -11,7 +11,6 @@ from autogalaxy.plot.abstract_plotters import Plotter from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.two_d import Include2D class FitImagingPlotter(Plotter): @@ -20,7 +19,6 @@ def __init__( fit: FitImaging, mat_plot_2d: MatPlot2D = None, visuals_2d: Visuals2D = None, - include_2d: Include2D = None, residuals_symmetric_cmap: bool = True, ): """ @@ -32,8 +30,7 @@ def __init__( 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. + the `FitImaging` and plotted via the visuals object. Parameters ---------- @@ -43,15 +40,11 @@ def __init__( 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 `FitImaging` are extracted and plotted as visuals. residuals_symmetric_cmap If true, the `residual_map` and `normalized_residual_map` are plotted with a symmetric color map such that `abs(vmin) = abs(vmax)`. """ - super().__init__( - mat_plot_2d=mat_plot_2d, include_2d=include_2d, visuals_2d=visuals_2d - ) + super().__init__(mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d) self.fit = fit @@ -59,7 +52,6 @@ def __init__( 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, residuals_symmetric_cmap=residuals_symmetric_cmap, ) @@ -84,7 +76,6 @@ def inversion_plotter(self) -> aplt.InversionPlotter: inversion=self.fit.inversion, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.get_visuals_2d(), - include_2d=self.include_2d, ) @property diff --git a/autogalaxy/interferometer/model/plotter_interface.py b/autogalaxy/interferometer/model/plotter_interface.py index a37096fbc..f27237b31 100644 --- a/autogalaxy/interferometer/model/plotter_interface.py +++ b/autogalaxy/interferometer/model/plotter_interface.py @@ -106,7 +106,6 @@ def should_plot(name): dataset_plotter = aplt.InterferometerPlotter( dataset=dataset, - include_2d=self.include_2d, mat_plot_1d=mat_plot_1d, mat_plot_2d=mat_plot_2d, ) @@ -160,7 +159,6 @@ def should_plot(name): fit_plotter = FitInterferometerPlotter( fit=fit, - include_2d=self.include_2d, mat_plot_1d=mat_plot_1d, mat_plot_2d=mat_plot_2d, ) diff --git a/autogalaxy/interferometer/plot/fit_interferometer_plotters.py b/autogalaxy/interferometer/plot/fit_interferometer_plotters.py index 3c063d31d..a2adf89e8 100644 --- a/autogalaxy/interferometer/plot/fit_interferometer_plotters.py +++ b/autogalaxy/interferometer/plot/fit_interferometer_plotters.py @@ -12,8 +12,6 @@ from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.one_d import Visuals1D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.one_d import Include1D -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.galaxy.plot.galaxies_plotters import GalaxiesPlotter @@ -24,10 +22,8 @@ def __init__( fit: FitInterferometer, mat_plot_1d: MatPlot1D = None, visuals_1d: Visuals1D = None, - include_1d: Include1D = None, mat_plot_2d: MatPlot2D = None, visuals_2d: Visuals2D = None, - include_2d: Include2D = None, residuals_symmetric_cmap: bool = True, ): """ @@ -40,8 +36,7 @@ def __init__( customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` objects. Attributes may be - extracted from the `FitInterferometer` 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. + extracted from the `FitInterferometer` and plotted via the visuals object. Parameters ---------- @@ -51,24 +46,18 @@ def __init__( 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 `FitInterferometer` 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 `FitInterferometer` are extracted and plotted as visuals for 2D plots. residuals_symmetric_cmap If true, the `residual_map` and `normalized_residual_map` are plotted with a symmetric color map such that `abs(vmin) = abs(vmax)`. """ super().__init__( mat_plot_1d=mat_plot_1d, - include_1d=include_1d, visuals_1d=visuals_1d, mat_plot_2d=mat_plot_2d, - include_2d=include_2d, visuals_2d=visuals_2d, ) @@ -78,10 +67,8 @@ def __init__( fit=self.fit, get_visuals_2d_real_space=self.get_visuals_2d_real_space, mat_plot_1d=self.mat_plot_1d, - include_1d=self.include_1d, visuals_1d=self.visuals_1d, mat_plot_2d=self.mat_plot_2d, - include_2d=self.include_2d, visuals_2d=self.visuals_2d, residuals_symmetric_cmap=residuals_symmetric_cmap, ) @@ -114,7 +101,6 @@ def galaxies_plotter_from(self, galaxies: List[Galaxy]) -> GalaxiesPlotter: grid=self.fit.grids.lp, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.get_visuals_2d_real_space(), - include_2d=self.include_2d, ) @property @@ -131,7 +117,6 @@ def inversion_plotter(self) -> aplt.InversionPlotter: inversion=self.fit.inversion, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.get_visuals_2d_real_space(), - include_2d=self.include_2d, ) def subplot_fit(self): diff --git a/autogalaxy/operate/deflections.py b/autogalaxy/operate/deflections.py index 27286bcae..d90498a8a 100644 --- a/autogalaxy/operate/deflections.py +++ b/autogalaxy/operate/deflections.py @@ -441,6 +441,7 @@ def tangential_critical_curve_list_from( If input, the `evaluation_grid` decorator creates the 2D grid at this resolution, therefore enabling the critical curve to be computed more accurately using a higher resolution grid. """ + print("aaaa") tangential_eigen_values = self.tangential_eigen_value_from(grid=grid) return self.contour_list_from(grid=grid, contour_array=tangential_eigen_values) diff --git a/autogalaxy/plot/__init__.py b/autogalaxy/plot/__init__.py index 81623d62f..0a0564b52 100644 --- a/autogalaxy/plot/__init__.py +++ b/autogalaxy/plot/__init__.py @@ -72,8 +72,6 @@ from autogalaxy.plot.mat_plot.one_d import MatPlot1D from autogalaxy.plot.mat_plot.two_d import MatPlot2D -from autogalaxy.plot.include.one_d import Include1D -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.plot.visuals.one_d import Visuals1D from autogalaxy.plot.visuals.two_d import Visuals2D diff --git a/autogalaxy/plot/abstract_plotters.py b/autogalaxy/plot/abstract_plotters.py index 94803bd94..828350c82 100644 --- a/autogalaxy/plot/abstract_plotters.py +++ b/autogalaxy/plot/abstract_plotters.py @@ -8,8 +8,6 @@ from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.one_d import Visuals1D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.one_d import Include1D -from autogalaxy.plot.include.two_d import Include2D class Plotter(AbstractPlotter): @@ -18,37 +16,31 @@ def __init__( self, mat_plot_1d: MatPlot1D = None, visuals_1d: Visuals1D = None, - include_1d: Include1D = None, mat_plot_2d: MatPlot2D = None, visuals_2d: Visuals2D = None, - include_2d: Include2D = None, ): super().__init__( mat_plot_1d=mat_plot_1d, visuals_1d=visuals_1d, - include_1d=include_1d, mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d, - include_2d=include_2d, ) self.visuals_1d = visuals_1d or Visuals1D() - self.include_1d = include_1d or Include1D() self.mat_plot_1d = mat_plot_1d or MatPlot1D() self.visuals_2d = visuals_2d or Visuals2D() - self.include_2d = include_2d or Include2D() self.mat_plot_2d = mat_plot_2d or MatPlot2D() @property def get_1d(self): from autogalaxy.plot.get_visuals.one_d import GetVisuals1D - return GetVisuals1D(visuals=self.visuals_1d, include=self.include_1d) + return GetVisuals1D(visuals=self.visuals_1d) @property def get_2d(self): from autogalaxy.plot.get_visuals.two_d import GetVisuals2D - return GetVisuals2D(visuals=self.visuals_2d, include=self.include_2d) + return GetVisuals2D(visuals=self.visuals_2d) diff --git a/autogalaxy/plot/get_visuals/one_d.py b/autogalaxy/plot/get_visuals/one_d.py index 7f5c8ddc9..d8c2a5f6e 100644 --- a/autogalaxy/plot/get_visuals/one_d.py +++ b/autogalaxy/plot/get_visuals/one_d.py @@ -5,46 +5,36 @@ import autoarray.plot as aplt from autogalaxy.galaxy.galaxy import Galaxy -from autogalaxy.plot.include.one_d import Include1D from autogalaxy.plot.visuals.one_d import Visuals1D from autogalaxy.profiles.light.abstract import LightProfile from autogalaxy.profiles.mass.abstract.abstract import MassProfile -from autogalaxy import exc from autogalaxy.util import error_util logger = logging.getLogger(__name__) class GetVisuals1D(aplt.GetVisuals1D): - def __init__(self, include: Include1D, visuals: Visuals1D): + def __init__(self, visuals: Visuals1D): """ Class which gets 1D attributes and adds them to a `Visuals1D` objects, such that they are plotted on 1D figures. - For a visual to be extracted and added for plotting, it must have a `True` value in its corresponding entry in - the `Include1D` object. If this entry is `False`, the `GetVisuals1D.get` method returns a None and the attribute - is omitted from the plot. - The `GetVisuals1D` class adds new visuals to a pre-existing `Visuals1D` object that is passed to its `__init__` method. This only adds a new entry if the visual are not already in this object. Parameters ---------- - include - Sets which 1D visuals are included on the figure that is to be plotted (only entries which are `True` - are extracted via the `GetVisuals1D` object). visuals The pre-existing visuals of the plotter which new visuals are added too via the `GetVisuals1D` class. """ - super().__init__(include=include, visuals=visuals) + super().__init__(visuals=visuals) def via_light_obj_from(self, light_obj: Union[LightProfile, Galaxy]) -> Visuals1D: """ From an object with light profiles (e.g. a `LightProfile`, `Galaxy`) get its attributes that can be plotted and return them in a `Visuals1D` object. - Only attributes not already in `self.visuals` and with `True` entries in the `Include1D` object are extracted - for plotting. + Only attributes not already in `self.visuals` are extracted for plotting. From a light object the following 1D attributes can be extracted for plotting: @@ -76,8 +66,7 @@ def via_light_obj_list_from( From a list of objects with light profiles (e.g. a `LightProfile`, `Galaxy`) get its attributes that can be plotted and return them in a `Visuals1D` object. - Only attributes not already in `self.visuals` and with `True` entries in the `Include1D` object are extracted - for plotting. + Only attributes not already in `self.visuals` are extracted for plotting. This function iterates over all light objects in the list and averages over each attribute's values to estimate the mean value of the attribute and its error, both of which can then be plotted. This is typically used @@ -102,27 +91,22 @@ def via_light_obj_list_from( The mean value and errors of each attribute that are plotted in 1D by a `Plotter` object. """ - if self.include.half_light_radius: - half_light_radius_list = [ - light_profile.half_light_radius for light_profile in light_obj_list - ] - - if None in half_light_radius_list: - half_light_radius = None - half_light_radius_errors = None - - else: - ( - half_light_radius, - half_light_radius_errors, - ) = error_util.value_median_and_error_region_via_quantile( - value_list=half_light_radius_list, low_limit=low_limit - ) + half_light_radius_list = [ + light_profile.half_light_radius for light_profile in light_obj_list + ] - else: + if None in half_light_radius_list: half_light_radius = None half_light_radius_errors = None + else: + ( + half_light_radius, + half_light_radius_errors, + ) = error_util.value_median_and_error_region_via_quantile( + value_list=half_light_radius_list, low_limit=low_limit + ) + half_light_radius = self.get("half_light_radius", value=half_light_radius) half_light_radius_errors = self.get( "half_light_radius", value=half_light_radius_errors @@ -140,8 +124,7 @@ def via_mass_obj_from( From an object with mass profiles (e.g. a `MassProfile`, `Galaxy`) get its attributes that can be plotted and return them in a `Visuals1D` object. - Only attributes not already in `self.visuals` and with `True` entries in the `Include1D` object are extracted - for plotting. + Only attributes not already in `self.visuals` are extracted for plotting. From a mass object the following 1D attributes can be extracted for plotting: @@ -163,11 +146,10 @@ def via_mass_obj_from( einstein_radius = None - if self.include.einstein_radius: - try: - einstein_radius = mass_obj.einstein_radius_from(grid=grid) - except (TypeError, AttributeError): - pass + try: + einstein_radius = mass_obj.einstein_radius_from(grid=grid) + except (TypeError, AttributeError): + pass einstein_radius = self.get("einstein_radius", value=einstein_radius) @@ -183,8 +165,7 @@ def via_mass_obj_list_from( From a list of objects with mass profiles (e.g. a `MassProfile`, `Galaxy`) get its attributes that can be plotted and return them in a `Visuals1D` object. - Only attributes not already in `self.visuals` and with `True` entries in the `Include1D` object are extracted - for plotting. + Only attributes not already in `self.visuals` are extracted for plotting. This function iterates over all mass objects in the list and averages over each attribute's values to estimate the mean value of the attribute and its error, both of which can then be plotted. This is typically used @@ -209,29 +190,22 @@ def via_mass_obj_list_from( The mean value and errors of each attribute that are plotted in 1D by a `Plotter` object. """ - if self.include.einstein_radius: - einstein_radius_list = [] - - for mass_obj in mass_obj_list: - try: - einstein_radius_list.append( - mass_obj.einstein_radius_from(grid=grid) - ) - except TypeError: - einstein_radius_list.append(None) + einstein_radius_list = [] - einstein_radius_list = list(filter(None, einstein_radius_list)) + for mass_obj in mass_obj_list: + try: + einstein_radius_list.append(mass_obj.einstein_radius_from(grid=grid)) + except TypeError: + einstein_radius_list.append(None) - ( - einstein_radius, - einstein_radius_errors, - ) = error_util.value_median_and_error_region_via_quantile( - value_list=einstein_radius_list, low_limit=low_limit - ) + einstein_radius_list = list(filter(None, einstein_radius_list)) - else: - einstein_radius = None - einstein_radius_errors = None + ( + einstein_radius, + einstein_radius_errors, + ) = error_util.value_median_and_error_region_via_quantile( + value_list=einstein_radius_list, low_limit=low_limit + ) einstein_radius = self.get("einstein_radius", value=einstein_radius) einstein_radius_errors = self.get( diff --git a/autogalaxy/plot/get_visuals/two_d.py b/autogalaxy/plot/get_visuals/two_d.py index 73f0efc04..e595ce52e 100644 --- a/autogalaxy/plot/get_visuals/two_d.py +++ b/autogalaxy/plot/get_visuals/two_d.py @@ -4,7 +4,6 @@ import autoarray.plot as aplt from autogalaxy.imaging.fit_imaging import FitImaging -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.plot.visuals.two_d import Visuals2D from autogalaxy.profiles.light.abstract import LightProfile from autogalaxy.profiles.mass.abstract.abstract import MassProfile @@ -12,14 +11,10 @@ class GetVisuals2D(aplt.GetVisuals2D): - def __init__(self, include: Include2D, visuals: Visuals2D): + def __init__(self, visuals: Visuals2D): """ Class which gets 2D attributes and adds them to a `Visuals2D` objects, such that they are plotted on 2D figures. - For a visual to be extracted and added for plotting, it must have a `True` value in its corresponding entry in - the `Include2D` object. If this entry is `False`, the `GetVisuals2D.get` method returns a None and the - attribute is omitted from the plot. - The `GetVisuals2D` class adds new visuals to a pre-existing `Visuals2D` object that is passed to its `__init__` method. This only adds a new entry if the visual are not already in this object. @@ -31,7 +26,7 @@ def __init__(self, include: Include2D, visuals: Visuals2D): visuals The pre-existing visuals of the plotter which new visuals are added too via the `GetVisuals2D` class. """ - super().__init__(include=include, visuals=visuals) + super().__init__(visuals=visuals) def via_light_obj_from( self, light_obj: Union[LightProfile, Galaxy], grid @@ -40,8 +35,7 @@ def via_light_obj_from( From an object with light profiles (e.g. a `LightProfile`, `Galaxy`) get its attributes that can be plotted and return them in a `Visuals2D` object. - Only attributes not already in `self.visuals` and with `True` entries in the `Include1D` object are extracted - for plotting. + Only attributes not already in `self.visuals` are extracted for plotting. From a light object the following 2D attributes can be extracted for plotting: @@ -89,8 +83,7 @@ def via_mass_obj_from( From an object with mass profiles (e.g. a `MassProfile`, `Galaxy`) get its attributes that can be plotted and return them in a `Visuals2D` object. - Only attributes not already in `self.visuals` and with `True` entries in the `Include1D` object are extracted - for plotting. + Only attributes not already in `self.visuals` are extracted for plotting. From a mass object the following 2D attributes can be extracted for plotting: @@ -129,7 +122,6 @@ def via_mass_obj_from( tangential_critical_curves = self.get( "tangential_critical_curves", mass_obj.tangential_critical_curve_list_from(grid=grid), - "tangential_critical_curves", ) radial_critical_curves = None @@ -142,7 +134,6 @@ def via_mass_obj_from( radial_critical_curves = self.get( "radial_critical_curves", mass_obj.radial_critical_curve_list_from(grid=grid), - "radial_critical_curves", ) return ( @@ -255,9 +246,6 @@ def via_fit_imaging_from(self, fit: FitImaging) -> Visuals2D: """ From a `FitImaging` get its attributes that can be plotted and return them in a `Visuals2D` object. - Only attributes not already in `self.visuals` and with `True` entries in the `Include2D` object are extracted - for plotting. - From a `FitImaging` the following attributes can be extracted for plotting: - origin: the (y,x) origin of the 2D coordinate system. diff --git a/autogalaxy/plot/include/__init__.py b/autogalaxy/plot/include/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/autogalaxy/plot/include/one_d.py b/autogalaxy/plot/include/one_d.py deleted file mode 100644 index a74ae0f4a..000000000 --- a/autogalaxy/plot/include/one_d.py +++ /dev/null @@ -1,34 +0,0 @@ -import autoarray.plot as aplt - - -class Include1D(aplt.Include1D): - def __init__(self, half_light_radius=None, einstein_radius=None): - """ - Sets which `Visuals1D` are included on a figure plotting 1D data that is plotted using a `Plotter1D`. - - The `Include` object is used to extract the visuals of the plotted 1D data structures so they can be used in - plot functions. Only visuals with a `True` entry in the `Include` object are extracted and plotted. - - If an entry is not input into the class (e.g. it retains its default entry of `None`) then the bool is - loaded from the `config/visualize/include.ini` config file. This means the default visuals of a project - can be specified in a config file. - - Parameters - ---------- - half_light_radius - If `True`, the `half_light_radius` of the plotted light profile is included on the figure. - einstein_radius - If `True`, the `einstein_radius` of the plotted mass profile is included on the figure. - """ - super().__init__() - - self._half_light_radius = half_light_radius - self._einstein_radius = einstein_radius - - @property - def half_light_radius(self): - return self.load(value=self._half_light_radius, name="half_light_radius") - - @property - def einstein_radius(self): - return self.load(value=self._einstein_radius, name="einstein_radius") diff --git a/autogalaxy/plot/include/two_d.py b/autogalaxy/plot/include/two_d.py deleted file mode 100644 index c8ba69b90..000000000 --- a/autogalaxy/plot/include/two_d.py +++ /dev/null @@ -1,80 +0,0 @@ -from typing import Optional - -import autoarray.plot as aplt - - -class Include2D(aplt.Include2D): - def __init__( - self, - origin=None, - mask=None, - border=None, - grid=None, - positions=None, - light_profile_centres=None, - mass_profile_centres=None, - tangential_critical_curves=None, - radial_critical_curves=None, - tangential_caustics=None, - radial_caustics=None, - multiple_images=None, - mapper_source_plane_mesh_grid: Optional[bool] = None, - mapper_source_plane_data_grid: Optional[bool] = None, - mapper_image_plane_mesh_grid=None, - ): - super().__init__( - origin=origin, - mask=mask, - border=border, - grid=grid, - mapper_source_plane_mesh_grid=mapper_source_plane_mesh_grid, - mapper_source_plane_data_grid=mapper_source_plane_data_grid, - mapper_image_plane_mesh_grid=mapper_image_plane_mesh_grid, - ) - - self._positions = positions - self._light_profile_centres = light_profile_centres - self._mass_profile_centres = mass_profile_centres - self._tangential_critical_curves = tangential_critical_curves - self._radial_critical_curves = radial_critical_curves - self._tangential_caustics = tangential_caustics - self._radial_caustics = radial_caustics - self._multiple_images = multiple_images - - @property - def positions(self): - return self.load(value=self._positions, name="positions") - - @property - def light_profile_centres(self): - return self.load( - value=self._light_profile_centres, name="light_profile_centres" - ) - - @property - def mass_profile_centres(self): - return self.load(value=self._mass_profile_centres, name="mass_profile_centres") - - @property - def tangential_critical_curves(self): - return self.load( - value=self._tangential_critical_curves, name="tangential_critical_curves" - ) - - @property - def radial_critical_curves(self): - return self.load( - value=self._radial_critical_curves, name="radial_critical_curves" - ) - - @property - def tangential_caustics(self): - return self.load(value=self._tangential_caustics, name="tangential_caustics") - - @property - def radial_caustics(self): - return self.load(value=self._radial_caustics, name="radial_caustics") - - @property - def multiple_images(self): - return self.load(value=self._multiple_images, name="multiple_images") diff --git a/autogalaxy/plot/mass_plotter.py b/autogalaxy/plot/mass_plotter.py index 51ba4f56e..7deedaa24 100644 --- a/autogalaxy/plot/mass_plotter.py +++ b/autogalaxy/plot/mass_plotter.py @@ -7,7 +7,6 @@ from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.plot.abstract_plotters import Plotter @@ -20,11 +19,8 @@ def __init__( get_visuals_2d: Callable, mat_plot_2d: MatPlot2D = None, visuals_2d: Visuals2D = None, - include_2d: Include2D = None, ): - super().__init__( - mat_plot_2d=mat_plot_2d, include_2d=include_2d, visuals_2d=visuals_2d - ) + super().__init__(mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d) self.mass_obj = mass_obj self.grid = grid diff --git a/autogalaxy/profiles/mass/total/power_law.py b/autogalaxy/profiles/mass/total/power_law.py index 77c472b56..829189acb 100644 --- a/autogalaxy/profiles/mass/total/power_law.py +++ b/autogalaxy/profiles/mass/total/power_law.py @@ -105,11 +105,7 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): ) def convergence_func(self, grid_radius: float) -> float: - if grid_radius.array > 0.0: - return self.einstein_radius_rescaled * grid_radius.array ** ( - -(self.slope - 1) - ) - return jnp.inf + return self.einstein_radius_rescaled * grid_radius.array ** (-(self.slope - 1)) @staticmethod def potential_func(u, y, x, axis_ratio, slope, core_radius): diff --git a/autogalaxy/profiles/mass/total/power_law_core.py b/autogalaxy/profiles/mass/total/power_law_core.py index c07a44eca..af2069e17 100644 --- a/autogalaxy/profiles/mass/total/power_law_core.py +++ b/autogalaxy/profiles/mass/total/power_law_core.py @@ -63,15 +63,9 @@ def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): grid The grid of (y,x) arc-second coordinates the convergence is computed on. """ - - covnergence_grid = np.zeros(grid.shape[0]) - grid_eta = self.elliptical_radii_grid_from(grid=grid, **kwargs) - for i in range(grid.shape[0]): - covnergence_grid[i] = self.convergence_func(grid_eta[i]) - - return covnergence_grid + return self.convergence_func(grid_radius=grid_eta) @aa.over_sample @aa.grid_dec.to_array diff --git a/autogalaxy/profiles/plot/basis_plotters.py b/autogalaxy/profiles/plot/basis_plotters.py index c304aea85..04c3b03d9 100644 --- a/autogalaxy/profiles/plot/basis_plotters.py +++ b/autogalaxy/profiles/plot/basis_plotters.py @@ -8,8 +8,6 @@ from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.one_d import Visuals1D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.one_d import Include1D -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.profiles.plot.light_profile_plotters import LightProfilePlotter @@ -23,10 +21,8 @@ def __init__( grid: aa.type.Grid1D2DLike, mat_plot_1d: MatPlot1D = None, visuals_1d: Visuals1D = None, - include_1d: Include1D = None, mat_plot_2d: MatPlot2D = None, visuals_2d: Visuals2D = None, - include_2d: Include2D = None, ): """ Plots the attributes of `Basis` objects using the matplotlib methods `plot()` and `imshow()` and many @@ -38,8 +34,7 @@ def __init__( customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` objects. Attributes may be - extracted from the `LightProfile` 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. + extracted from the `LightProfile` and plotted via the visuals object. Parameters ---------- @@ -51,14 +46,10 @@ def __init__( 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 `LightProfile` 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 `LightProfile` are extracted and plotted as visuals for 2D plots. """ from autogalaxy.profiles.light.linear import ( @@ -76,10 +67,8 @@ def __init__( super().__init__( mat_plot_2d=mat_plot_2d, - include_2d=include_2d, visuals_2d=visuals_2d, mat_plot_1d=mat_plot_1d, - include_1d=include_1d, visuals_1d=visuals_1d, ) @@ -113,7 +102,6 @@ def light_profile_plotter_from( grid=self.grid, mat_plot_1d=self.mat_plot_1d, visuals_1d=self.get_1d.via_light_obj_from(light_obj=light_profile), - include_1d=self.include_1d, ) def subplot_image(self): diff --git a/autogalaxy/profiles/plot/light_profile_plotters.py b/autogalaxy/profiles/plot/light_profile_plotters.py index 45388e275..686e6f379 100644 --- a/autogalaxy/profiles/plot/light_profile_plotters.py +++ b/autogalaxy/profiles/plot/light_profile_plotters.py @@ -11,8 +11,6 @@ from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.one_d import Visuals1D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.one_d import Include1D -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.util import error_util from autogalaxy import exc @@ -25,10 +23,8 @@ def __init__( grid: aa.type.Grid1D2DLike, mat_plot_1d: MatPlot1D = None, visuals_1d: Visuals1D = None, - include_1d: Include1D = None, mat_plot_2d: MatPlot2D = None, visuals_2d: Visuals2D = None, - include_2d: Include2D = None, ): """ Plots the attributes of `LightProfile` objects using the matplotlib methods `plot()` and `imshow()` and many @@ -40,8 +36,7 @@ def __init__( customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` objects. Attributes may be - extracted from the `LightProfile` 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. + extracted from the `LightProfile` and plotted via the visuals object. Parameters ---------- @@ -53,14 +48,10 @@ def __init__( 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 `LightProfile` 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 `LightProfile` are extracted and plotted as visuals for 2D plots. """ from autogalaxy.profiles.light.linear import ( @@ -77,10 +68,8 @@ def __init__( super().__init__( mat_plot_2d=mat_plot_2d, - include_2d=include_2d, visuals_2d=visuals_2d, mat_plot_1d=mat_plot_1d, - include_1d=include_1d, visuals_1d=visuals_1d, ) @@ -158,10 +147,8 @@ def __init__( grid: aa.type.Grid2DLike, mat_plot_1d: MatPlot1D = None, visuals_1d: Visuals1D = None, - include_1d: Include1D = None, mat_plot_2d: MatPlot2D = None, visuals_2d: Visuals2D = None, - include_2d: Include2D = None, sigma: Optional[float] = 3.0, ): """ @@ -179,8 +166,7 @@ def __init__( customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` objects. Attributes may be - extracted from the `LightProfile` 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. + extracted from the `LightProfile` and plotted via the visuals object. Parameters ---------- @@ -192,14 +178,10 @@ def __init__( 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 `LightProfile` 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 `LightProfile` are extracted and plotted as visuals for 2D plots. sigma The confidence interval in terms of a sigma value at which the errors are computed (e.g. a value of sigma=3.0 uses confidence intevals at ~0.01 and 0.99 the PDF). @@ -209,10 +191,8 @@ def __init__( grid=grid, mat_plot_1d=mat_plot_1d, visuals_1d=visuals_1d, - include_1d=include_1d, mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d, - include_2d=include_2d, ) self.light_profile_pdf_list = light_profile_pdf_list diff --git a/autogalaxy/profiles/plot/mass_profile_plotters.py b/autogalaxy/profiles/plot/mass_profile_plotters.py index 248977955..b7bd0113b 100644 --- a/autogalaxy/profiles/plot/mass_profile_plotters.py +++ b/autogalaxy/profiles/plot/mass_profile_plotters.py @@ -11,8 +11,6 @@ from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.one_d import Visuals1D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.one_d import Include1D -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.util import error_util @@ -24,10 +22,8 @@ def __init__( grid: aa.type.Grid2DLike, mat_plot_1d: MatPlot1D = None, visuals_1d: Visuals1D = None, - include_1d: Include1D = None, mat_plot_2d: MatPlot2D = None, visuals_2d: Visuals2D = None, - include_2d: Include2D = None, ): """ Plots the attributes of `MassProfile` objects using the matplotlib methods `plot()` and `imshow()` and many @@ -39,8 +35,7 @@ def __init__( 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. + extracted from the `MassProfile` and plotted via the visuals object. Parameters ---------- @@ -52,21 +47,15 @@ def __init__( 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_2d=mat_plot_2d, - include_2d=include_2d, visuals_2d=visuals_2d, mat_plot_1d=mat_plot_1d, - include_1d=include_1d, visuals_1d=visuals_1d, ) @@ -78,7 +67,6 @@ def __init__( 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, ) @@ -154,10 +142,8 @@ def __init__( grid: aa.Grid2D, mat_plot_1d: MatPlot1D = None, visuals_1d: Visuals1D = None, - include_1d: Include1D = None, mat_plot_2d: MatPlot2D = None, visuals_2d: Visuals2D = None, - include_2d: Include2D = None, sigma: Optional[float] = 3.0, ): """ @@ -175,8 +161,7 @@ def __init__( 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. + extracted from the `MassProfile` and plotted via the visuals object. Parameters ---------- @@ -188,14 +173,10 @@ def __init__( 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. sigma The confidence interval in terms of a sigma value at which the errors are computed (e.g. a value of sigma=3.0 uses confidence intevals at ~0.01 and 0.99 the PDF). @@ -205,10 +186,8 @@ def __init__( grid=grid, mat_plot_1d=mat_plot_1d, visuals_1d=visuals_1d, - include_1d=include_1d, mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d, - include_2d=include_2d, ) self.mass_profile_pdf_list = mass_profile_pdf_list diff --git a/autogalaxy/quantity/model/plotter_interface.py b/autogalaxy/quantity/model/plotter_interface.py index 91e72f83f..0a573b74e 100644 --- a/autogalaxy/quantity/model/plotter_interface.py +++ b/autogalaxy/quantity/model/plotter_interface.py @@ -86,7 +86,6 @@ def should_plot(name): fit=fit, mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d, - include_2d=self.include_2d, ) if should_plot("subplot_fit"): diff --git a/autogalaxy/quantity/plot/fit_quantity_plotters.py b/autogalaxy/quantity/plot/fit_quantity_plotters.py index 07f449471..438056fd0 100644 --- a/autogalaxy/quantity/plot/fit_quantity_plotters.py +++ b/autogalaxy/quantity/plot/fit_quantity_plotters.py @@ -7,7 +7,6 @@ from autogalaxy.plot.abstract_plotters import Plotter from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.two_d import Include2D # TODO : Ew, this is a mass, but it works. Clean up one day! @@ -19,7 +18,6 @@ def __init__( fit: FitQuantity, mat_plot_2d: MatPlot2D = None, visuals_2d: Visuals2D = None, - include_2d: Include2D = None, ): """ Plots the attributes of `FitQuantity` objects using the matplotlib method `imshow()` and many @@ -31,8 +29,7 @@ def __init__( customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` objects. Attributes may be - extracted from the `FitQuantity` 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. + extracted from the `FitQuantity` and plotted via the visuals object. Parameters ---------- @@ -42,12 +39,8 @@ def __init__( 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 `FitQuantity` are extracted and plotted as visuals for 2D plots. """ - super().__init__( - mat_plot_2d=mat_plot_2d, include_2d=include_2d, visuals_2d=visuals_2d - ) + super().__init__(mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d) self.fit = fit @@ -99,7 +92,6 @@ def figures_2d( 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, ) @@ -118,7 +110,6 @@ def figures_2d( fit=self.fit.y, get_visuals_2d=self.get_visuals_2d_y, mat_plot_2d=self.mat_plot_2d, - include_2d=self.include_2d, visuals_2d=self.visuals_2d, ) @@ -137,7 +128,6 @@ def figures_2d( fit=self.fit.y, get_visuals_2d=self.get_visuals_2d_x, mat_plot_2d=self.mat_plot_2d, - include_2d=self.include_2d, visuals_2d=self.visuals_2d, ) @@ -162,7 +152,6 @@ def subplot_fit(self): 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, ) @@ -181,7 +170,6 @@ def subplot_fit(self): fit=self.fit.y, get_visuals_2d=self.get_visuals_2d_y, mat_plot_2d=self.mat_plot_2d, - include_2d=self.include_2d, visuals_2d=self.visuals_2d, ) @@ -199,7 +187,6 @@ def subplot_fit(self): fit=self.fit.x, get_visuals_2d=self.get_visuals_2d_x, mat_plot_2d=self.mat_plot_2d, - include_2d=self.include_2d, visuals_2d=self.visuals_2d, ) diff --git a/test_autogalaxy/analysis/test_plotter_interface.py b/test_autogalaxy/analysis/test_plotter_interface.py index ce8b45a7e..7dfef6c83 100644 --- a/test_autogalaxy/analysis/test_plotter_interface.py +++ b/test_autogalaxy/analysis/test_plotter_interface.py @@ -16,9 +16,7 @@ def make_plotter_interface_plotter_setup(): return path.join("{}".format(directory), "files") -def test__galaxies( - masked_imaging_7x7, galaxies_7x7, include_2d_all, plot_path, plot_patch -): +def test__galaxies(masked_imaging_7x7, galaxies_7x7, plot_path, plot_patch): if path.exists(plot_path): shutil.rmtree(plot_path) @@ -83,7 +81,6 @@ def test__inversion( def test__adapt_images( masked_imaging_7x7, - include_2d_all, adapt_galaxy_name_image_dict_7x7, fit_imaging_x2_galaxy_inversion_7x7, plot_path, diff --git a/test_autogalaxy/config/visualize.yaml b/test_autogalaxy/config/visualize.yaml index a2ab113c9..af4a18bcb 100644 --- a/test_autogalaxy/config/visualize.yaml +++ b/test_autogalaxy/config/visualize.yaml @@ -3,29 +3,6 @@ general: backend: default imshow_origin: upper zoom_around_mask: true -include: - include_1d: - einstein_radius: true - half_light_radius: true - include_2d: - border: false - tangential_caustics: false - radial_caustics: false - tangential_critical_curves: false - radial_critical_curves: false - grid: false - light_profile_centres: true - mapper_image_plane_mesh_grid: false - mapper_source_plane_data_grid: false - mapper_source_plane_mesh_grid: false - mask: true - mass_profile_centres: true - multiple_images: false - origin: true - parallel_overscan: true - positions: true - serial_overscan: true - serial_prescan: true mat_wrap: Axis: figure: @@ -293,47 +270,39 @@ mat_wrap_2d: TangentialCausticsPlot: figure: c: w,g - pointsize: 21 - style: -- - width: 5 + linestyle: -- + linewidth: 5 subplot: c: g - pointsize: 23 - style: -- - width: 7 + linestyle: -- + linewidth: 7 TangentialCriticalCurvesPlot: figure: c: w,k - pointsize: 20 - style: '-' - width: 4 + linestyle: '-' + linewidth: 4 subplot: c: b - pointsize: 22 - style: '-' - width: 6 + linestyle: '-' + linewidth: 6 RadialCausticsPlot: figure: c: w,g - pointsize: 21 - style: -- - width: 5 + linestyle: -- + linewidth: 5 subplot: c: g - pointsize: 23 - style: -- - width: 7 + linestyle: -- + linewidth: 7 RadialCriticalCurvesPlot: figure: c: w,k - pointsize: 20 - style: '-' - width: 4 + linestyle: '-' + linewidth: 4 subplot: c: b - pointsize: 22 - style: '-' - width: 6 + linestyle: '-' + linewidth: 6 LightProfileCentresScatter: figure: c: k,r diff --git a/test_autogalaxy/conftest.py b/test_autogalaxy/conftest.py index 95d164c3d..1d27ed90e 100644 --- a/test_autogalaxy/conftest.py +++ b/test_autogalaxy/conftest.py @@ -383,16 +383,6 @@ def make_voronoi_mapper_9_3x3(): return fixtures.make_voronoi_mapper_9_3x3() -@pytest.fixture(name="include_1d_all") -def make_include_1d_all(): - return fixtures.make_include_1d_all() - - -@pytest.fixture(name="include_2d_all") -def make_include_2d_all(): - return fixtures.make_include_2d_all() - - @pytest.fixture(name="samples_summary_with_result") def make_samples_summary_with_result(): return fixtures.make_samples_summary_with_result() diff --git a/test_autogalaxy/galaxy/plot/test_adapt_plotters.py b/test_autogalaxy/galaxy/plot/test_adapt_plotters.py index 8e1eec666..5b3a2fa68 100644 --- a/test_autogalaxy/galaxy/plot/test_adapt_plotters.py +++ b/test_autogalaxy/galaxy/plot/test_adapt_plotters.py @@ -15,10 +15,9 @@ def make_adapt_plotter_setup(): def test__plot_adapt_adapt_images( - adapt_galaxy_name_image_dict_7x7, mask_2d_7x7, include_2d_all, plot_path, plot_patch + adapt_galaxy_name_image_dict_7x7, mask_2d_7x7, plot_path, plot_patch ): adapt_plotter = aplt.AdaptPlotter( - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) diff --git a/test_autogalaxy/galaxy/plot/test_galaxies_plotter.py b/test_autogalaxy/galaxy/plot/test_galaxies_plotter.py index 71a88e3ed..eddee94c0 100644 --- a/test_autogalaxy/galaxy/plot/test_galaxies_plotter.py +++ b/test_autogalaxy/galaxy/plot/test_galaxies_plotter.py @@ -19,14 +19,12 @@ def test__all_individual_plotter__output_file_with_default_name( grid_2d_7x7, mask_2d_7x7, grid_2d_irregular_7x7_list, - include_2d_all, plot_path, plot_patch, ): plotter = aplt.GalaxiesPlotter( galaxies=galaxies_7x7, grid=grid_2d_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) @@ -40,14 +38,12 @@ def test__figures_of_galaxies( galaxies_x2_7x7, grid_2d_7x7, mask_2d_7x7, - include_2d_all, plot_path, plot_patch, ): plotter = aplt.GalaxiesPlotter( galaxies=galaxies_x2_7x7, grid=grid_2d_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(path=plot_path, format="png")), ) @@ -64,15 +60,11 @@ def test__figures_of_galaxies( assert path.join(plot_path, "image_2d_of_galaxy_1.png") not in plot_patch.paths -def test__galaxies_sub_plot_output( - galaxies_x2_7x7, grid_2d_7x7, include_2d_all, include_1d_all, plot_path, plot_patch -): +def test__galaxies_sub_plot_output(galaxies_x2_7x7, grid_2d_7x7, plot_path, plot_patch): plotter = aplt.GalaxiesPlotter( galaxies=galaxies_x2_7x7, grid=grid_2d_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), - include_1d=include_1d_all, mat_plot_1d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) diff --git a/test_autogalaxy/galaxy/plot/test_galaxy_plotters.py b/test_autogalaxy/galaxy/plot/test_galaxy_plotters.py index 911cf83bf..e03fd3f29 100644 --- a/test_autogalaxy/galaxy/plot/test_galaxy_plotters.py +++ b/test_autogalaxy/galaxy/plot/test_galaxy_plotters.py @@ -15,12 +15,11 @@ def make_galaxy_plotter_setup(): def test__figures_1d__all_are_output( - gal_x1_lp_x1_mp, grid_2d_7x7, mask_2d_7x7, include_1d_all, plot_path, plot_patch + gal_x1_lp_x1_mp, grid_2d_7x7, mask_2d_7x7, plot_path, plot_patch ): galaxy_plotter = aplt.GalaxyPlotter( galaxy=gal_x1_lp_x1_mp, grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=aplt.MatPlot1D(output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.figures_1d(image=True, convergence=True, potential=True) @@ -34,7 +33,6 @@ def test__figures_1d__all_are_output( galaxy_plotter = aplt.GalaxyPDFPlotter( galaxy_pdf_list=[gal_x1_lp_x1_mp, gal_x1_lp_x1_mp, gal_x1_lp_x1_mp], grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=aplt.MatPlot1D(output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.figures_1d(image=True, convergence=True, potential=True) @@ -45,12 +43,11 @@ def test__figures_1d__all_are_output( def test__figures_1d_decomposed__all_are_output( - gal_x1_lp_x1_mp, grid_2d_7x7, mask_2d_7x7, include_1d_all, plot_path, plot_patch + gal_x1_lp_x1_mp, grid_2d_7x7, mask_2d_7x7, plot_path, plot_patch ): galaxy_plotter = aplt.GalaxyPlotter( galaxy=gal_x1_lp_x1_mp, grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=aplt.MatPlot1D(output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.figures_1d_decomposed(image=True, convergence=True, potential=True) @@ -64,7 +61,6 @@ def test__figures_1d_decomposed__all_are_output( galaxy_plotter = aplt.GalaxyPDFPlotter( galaxy_pdf_list=[gal_x1_lp_x1_mp, gal_x1_lp_x1_mp, gal_x1_lp_x1_mp], grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=aplt.MatPlot1D(output=aplt.Output(plot_path, format="png")), ) @@ -76,7 +72,7 @@ def test__figures_1d_decomposed__all_are_output( def test__figures_1d_decomposed__light_profiles_different_centres_making_offset_radial_grid( - grid_2d_7x7, mask_2d_7x7, include_1d_all, plot_path, plot_patch + grid_2d_7x7, mask_2d_7x7, plot_path, plot_patch ): lp_0 = ag.lp.SersicSph(centre=(0.0, 0.0)) lp_1 = ag.lp.SersicSph(centre=(1.0, 1.0)) @@ -89,7 +85,6 @@ def test__figures_1d_decomposed__light_profiles_different_centres_making_offset_ galaxy_plotter = aplt.GalaxyPlotter( galaxy=gal, grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=aplt.MatPlot1D(output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.figures_1d_decomposed(image=True, convergence=True, potential=True) @@ -110,7 +105,6 @@ def test__figures_1d_decomposed__light_profiles_different_centres_making_offset_ galaxy_plotter = aplt.GalaxyPDFPlotter( galaxy_pdf_list=[gal_0, gal_1], grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=aplt.MatPlot1D(output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.figures_1d_decomposed(image=True, convergence=True, potential=True) @@ -125,14 +119,12 @@ def test__figures_2d__all_are_output( grid_2d_7x7, mask_2d_7x7, grid_2d_irregular_7x7_list, - include_2d_all, plot_path, plot_patch, ): galaxy_plotter = aplt.GalaxyPlotter( galaxy=gal_x1_lp_x1_mp, grid=grid_2d_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.figures_2d(image=True, convergence=True) @@ -145,14 +137,12 @@ def test__subplots_galaxy_quantities__all_are_output( gal_x1_lp_x1_mp, grid_2d_7x7, grid_2d_irregular_7x7_list, - include_2d_all, plot_path, plot_patch, ): galaxy_plotter = aplt.GalaxyPlotter( galaxy=gal_x1_lp_x1_mp, grid=grid_2d_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.subplot_of_light_profiles(image=True) diff --git a/test_autogalaxy/galaxy/test_galaxies.py b/test_autogalaxy/galaxy/test_galaxies.py index e5944f2d4..ea16d74ab 100644 --- a/test_autogalaxy/galaxy/test_galaxies.py +++ b/test_autogalaxy/galaxy/test_galaxies.py @@ -179,7 +179,9 @@ def test__convergence_2d_from(grid_2d_7x7): convergence = galaxies.convergence_2d_from(grid=grid_2d_7x7) - assert convergence == pytest.approx(g0_convergence + g1_convergence, 1.0e-8) + assert convergence.array == pytest.approx( + g0_convergence.array + g1_convergence.array, 1.0e-8 + ) def test__potential_2d_from(grid_2d_7x7): diff --git a/test_autogalaxy/galaxy/test_galaxy.py b/test_autogalaxy/galaxy/test_galaxy.py index 4f0d9b990..bb1098104 100644 --- a/test_autogalaxy/galaxy/test_galaxy.py +++ b/test_autogalaxy/galaxy/test_galaxy.py @@ -383,13 +383,15 @@ def test__mass_profile_2d_quantity_from_grid__symmetric_profiles_give_symmetric_ assert gal_x4_mp.convergence_2d_from( grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) == pytest.approx( - gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[99.0, 0.0]])), 1.0e-4 + gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[99.0, 0.0]])).array, + 1.0e-4, ) assert gal_x4_mp.convergence_2d_from( grid=ag.Grid2DIrregular([[49.0, 0.0]]) ) == pytest.approx( - gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])), 1.0e-4 + gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])).array, + 1.0e-4, ) assert gal_x4_mp.potential_2d_from( @@ -437,25 +439,29 @@ def test__mass_profile_2d_quantity_from_grid__symmetric_profiles_give_symmetric_ assert gal_x4_mp.convergence_2d_from( grid=ag.Grid2DIrregular([[49.0, 0.0]]) ) == pytest.approx( - gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])), 1e-5 + gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])).array, + 1e-5, ) assert gal_x4_mp.convergence_2d_from( grid=ag.Grid2DIrregular([[0.0, 49.0]]) ) == pytest.approx( - gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[0.0, 51.0]])), 1e-5 + gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[0.0, 51.0]])).array, + 1e-5, ) assert gal_x4_mp.convergence_2d_from( grid=ag.Grid2DIrregular([[100.0, 49.0]]) ) == pytest.approx( - gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[100.0, 51.0]])), 1e-5 + gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[100.0, 51.0]])).array, + 1e-5, ) assert gal_x4_mp.convergence_2d_from( grid=ag.Grid2DIrregular([[49.0, 49.0]]) ) == pytest.approx( - gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[51.0, 51.0]])), 1e-5 + gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[51.0, 51.0]])).array, + 1e-5, ) assert gal_x4_mp.potential_2d_from( diff --git a/test_autogalaxy/imaging/model/test_plotter_interface_imaging.py b/test_autogalaxy/imaging/model/test_plotter_interface_imaging.py index d24358750..58f59479e 100644 --- a/test_autogalaxy/imaging/model/test_plotter_interface_imaging.py +++ b/test_autogalaxy/imaging/model/test_plotter_interface_imaging.py @@ -13,7 +13,7 @@ def make_plotter_interface_plotter_setup(): return path.join("{}".format(directory), "files") -def test__imaging(imaging_7x7, include_2d_all, plot_path, plot_patch): +def test__imaging(imaging_7x7, plot_path, plot_patch): if path.exists(plot_path): shutil.rmtree(plot_path) @@ -44,7 +44,6 @@ def test__imaging_combined(imaging_7x7, plot_path, plot_patch): def test__fit_imaging( masked_imaging_7x7, fit_imaging_x2_galaxy_inversion_7x7, - include_2d_all, plot_path, plot_patch, ): diff --git a/test_autogalaxy/imaging/plot/test_fit_imaging_plotters.py b/test_autogalaxy/imaging/plot/test_fit_imaging_plotters.py index b88b5ae0e..6ed807b02 100644 --- a/test_autogalaxy/imaging/plot/test_fit_imaging_plotters.py +++ b/test_autogalaxy/imaging/plot/test_fit_imaging_plotters.py @@ -15,11 +15,10 @@ def make_fit_imaging_plotter_setup(): def test__fit_individuals__source_and_galaxy__dependent_on_input( - fit_imaging_x2_galaxy_7x7, include_2d_all, plot_path, plot_patch + fit_imaging_x2_galaxy_7x7, plot_path, plot_patch ): fit_plotter = aplt.FitImagingPlotter( fit=fit_imaging_x2_galaxy_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) @@ -40,12 +39,9 @@ def test__fit_individuals__source_and_galaxy__dependent_on_input( assert path.join(plot_path, "chi_squared_map.png") in plot_patch.paths -def test__figures_of_galaxies( - fit_imaging_x2_galaxy_7x7, include_2d_all, plot_path, plot_patch -): +def test__figures_of_galaxies(fit_imaging_x2_galaxy_7x7, plot_path, plot_patch): fit_plotter = aplt.FitImagingPlotter( fit=fit_imaging_x2_galaxy_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) @@ -74,12 +70,9 @@ def test__figures_of_galaxies( assert path.join(plot_path, "model_image_of_galaxy_1.png") in plot_patch.paths -def test__subplot_of_galaxy( - fit_imaging_x2_galaxy_7x7, include_2d_all, plot_path, plot_patch -): +def test__subplot_of_galaxy(fit_imaging_x2_galaxy_7x7, plot_path, plot_patch): fit_plotter = aplt.FitImagingPlotter( fit=fit_imaging_x2_galaxy_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) fit_plotter.subplot_of_galaxies() diff --git a/test_autogalaxy/interferometer/model/test_plotter_interface_interferometer.py b/test_autogalaxy/interferometer/model/test_plotter_interface_interferometer.py index a9f6caca8..a779f7d4c 100644 --- a/test_autogalaxy/interferometer/model/test_plotter_interface_interferometer.py +++ b/test_autogalaxy/interferometer/model/test_plotter_interface_interferometer.py @@ -15,7 +15,7 @@ def make_plotter_interface_plotter_setup(): return path.join("{}".format(directory), "files") -def test__interferometer(interferometer_7, include_2d_all, plot_path, plot_patch): +def test__interferometer(interferometer_7, plot_path, plot_patch): plotter_interface = PlotterInterfaceInterferometer(image_path=plot_path) plotter_interface.interferometer(dataset=interferometer_7) @@ -32,7 +32,6 @@ def test__interferometer(interferometer_7, include_2d_all, plot_path, plot_patch def test__fit_interferometer( interferometer_7, fit_interferometer_x2_galaxy_inversion_7x7, - include_2d_all, plot_path, plot_patch, ): diff --git a/test_autogalaxy/interferometer/plot/test_fit_interferometer_plotters.py b/test_autogalaxy/interferometer/plot/test_fit_interferometer_plotters.py index ce6797133..174351865 100644 --- a/test_autogalaxy/interferometer/plot/test_fit_interferometer_plotters.py +++ b/test_autogalaxy/interferometer/plot/test_fit_interferometer_plotters.py @@ -14,13 +14,11 @@ def make_fit_dataset_plotter_setup(): def test__fit_sub_plot_real_space( fit_interferometer_7x7, fit_interferometer_x2_galaxy_inversion_7x7, - include_2d_all, plot_path, plot_patch, ): fit_plotter = aplt.FitInterferometerPlotter( fit=fit_interferometer_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) @@ -32,7 +30,6 @@ def test__fit_sub_plot_real_space( fit_plotter = aplt.FitInterferometerPlotter( fit=fit_interferometer_x2_galaxy_inversion_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) diff --git a/test_autogalaxy/plot/mat_wrap/config/visualize/include.ini b/test_autogalaxy/plot/mat_wrap/config/visualize/include.ini deleted file mode 100644 index ca5f8aa1b..000000000 --- a/test_autogalaxy/plot/mat_wrap/config/visualize/include.ini +++ /dev/null @@ -1,16 +0,0 @@ -[include_2d] -origin=True -mask=True -border=True -positions=True -critical_curves=False -caustics=False -multiple_images=False -light_profile_centres=True -mass_profile_centres=True -mapper_image_plane_mesh_grid=True -mapper_source_plane_mesh_grid=False -mapper_source_plane_data_grid=False -parallel_overscan=True -serial_prescan=True -serial_overscan=True \ No newline at end of file diff --git a/test_autogalaxy/plot/mat_wrap/test_get_visuals.py b/test_autogalaxy/plot/mat_wrap/test_get_visuals.py index 9cf8fc038..41ae8f5ea 100644 --- a/test_autogalaxy/plot/mat_wrap/test_get_visuals.py +++ b/test_autogalaxy/plot/mat_wrap/test_get_visuals.py @@ -19,28 +19,18 @@ def make_profile_plotter_setup(): def test__1d__via_light_obj_from(lp_0): visuals_1d = aplt.Visuals1D() - include_1d = aplt.Include1D(half_light_radius=True) - get_visuals = GetVisuals1D(include=include_1d, visuals=visuals_1d) + get_visuals = GetVisuals1D(visuals=visuals_1d) visuals_1d_via = get_visuals.via_light_obj_from(light_obj=lp_0) assert visuals_1d_via.half_light_radius == lp_0.half_light_radius - include_1d = aplt.Include1D(half_light_radius=False) - - get_visuals = GetVisuals1D(include=include_1d, visuals=visuals_1d) - - visuals_1d_via = get_visuals.via_light_obj_from(light_obj=lp_0) - - assert visuals_1d_via.half_light_radius is None - def test__1d__via_light_obj_list_from(lp_0): visuals_1d = aplt.Visuals1D() - include_1d = aplt.Include1D(half_light_radius=True) - get_visuals = GetVisuals1D(include=include_1d, visuals=visuals_1d) + get_visuals = GetVisuals1D(visuals=visuals_1d) visuals_1d_via = get_visuals.via_light_obj_list_from( light_obj_list=[lp_0, lp_0], low_limit=1.0 @@ -49,42 +39,22 @@ def test__1d__via_light_obj_list_from(lp_0): assert visuals_1d_via.half_light_radius == lp_0.half_light_radius assert visuals_1d_via.half_light_radius_errors[0][0] == lp_0.half_light_radius - include_1d = aplt.Include1D(half_light_radius=False) - - get_visuals = GetVisuals1D(include=include_1d, visuals=visuals_1d) - - visuals_1d_via = get_visuals.via_light_obj_list_from( - light_obj_list=[lp_0, lp_0], low_limit=1.0 - ) - - assert visuals_1d_via.half_light_radius is None - assert visuals_1d_via.half_light_radius_errors is None - def test__1d__via_mass_obj_from(mp_0, grid_2d_7x7): visuals_1d = aplt.Visuals1D() - include_1d = aplt.Include1D(einstein_radius=True) - get_visuals = GetVisuals1D(include=include_1d, visuals=visuals_1d) + get_visuals = GetVisuals1D(visuals=visuals_1d) visuals_1d_via = get_visuals.via_mass_obj_from(mass_obj=mp_0, grid=grid_2d_7x7) assert visuals_1d_via.einstein_radius == mp_0.einstein_radius_from(grid=grid_2d_7x7) - include_1d = aplt.Include1D(einstein_radius=False) - - get_visuals = GetVisuals1D(include=include_1d, visuals=visuals_1d) - - visuals_1d_via = get_visuals.via_mass_obj_from(mass_obj=mp_0, grid=grid_2d_7x7) - - assert visuals_1d_via.einstein_radius is None - def test__1d__via_mass_obj_list_from(mp_0, grid_2d_7x7): + visuals_1d = aplt.Visuals1D() - include_1d = aplt.Include1D(einstein_radius=True) - get_visuals = GetVisuals1D(include=include_1d, visuals=visuals_1d) + get_visuals = GetVisuals1D(visuals=visuals_1d) visuals_1d_via = get_visuals.via_mass_obj_list_from( mass_obj_list=[mp_0, mp_0], grid=grid_2d_7x7, low_limit=1.0 @@ -95,25 +65,11 @@ def test__1d__via_mass_obj_list_from(mp_0, grid_2d_7x7): grid=grid_2d_7x7 ) - include_1d = aplt.Include1D(einstein_radius=False) - - get_visuals = GetVisuals1D(include=include_1d, visuals=visuals_1d) - - visuals_1d_via = get_visuals.via_mass_obj_list_from( - mass_obj_list=[mp_0, mp_0], grid=grid_2d_7x7, low_limit=1.0 - ) - - assert visuals_1d_via.einstein_radius is None - assert visuals_1d_via.einstein_radius_errors is None - 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) + get_visuals = GetVisuals2D(visuals=visuals_2d) visuals_2d_via = get_visuals.via_light_obj_from(light_obj=lp_0, grid=grid_2d_7x7) @@ -123,33 +79,11 @@ def test__2d__via_light_obj_from(lp_0, grid_2d_7x7): 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 - def test__2d__via_mass_obj(mp_0, grid_2d_7x7): visuals_2d = aplt.Visuals2D(vectors=2) - include_2d = aplt.Include2D( - origin=True, - mask=True, - border=True, - mass_profile_centres=True, - tangential_critical_curves=True, - radial_critical_curves=True, - ) - get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d) + get_visuals = GetVisuals2D(visuals=visuals_2d) visuals_2d_via = get_visuals.via_mass_obj_from(mass_obj=mp_0, grid=grid_2d_7x7) @@ -163,41 +97,11 @@ def test__2d__via_mass_obj(mp_0, grid_2d_7x7): ).all() assert visuals_2d_via.vectors == 2 - include_2d = aplt.Include2D( - origin=False, - mask=False, - border=False, - mass_profile_centres=False, - tangential_critical_curves=False, - radial_critical_curves=False, - ) - - get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d) - - visuals_2d_via = get_visuals.via_mass_obj_from(mass_obj=mp_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.mass_profile_centres is None - assert visuals_2d_via.tangential_critical_curves is None - assert visuals_2d_via.radial_critical_curves is None - assert visuals_2d_via.vectors == 2 - 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, - tangential_critical_curves=True, - radial_critical_curves=True, - ) - get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d) + get_visuals = GetVisuals2D(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 @@ -222,45 +126,11 @@ def test__2d__via_light_mass_obj(gal_x1_lp_x1_mp, grid_2d_7x7): ).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, - tangential_critical_curves=False, - radial_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.tangential_critical_curves is None - assert visuals_2d_via.radial_critical_curves is None - assert visuals_2d_via.vectors == 2 - 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, - tangential_critical_curves=True, - radial_critical_curves=True, - ) - get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d) + get_visuals = GetVisuals2D(visuals=visuals_2d) visuals_2d_via = get_visuals.via_fit_imaging_from(fit=fit_imaging_x2_galaxy_7x7) @@ -284,26 +154,3 @@ def test__via_fit_imaging_from(fit_imaging_x2_galaxy_7x7, 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, - tangential_critical_curves=False, - radial_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.tangential_critical_curves is None - assert visuals_2d_via.radial_critical_curves is None - assert visuals_2d_via.vectors == 2 diff --git a/test_autogalaxy/plot/mat_wrap/test_mat_obj.py b/test_autogalaxy/plot/mat_wrap/test_mat_obj.py index 16c76cab1..53e4f154e 100644 --- a/test_autogalaxy/plot/mat_wrap/test_mat_obj.py +++ b/test_autogalaxy/plot/mat_wrap/test_mat_obj.py @@ -16,16 +16,16 @@ def test__mat_obj__all_load_from_config_correctly(): tangential_critical_curves_plot = aplt.TangentialCriticalCurvesPlot() - assert tangential_critical_curves_plot.config_dict["width"] == 4 + assert tangential_critical_curves_plot.config_dict["linewidth"] == 4 tangential_caustics_plot = aplt.TangentialCausticsPlot() - assert tangential_caustics_plot.config_dict["width"] == 5 + assert tangential_caustics_plot.config_dict["linewidth"] == 5 radial_critical_curves_plot = aplt.RadialCriticalCurvesPlot() - assert radial_critical_curves_plot.config_dict["width"] == 4 + assert radial_critical_curves_plot.config_dict["linewidth"] == 4 radial_caustics_plot = aplt.RadialCausticsPlot() - assert radial_caustics_plot.config_dict["width"] == 5 + assert radial_caustics_plot.config_dict["linewidth"] == 5 diff --git a/test_autogalaxy/profiles/mass/abstract/test_abstract.py b/test_autogalaxy/profiles/mass/abstract/test_abstract.py index 65f8f7694..4e8f817f4 100644 --- a/test_autogalaxy/profiles/mass/abstract/test_abstract.py +++ b/test_autogalaxy/profiles/mass/abstract/test_abstract.py @@ -247,18 +247,18 @@ def test__decorators__convergence_1d_from__grid_2d_irregular_in__returns_1d_quan convergence_1d = sie.convergence_1d_from(grid=grid_2d) convergence_2d = sie.convergence_2d_from(grid=grid_2d) - assert convergence_1d[0] == pytest.approx(convergence_2d[0], 1.0e-4) - assert convergence_1d[1] == pytest.approx(convergence_2d[1], 1.0e-4) - assert convergence_1d[2] == pytest.approx(convergence_2d[2], 1.0e-4) + assert convergence_1d[0] == pytest.approx(convergence_2d[0].array, 1.0e-4) + assert convergence_1d[1] == pytest.approx(convergence_2d[1].array, 1.0e-4) + assert convergence_1d[2] == pytest.approx(convergence_2d[2].array, 1.0e-4) sie = ag.mp.Isothermal(centre=(0.2, 0.2), ell_comps=(0.3, 0.3), einstein_radius=1.0) convergence_1d = sie.convergence_1d_from(grid=grid_2d) convergence_2d = sie.convergence_2d_from(grid=grid_2d) - assert convergence_1d[0] == pytest.approx(convergence_2d[0], 1.0e-4) - assert convergence_1d[1] == pytest.approx(convergence_2d[1], 1.0e-4) - assert convergence_1d[2] == pytest.approx(convergence_2d[2], 1.0e-4) + assert convergence_1d[0] == pytest.approx(convergence_2d[0].array, 1.0e-4) + assert convergence_1d[1] == pytest.approx(convergence_2d[1].array, 1.0e-4) + assert convergence_1d[2] == pytest.approx(convergence_2d[2].array, 1.0e-4) def test__decorators__convergence_1d_from__grid_1d_in__returns_1d_quantities_via_projection(): @@ -269,9 +269,9 @@ def test__decorators__convergence_1d_from__grid_1d_in__returns_1d_quantities_via convergence_1d = sie.convergence_1d_from(grid=grid_1d) convergence_2d = sie.convergence_2d_from(grid=grid_1d) - assert convergence_1d[0] == pytest.approx(convergence_2d[0], 1.0e-4) - assert convergence_1d[1] == pytest.approx(convergence_2d[1], 1.0e-4) - assert convergence_1d[2] == pytest.approx(convergence_2d[2], 1.0e-4) + assert convergence_1d[0] == pytest.approx(convergence_2d[0].array, 1.0e-4) + assert convergence_1d[1] == pytest.approx(convergence_2d[1].array, 1.0e-4) + assert convergence_1d[2] == pytest.approx(convergence_2d[2].array, 1.0e-4) sie = ag.mp.Isothermal(centre=(0.5, 0.5), ell_comps=(0.2, 0.2), einstein_radius=1.0) @@ -281,9 +281,9 @@ def test__decorators__convergence_1d_from__grid_1d_in__returns_1d_quantities_via convergence_2d = sie.convergence_2d_from(grid=grid_2d_radial) - assert convergence_1d[0] == pytest.approx(convergence_2d[0], 1.0e-4) - assert convergence_1d[1] == pytest.approx(convergence_2d[1], 1.0e-4) - assert convergence_1d[2] == pytest.approx(convergence_2d[2], 1.0e-4) + assert convergence_1d[0] == pytest.approx(convergence_2d[0].array, 1.0e-4) + assert convergence_1d[1] == pytest.approx(convergence_2d[1].array, 1.0e-4) + assert convergence_1d[2] == pytest.approx(convergence_2d[2].array, 1.0e-4) def test__decorators__potential_1d_from__grid_2d_in__returns_1d_image_via_projected_quantities(): diff --git a/test_autogalaxy/profiles/mass/total/test_isothermal.py b/test_autogalaxy/profiles/mass/total/test_isothermal.py index 21ca57d5c..22605bb1b 100644 --- a/test_autogalaxy/profiles/mass/total/test_isothermal.py +++ b/test_autogalaxy/profiles/mass/total/test_isothermal.py @@ -79,8 +79,8 @@ def test__convergence_2d_from(): ) spherical = ag.mp.IsothermalSph(centre=(1.1, 1.1), einstein_radius=3.0) - assert elliptical.convergence_2d_from(grid=grid) == pytest.approx( - spherical.convergence_2d_from(grid=grid), 1e-4 + assert elliptical.convergence_2d_from(grid=grid).array == pytest.approx( + spherical.convergence_2d_from(grid=grid).array, 1e-4 ) @@ -119,19 +119,19 @@ def test__shear_yx_2d_from(): shear = mp.shear_yx_2d_from(grid=ag.Grid2DIrregular([[0.0, 1.0]])) assert shear[0, 0] == pytest.approx(0.0, 1e-4) - assert shear[0, 1] == pytest.approx(-convergence[0], 1e-4) + assert shear[0, 1] == pytest.approx(-convergence.array[0], 1e-4) convergence = mp.convergence_2d_from(grid=ag.Grid2DIrregular([[2.0, 1.0]])) shear = mp.shear_yx_2d_from(grid=ag.Grid2DIrregular([[2.0, 1.0]])) - assert shear[0, 0] == pytest.approx(-(4.0 / 5.0) * convergence[0], 1e-4) - assert shear[0, 1] == pytest.approx((3.0 / 5.0) * convergence[0], 1e-4) + assert shear[0, 0] == pytest.approx(-(4.0 / 5.0) * convergence.array[0], 1e-4) + assert shear[0, 1] == pytest.approx((3.0 / 5.0) * convergence.array[0], 1e-4) convergence = mp.convergence_2d_from(grid=ag.Grid2DIrregular([[3.0, 5.0]])) shear = mp.shear_yx_2d_from(grid=ag.Grid2DIrregular([[3.0, 5.0]])) - assert shear[0, 0] == pytest.approx(-(30.0 / 34.0) * convergence[0], 1e-4) - assert shear[0, 1] == pytest.approx(-(16.0 / 34.0) * convergence[0], 1e-4) + assert shear[0, 0] == pytest.approx(-(30.0 / 34.0) * convergence.array[0], 1e-4) + assert shear[0, 1] == pytest.approx(-(16.0 / 34.0) * convergence.array[0], 1e-4) mp = ag.mp.Isothermal(centre=(0.0, 0.0), ell_comps=(0.0, 0.0), einstein_radius=2.0) @@ -140,7 +140,7 @@ def test__shear_yx_2d_from(): shear = mp.shear_yx_2d_from(grid=ag.Grid2DIrregular([[0.0, 1.0]])) assert shear[0, 0] == pytest.approx(0.0, 1e-4) - assert shear[0, 1] == pytest.approx(-convergence[0], 1e-4) + assert shear[0, 1] == pytest.approx(-convergence.array[0], 1e-4) mp = ag.mp.Isothermal(centre=(0.0, 0.0), ell_comps=(0.3, 0.4), einstein_radius=2.0) diff --git a/test_autogalaxy/profiles/mass/total/test_isothermal_cored.py b/test_autogalaxy/profiles/mass/total/test_isothermal_cored.py index 88cb13e1e..143a1d294 100644 --- a/test_autogalaxy/profiles/mass/total/test_isothermal_cored.py +++ b/test_autogalaxy/profiles/mass/total/test_isothermal_cored.py @@ -150,8 +150,8 @@ def test__convergence_2d_from(): centre=(1.1, 1.1), einstein_radius=3.0, core_radius=1.0 ) - assert elliptical.convergence_2d_from(grid=grid) == pytest.approx( - spherical.convergence_2d_from(grid=grid), 1e-4 + assert elliptical.convergence_2d_from(grid=grid).array == pytest.approx( + spherical.convergence_2d_from(grid=grid).array, 1e-4 ) diff --git a/test_autogalaxy/profiles/mass/total/test_power_law.py b/test_autogalaxy/profiles/mass/total/test_power_law.py index b78f9d335..856340d1e 100644 --- a/test_autogalaxy/profiles/mass/total/test_power_law.py +++ b/test_autogalaxy/profiles/mass/total/test_power_law.py @@ -140,8 +140,8 @@ def test__convergence_2d_from(): spherical = ag.mp.PowerLawSph(centre=(1.1, 1.1), einstein_radius=3.0, slope=2.4) - assert elliptical.convergence_2d_from(grid=grid) == pytest.approx( - spherical.convergence_2d_from(grid=grid), 1e-4 + assert elliptical.convergence_2d_from(grid=grid).array == pytest.approx( + spherical.convergence_2d_from(grid=grid).array, 1e-4 ) diff --git a/test_autogalaxy/profiles/mass/total/test_power_law_cored.py b/test_autogalaxy/profiles/mass/total/test_power_law_cored.py index e585a5ef7..5c4efa896 100644 --- a/test_autogalaxy/profiles/mass/total/test_power_law_cored.py +++ b/test_autogalaxy/profiles/mass/total/test_power_law_cored.py @@ -114,8 +114,8 @@ def test__convergence_2d_from(): centre=(1.1, 1.1), einstein_radius=3.0, slope=2.2, core_radius=0.1 ) - assert elliptical.convergence_2d_from(grid=grid) == pytest.approx( - spherical.convergence_2d_from(grid=grid), 1e-4 + assert elliptical.convergence_2d_from(grid=grid).array == pytest.approx( + spherical.convergence_2d_from(grid=grid).array, 1e-4 ) diff --git a/test_autogalaxy/profiles/plot/test_light_profile_plotters.py b/test_autogalaxy/profiles/plot/test_light_profile_plotters.py index d843bb896..e39e6cf77 100644 --- a/test_autogalaxy/profiles/plot/test_light_profile_plotters.py +++ b/test_autogalaxy/profiles/plot/test_light_profile_plotters.py @@ -20,7 +20,6 @@ def test__figures_1d__all_are_output( lp_1, grid_2d_7x7, grid_2d_irregular_7x7_list, - include_1d_all, plot_path, plot_patch, ): @@ -33,7 +32,6 @@ def test__figures_1d__all_are_output( light_profile_plotter = aplt.LightProfilePlotter( light_profile=lp_0, grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=mat_plot_1d, ) @@ -48,7 +46,6 @@ def test__figures_1d__all_are_output( light_profile_plotter = aplt.LightProfilePDFPlotter( light_profile_pdf_list=[lp_0, lp_1, lp_0, lp_1, lp_0, lp_offset_centre], grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=mat_plot_1d, sigma=2.0, ) @@ -62,14 +59,12 @@ def test__figures_2d__all_are_output( lp_0, grid_2d_7x7, grid_2d_irregular_7x7_list, - include_2d_all, plot_path, plot_patch, ): light_profile_plotter = aplt.LightProfilePlotter( light_profile=lp_0, grid=grid_2d_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) diff --git a/test_autogalaxy/profiles/plot/test_mass_profile_plotters.py b/test_autogalaxy/profiles/plot/test_mass_profile_plotters.py index 847752268..2b1b9bbe5 100644 --- a/test_autogalaxy/profiles/plot/test_mass_profile_plotters.py +++ b/test_autogalaxy/profiles/plot/test_mass_profile_plotters.py @@ -19,7 +19,6 @@ def test__figures_1d__all_are_output( mp_1, grid_2d_7x7, grid_2d_irregular_7x7_list, - include_1d_all, plot_path, plot_patch, ): @@ -32,7 +31,6 @@ def test__figures_1d__all_are_output( mass_profile_plotter = aplt.MassProfilePlotter( mass_profile=mp_0, grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=mat_plot_1d, ) @@ -48,7 +46,6 @@ def test__figures_1d__all_are_output( mass_profile_plotter = aplt.MassProfilePDFPlotter( mass_profile_pdf_list=[mp_0, mp_1, mp_0, mp_1, mp_0, mp_offset_centre], grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=mat_plot_1d, ) @@ -62,14 +59,12 @@ def test__figures_2d__all_are_output( mp_0, grid_2d_7x7, grid_2d_irregular_7x7_list, - include_2d_all, plot_path, plot_patch, ): mass_profile_plotter = aplt.MassProfilePlotter( mass_profile=mp_0, grid=grid_2d_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) mass_profile_plotter.figures_2d( diff --git a/test_autogalaxy/profiles/test_basis.py b/test_autogalaxy/profiles/test_basis.py index 3739ebf28..40a6250cd 100644 --- a/test_autogalaxy/profiles/test_basis.py +++ b/test_autogalaxy/profiles/test_basis.py @@ -86,4 +86,6 @@ def test__mass_profile_quantities(grid_2d_7x7, mp_0, mp_1): convergence_2d = basis.convergence_2d_from(grid=grid_2d_7x7) - assert convergence_2d == pytest.approx(convergence_2d_0 + convergence_2d_1, 1.0e-4) + assert convergence_2d.array == pytest.approx( + convergence_2d_0.array + convergence_2d_1.array, 1.0e-4 + ) diff --git a/test_autogalaxy/quantity/model/test_plotter_interface_quantity.py b/test_autogalaxy/quantity/model/test_plotter_interface_quantity.py index eeb52afc5..eae1a139b 100644 --- a/test_autogalaxy/quantity/model/test_plotter_interface_quantity.py +++ b/test_autogalaxy/quantity/model/test_plotter_interface_quantity.py @@ -16,7 +16,6 @@ def make_plotter_interface_plotter_setup(): def test__dataset( dataset_quantity_7x7_array_2d, - include_2d_all, plot_path, plot_patch, ): @@ -37,7 +36,6 @@ def test__dataset( def test__fit_quantity( fit_quantity_7x7_array_2d, fit_quantity_7x7_vector_yx_2d, - include_2d_all, plot_path, plot_patch, ): diff --git a/test_autogalaxy/quantity/plot/test_fit_quantity_plotters.py b/test_autogalaxy/quantity/plot/test_fit_quantity_plotters.py index 84f5bb3b2..94265e502 100644 --- a/test_autogalaxy/quantity/plot/test_fit_quantity_plotters.py +++ b/test_autogalaxy/quantity/plot/test_fit_quantity_plotters.py @@ -20,13 +20,11 @@ def make_galaxy_fit_plotter_setup(): def test__fit_individuals__source_and_galaxy__dependent_on_input( fit_quantity_7x7_array_2d, fit_quantity_7x7_vector_yx_2d, - include_2d_all, plot_path, plot_patch, ): fit_quantity_plotter = aplt.FitQuantityPlotter( fit=fit_quantity_7x7_array_2d, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) @@ -39,7 +37,6 @@ def test__fit_individuals__source_and_galaxy__dependent_on_input( fit_quantity_plotter = aplt.FitQuantityPlotter( fit=fit_quantity_7x7_vector_yx_2d, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) @@ -58,7 +55,6 @@ def test__fit_individuals__source_and_galaxy__dependent_on_input( def test__fit_sub_plot__all_types_of_fit( fit_quantity_7x7_array_2d, fit_quantity_7x7_vector_yx_2d, - include_2d_all, plot_patch, plot_path, ): From 07c2bcdfbad8b8088921f6dc8c319104462a9576 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 21 Jul 2025 20:44:07 +0100 Subject: [PATCH 2/4] image refactor progress --- .../ellipse/plot/fit_ellipse_plotters.py | 8 +- autogalaxy/galaxy/plot/adapt_plotters.py | 7 +- autogalaxy/galaxy/plot/galaxies_plotters.py | 19 +- autogalaxy/galaxy/plot/galaxy_plotters.py | 51 +-- .../imaging/plot/fit_imaging_plotters.py | 10 +- .../plot/fit_interferometer_plotters.py | 8 +- autogalaxy/operate/deflections.py | 1 - autogalaxy/plot/abstract_plotters.py | 12 - autogalaxy/plot/get_visuals/__init__.py | 0 autogalaxy/plot/get_visuals/one_d.py | 218 ----------- autogalaxy/plot/get_visuals/two_d.py | 274 -------------- autogalaxy/plot/mass_plotter.py | 28 +- autogalaxy/plot/mat_plot/two_d.py | 4 + autogalaxy/plot/visuals/one_d.py | 183 +++++++++- autogalaxy/plot/visuals/two_d.py | 345 ++++++++++++------ autogalaxy/profiles/plot/basis_plotters.py | 8 +- .../profiles/plot/light_profile_plotters.py | 22 +- .../profiles/plot/mass_profile_plotters.py | 21 +- .../quantity/plot/fit_quantity_plotters.py | 15 - .../plot/mat_wrap/test_get_visuals.py | 156 -------- test_autogalaxy/plot/mat_wrap/test_visuals.py | 83 +++++ 21 files changed, 561 insertions(+), 912 deletions(-) delete mode 100644 autogalaxy/plot/get_visuals/__init__.py delete mode 100644 autogalaxy/plot/get_visuals/one_d.py delete mode 100644 autogalaxy/plot/get_visuals/two_d.py delete mode 100644 test_autogalaxy/plot/mat_wrap/test_get_visuals.py create mode 100644 test_autogalaxy/plot/mat_wrap/test_visuals.py diff --git a/autogalaxy/ellipse/plot/fit_ellipse_plotters.py b/autogalaxy/ellipse/plot/fit_ellipse_plotters.py index 8a968569b..d65d9bcd3 100644 --- a/autogalaxy/ellipse/plot/fit_ellipse_plotters.py +++ b/autogalaxy/ellipse/plot/fit_ellipse_plotters.py @@ -30,12 +30,6 @@ def __init__( self.fit_list = fit_list - def get_visuals_1d(self) -> Visuals1D: - return self.visuals_1d - - def get_visuals_2d(self): - return self.get_2d.via_mask_from(mask=self.fit_list[0].dataset.mask) - def figures_2d( self, data: bool = False, @@ -81,7 +75,7 @@ def figures_2d( ellipse_list.append(aa.Grid2DIrregular.from_yx_1d(y=y, x=x)) - visuals_2d = self.get_visuals_2d() + Visuals2D( + visuals_2d = self.visuals_2d + Visuals2D( positions=ellipse_list, lines=ellipse_list ) diff --git a/autogalaxy/galaxy/plot/adapt_plotters.py b/autogalaxy/galaxy/plot/adapt_plotters.py index ef173339e..a2b07e2ef 100644 --- a/autogalaxy/galaxy/plot/adapt_plotters.py +++ b/autogalaxy/galaxy/plot/adapt_plotters.py @@ -17,9 +17,6 @@ def __init__( ): super().__init__(mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d) - def get_visuals_2d(self) -> Visuals2D: - return self.visuals_2d - def figure_model_image(self, model_image: aa.Array2D): """ Plots the adapt model image (e.g. sum of all individual galaxy model images). @@ -32,7 +29,7 @@ def figure_model_image(self, model_image: aa.Array2D): self.mat_plot_2d.plot_array( array=model_image, - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels( title="adapt image", filename="adapt_model_image" ), @@ -49,7 +46,7 @@ def figure_galaxy_image(self, galaxy_image: aa.Array2D): """ self.mat_plot_2d.plot_array( array=galaxy_image, - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels( title="galaxy Image", filename="adapt_galaxy_image" ), diff --git a/autogalaxy/galaxy/plot/galaxies_plotters.py b/autogalaxy/galaxy/plot/galaxies_plotters.py index dba5f0a83..56522360f 100644 --- a/autogalaxy/galaxy/plot/galaxies_plotters.py +++ b/autogalaxy/galaxy/plot/galaxies_plotters.py @@ -77,21 +77,10 @@ def __init__( self._mass_plotter = MassPlotter( mass_obj=self.galaxies, grid=self.grid, - get_visuals_2d=self.get_visuals_2d, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.visuals_2d, ) - def get_visuals_2d(self) -> Visuals2D: - return self.get_2d.via_light_mass_obj_from( - light_mass_obj=self.galaxies, grid=self.grid - ) - - def get_visuals_2d_of_galaxy(self, galaxy_index: int) -> aplt.Visuals2D: - return self.get_2d.via_galaxies_from( - galaxies=self.galaxies, grid=self.grid, galaxy_index=galaxy_index - ) - def galaxy_plotter_from(self, galaxy_index: int) -> GalaxyPlotter: """ Returns an `GalaxyPlotter` corresponding to a `Galaxy` in the `Tracer`. @@ -106,7 +95,7 @@ def galaxy_plotter_from(self, galaxy_index: int) -> GalaxyPlotter: galaxy=self.galaxies[galaxy_index], grid=self.grid, mat_plot_2d=self.mat_plot_2d, - visuals_2d=self.get_visuals_2d_of_galaxy(galaxy_index=galaxy_index), + visuals_2d=self._mass_plotter.visuals_2d_with_critical_curves, ) def figures_2d( @@ -159,7 +148,7 @@ def figures_2d( if image: self.mat_plot_2d.plot_array( array=self.galaxies.image_2d_from(grid=self.grid), - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels( title=f"Image{title_suffix}", filename=f"image_2d{filename_suffix}" ), @@ -175,7 +164,7 @@ def figures_2d( array=self.galaxies.plane_image_2d_from( grid=self.grid, zoom_to_brightest=zoom_to_brightest ), - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels( title=title, filename=f"plane_image{filename_suffix}", @@ -190,7 +179,7 @@ def figures_2d( self.mat_plot_2d.plot_grid( grid=self.grid, - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels( title=title, filename=f"plane_grid{filename_suffix}", diff --git a/autogalaxy/galaxy/plot/galaxy_plotters.py b/autogalaxy/galaxy/plot/galaxy_plotters.py index afd19d5b6..f03fbe83d 100644 --- a/autogalaxy/galaxy/plot/galaxy_plotters.py +++ b/autogalaxy/galaxy/plot/galaxy_plotters.py @@ -87,22 +87,10 @@ def __init__( self._mass_plotter = MassPlotter( mass_obj=self.galaxy, grid=self.grid, - get_visuals_2d=self.get_visuals_2d, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.visuals_2d, ) - def get_visuals_1d_light(self) -> Visuals1D: - return self.get_1d.via_light_obj_from(light_obj=self.galaxy) - - def get_visuals_1d_mass(self) -> Visuals1D: - return self.get_1d.via_mass_obj_from(mass_obj=self.galaxy, grid=self.grid) - - def get_visuals_2d(self) -> Visuals2D: - return self.get_2d.via_light_mass_obj_from( - light_mass_obj=self.galaxy, grid=self.grid - ) - def light_profile_plotter_from( self, light_profile: LightProfile, one_d_only: bool = False ) -> LightProfilePlotter: @@ -124,22 +112,23 @@ def light_profile_plotter_from( from autogalaxy.profiles.plot.light_profile_plotters import LightProfilePlotter if not one_d_only: + return LightProfilePlotter( light_profile=light_profile, grid=self.grid, mat_plot_2d=self.mat_plot_2d, - visuals_2d=self.get_2d.via_light_obj_from( - light_obj=light_profile, grid=self.grid - ), + visuals_2d=self.visuals_2d, mat_plot_1d=self.mat_plot_1d, - visuals_1d=self.get_1d.via_light_obj_from(light_obj=light_profile), + visuals_1d=self.visuals_1d + + Visuals1D().add_half_light_radius(light_obj=light_profile), ) return LightProfilePlotter( light_profile=light_profile, grid=self.grid, mat_plot_1d=self.mat_plot_1d, - visuals_1d=self.get_1d.via_light_obj_from(light_obj=light_profile), + visuals_1d=self.visuals_1d + + Visuals1D().add_half_light_radius(light_obj=light_profile), ) def mass_profile_plotter_from( @@ -165,11 +154,10 @@ def mass_profile_plotter_from( mass_profile=mass_profile, grid=self.grid, mat_plot_2d=self.mat_plot_2d, - visuals_2d=self.get_2d.via_mass_obj_from( - mass_obj=mass_profile, grid=self.grid - ), + visuals_2d=self._mass_plotter.visuals_2d_with_critical_curves, mat_plot_1d=self.mat_plot_1d, - visuals_1d=self.get_1d.via_mass_obj_from( + visuals_1d=self.visuals_1d + + Visuals1D().add_einstein_radius( mass_obj=mass_profile, grid=self.grid ), ) @@ -178,9 +166,8 @@ def mass_profile_plotter_from( mass_profile=mass_profile, grid=self.grid, mat_plot_1d=self.mat_plot_1d, - visuals_1d=self.get_1d.via_mass_obj_from( - mass_obj=mass_profile, grid=self.grid - ), + visuals_1d=self.visuals_1d + + Visuals1D().add_einstein_radius(mass_obj=mass_profile, grid=self.grid), ) @property @@ -246,7 +233,8 @@ def figures_1d( self.mat_plot_1d.plot_yx( y=image_1d, x=image_1d.grid_radial, - visuals_1d=self.get_visuals_1d_light(), + visuals_1d=self.visuals_1d + + Visuals1D().add_half_light_radius(self.galaxy), auto_labels=aplt.AutoLabels( title="Image vs Radius", ylabel="Image ", @@ -263,7 +251,8 @@ def figures_1d( self.mat_plot_1d.plot_yx( y=convergence_1d, x=convergence_1d.grid_radial, - visuals_1d=self.get_visuals_1d_mass(), + visuals_1d=self.visuals_1d + + Visuals1D().add_einstein_radius(mass_obj=self.galaxy, grid=self.grid), auto_labels=aplt.AutoLabels( title="Convergence vs Radius", ylabel="Convergence ", @@ -280,7 +269,7 @@ def figures_1d( self.mat_plot_1d.plot_yx( y=potential_1d, x=potential_1d.grid_radial, - visuals_1d=self.get_visuals_1d_mass(), + visuals_1d=self.visuals_1d, auto_labels=aplt.AutoLabels( title="Potential vs Radius", ylabel="Potential ", @@ -420,7 +409,7 @@ def figures_2d( if image: self.mat_plot_2d.plot_array( array=self.galaxy.image_2d_from(grid=self.grid), - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels( title=f"Image{title_suffix}", filename=f"image_2d{filename_suffix}" ), @@ -718,7 +707,7 @@ def figures_1d( profile_1d_list=image_1d_list, low_limit=self.low_limit ) - visuals_1d_via_light_obj_list = self.get_1d.via_light_obj_list_from( + visuals_1d_via_light_obj_list = Visuals1D().add_half_light_radius_errors( light_obj_list=self.galaxy_pdf_list, low_limit=self.low_limit ) visuals_1d_with_shaded_region = self.visuals_1d.__class__( @@ -765,7 +754,7 @@ def figures_1d( profile_1d_list=convergence_1d_list, low_limit=self.low_limit ) - visuals_1d_via_lensing_obj_list = self.get_1d.via_mass_obj_list_from( + visuals_1d_via_lensing_obj_list = Visuals1D().add_einstein_radius_errors( mass_obj_list=self.galaxy_pdf_list, grid=self.grid, low_limit=self.low_limit, @@ -814,7 +803,7 @@ def figures_1d( profile_1d_list=potential_1d_list, low_limit=self.low_limit ) - visuals_1d_via_lensing_obj_list = self.get_1d.via_mass_obj_list_from( + visuals_1d_via_lensing_obj_list = Visuals1D().add_einstein_radius_errors( mass_obj_list=self.galaxy_pdf_list, grid=self.grid, low_limit=self.low_limit, diff --git a/autogalaxy/imaging/plot/fit_imaging_plotters.py b/autogalaxy/imaging/plot/fit_imaging_plotters.py index 94b96fee0..a5b1cc3e5 100644 --- a/autogalaxy/imaging/plot/fit_imaging_plotters.py +++ b/autogalaxy/imaging/plot/fit_imaging_plotters.py @@ -50,7 +50,6 @@ def __init__( self._fit_imaging_meta_plotter = FitImagingPlotterMeta( fit=self.fit, - get_visuals_2d=self.get_visuals_2d, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.visuals_2d, residuals_symmetric_cmap=residuals_symmetric_cmap, @@ -59,9 +58,6 @@ def __init__( self.figures_2d = self._fit_imaging_meta_plotter.figures_2d self.subplot = self._fit_imaging_meta_plotter.subplot - def get_visuals_2d(self) -> Visuals2D: - return self.get_2d.via_fit_imaging_from(fit=self.fit) - @property def inversion_plotter(self) -> aplt.InversionPlotter: """ @@ -75,7 +71,7 @@ def inversion_plotter(self) -> aplt.InversionPlotter: return aplt.InversionPlotter( inversion=self.fit.inversion, mat_plot_2d=self.mat_plot_2d, - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, ) @property @@ -144,7 +140,7 @@ def figures_2d_of_galaxies( self.mat_plot_2d.plot_array( array=self.fit.subtracted_images_of_galaxies_list[galaxy_index], - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels( title=f"Subtracted Image of Galaxy {galaxy_index}", filename=f"subtracted_image_of_galaxy_{galaxy_index}", @@ -154,7 +150,7 @@ def figures_2d_of_galaxies( if model_image: self.mat_plot_2d.plot_array( array=self.fit.model_images_of_galaxies_list[galaxy_index], - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels( title=f"Model Image of Galaxy {galaxy_index}", filename=f"model_image_of_galaxy_{galaxy_index}", diff --git a/autogalaxy/interferometer/plot/fit_interferometer_plotters.py b/autogalaxy/interferometer/plot/fit_interferometer_plotters.py index a2adf89e8..1dbddd50d 100644 --- a/autogalaxy/interferometer/plot/fit_interferometer_plotters.py +++ b/autogalaxy/interferometer/plot/fit_interferometer_plotters.py @@ -65,7 +65,6 @@ def __init__( self._fit_interferometer_meta_plotter = FitInterferometerPlotterMeta( fit=self.fit, - get_visuals_2d_real_space=self.get_visuals_2d_real_space, mat_plot_1d=self.mat_plot_1d, visuals_1d=self.visuals_1d, mat_plot_2d=self.mat_plot_2d, @@ -80,9 +79,6 @@ def __init__( self._fit_interferometer_meta_plotter.subplot_fit_dirty_images ) - def get_visuals_2d_real_space(self) -> Visuals2D: - return self.get_2d.via_mask_from(mask=self.fit.dataset.real_space_mask) - @property def galaxies(self) -> List[Galaxy]: return self.fit.galaxies_linear_light_profiles_to_light_profiles @@ -100,7 +96,7 @@ def galaxies_plotter_from(self, galaxies: List[Galaxy]) -> GalaxiesPlotter: galaxies=galaxies, grid=self.fit.grids.lp, mat_plot_2d=self.mat_plot_2d, - visuals_2d=self.get_visuals_2d_real_space(), + visuals_2d=self.visuals_2d, ) @property @@ -116,7 +112,7 @@ def inversion_plotter(self) -> aplt.InversionPlotter: return aplt.InversionPlotter( inversion=self.fit.inversion, mat_plot_2d=self.mat_plot_2d, - visuals_2d=self.get_visuals_2d_real_space(), + visuals_2d=self.visuals_2d, ) def subplot_fit(self): diff --git a/autogalaxy/operate/deflections.py b/autogalaxy/operate/deflections.py index d90498a8a..27286bcae 100644 --- a/autogalaxy/operate/deflections.py +++ b/autogalaxy/operate/deflections.py @@ -441,7 +441,6 @@ def tangential_critical_curve_list_from( If input, the `evaluation_grid` decorator creates the 2D grid at this resolution, therefore enabling the critical curve to be computed more accurately using a higher resolution grid. """ - print("aaaa") tangential_eigen_values = self.tangential_eigen_value_from(grid=grid) return self.contour_list_from(grid=grid, contour_array=tangential_eigen_values) diff --git a/autogalaxy/plot/abstract_plotters.py b/autogalaxy/plot/abstract_plotters.py index 828350c82..3acd36679 100644 --- a/autogalaxy/plot/abstract_plotters.py +++ b/autogalaxy/plot/abstract_plotters.py @@ -32,15 +32,3 @@ def __init__( self.visuals_2d = visuals_2d or Visuals2D() self.mat_plot_2d = mat_plot_2d or MatPlot2D() - - @property - def get_1d(self): - from autogalaxy.plot.get_visuals.one_d import GetVisuals1D - - return GetVisuals1D(visuals=self.visuals_1d) - - @property - def get_2d(self): - from autogalaxy.plot.get_visuals.two_d import GetVisuals2D - - return GetVisuals2D(visuals=self.visuals_2d) diff --git a/autogalaxy/plot/get_visuals/__init__.py b/autogalaxy/plot/get_visuals/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/autogalaxy/plot/get_visuals/one_d.py b/autogalaxy/plot/get_visuals/one_d.py deleted file mode 100644 index d8c2a5f6e..000000000 --- a/autogalaxy/plot/get_visuals/one_d.py +++ /dev/null @@ -1,218 +0,0 @@ -import logging -from typing import List, Union - -import autoarray as aa -import autoarray.plot as aplt - -from autogalaxy.galaxy.galaxy import Galaxy -from autogalaxy.plot.visuals.one_d import Visuals1D -from autogalaxy.profiles.light.abstract import LightProfile -from autogalaxy.profiles.mass.abstract.abstract import MassProfile - -from autogalaxy.util import error_util - -logger = logging.getLogger(__name__) - - -class GetVisuals1D(aplt.GetVisuals1D): - def __init__(self, visuals: Visuals1D): - """ - Class which gets 1D attributes and adds them to a `Visuals1D` objects, such that they are plotted on 1D figures. - - The `GetVisuals1D` class adds new visuals to a pre-existing `Visuals1D` object that is passed to its `__init__` - method. This only adds a new entry if the visual are not already in this object. - - Parameters - ---------- - visuals - The pre-existing visuals of the plotter which new visuals are added too via the `GetVisuals1D` class. - """ - super().__init__(visuals=visuals) - - def via_light_obj_from(self, light_obj: Union[LightProfile, Galaxy]) -> Visuals1D: - """ - From an object with light profiles (e.g. a `LightProfile`, `Galaxy`) get its attributes that can be plotted - and return them in a `Visuals1D` object. - - Only attributes not already in `self.visuals` are extracted for plotting. - - From a light object the following 1D attributes can be extracted for plotting: - - - half_light_radius: the radius containing 50% of the light objects total integrated luminosity. - - Parameters - ---------- - light_obj - The light object (e.g. a `LightProfile`, `Galaxy`) whose attributes are extracted for plotting. - - Returns - ------- - Visuals1D - The collection of attributes that can be plotted by a `Plotter` object. - """ - - half_light_radius = self.get( - "half_light_radius", value=light_obj.half_light_radius - ) - - return self.visuals + self.visuals.__class__( - half_light_radius=half_light_radius - ) - - def via_light_obj_list_from( - self, light_obj_list: Union[List[LightProfile], List[Galaxy]], low_limit: float - ) -> Visuals1D: - """ - From a list of objects with light profiles (e.g. a `LightProfile`, `Galaxy`) get its attributes that can be - plotted and return them in a `Visuals1D` object. - - Only attributes not already in `self.visuals` are extracted for plotting. - - This function iterates over all light objects in the list and averages over each attribute's values to estimate - the mean value of the attribute and its error, both of which can then be plotted. This is typically used - to plot 1D errors on a quantity that are estimated via a Probability Density Function. - - From a light object lust the following 1D attributes can be extracted for plotting: - - - half_light_radius: the radius containing 50% of the light objects total integrated luminosity. - - Parameters - ---------- - light_obj_list - The list of light objects (e.g. a `LightProfile`, `Galaxy`) whose mean attributes and error estimates are - extracted for plotting. - low_limit - The value of sigma to which errors are estimated (e.g. 1.0 will estimate errors at the ~0.32 and ~0.68 - intervals of the probability distribution. - - Returns - ------- - Visuals1D - The mean value and errors of each attribute that are plotted in 1D by a `Plotter` object. - """ - - half_light_radius_list = [ - light_profile.half_light_radius for light_profile in light_obj_list - ] - - if None in half_light_radius_list: - half_light_radius = None - half_light_radius_errors = None - - else: - ( - half_light_radius, - half_light_radius_errors, - ) = error_util.value_median_and_error_region_via_quantile( - value_list=half_light_radius_list, low_limit=low_limit - ) - - half_light_radius = self.get("half_light_radius", value=half_light_radius) - half_light_radius_errors = self.get( - "half_light_radius", value=half_light_radius_errors - ) - - return self.visuals + self.visuals.__class__( - half_light_radius=half_light_radius, - half_light_radius_errors=half_light_radius_errors, - ) - - def via_mass_obj_from( - self, mass_obj: Union[MassProfile, Galaxy], grid: aa.type.Grid2DLike - ) -> Visuals1D: - """ - From an object with mass profiles (e.g. a `MassProfile`, `Galaxy`) get its attributes that can be plotted - and return them in a `Visuals1D` object. - - Only attributes not already in `self.visuals` are extracted for plotting. - - From a mass object the following 1D attributes can be extracted for plotting: - - - einstein_radius: the einstein radius (e.g. area within critical curve) of the mass object. - - Mass profiles can be too shallow to do lensing and therefore an Einstein radius cannot be computed. This - raises a TypeError which is accounted for below. - - Parameters - ---------- - mass_obj - The mass object (e.g. a `MassProfile`, `Galaxy`) whose attributes are extracted for plotting. - - Returns - ------- - Visuals1D - The collection of attributes that can be plotted by a `Plotter` object. - """ - - einstein_radius = None - - try: - einstein_radius = mass_obj.einstein_radius_from(grid=grid) - except (TypeError, AttributeError): - pass - - einstein_radius = self.get("einstein_radius", value=einstein_radius) - - return self.visuals + self.visuals.__class__(einstein_radius=einstein_radius) - - def via_mass_obj_list_from( - self, - mass_obj_list: Union[List[MassProfile], List[Galaxy]], - grid: aa.type.Grid2DLike, - low_limit: float, - ) -> Visuals1D: - """ - From a list of objects with mass profiles (e.g. a `MassProfile`, `Galaxy`) get its attributes that can be - plotted and return them in a `Visuals1D` object. - - Only attributes not already in `self.visuals` are extracted for plotting. - - This function iterates over all mass objects in the list and averages over each attribute's values to estimate - the mean value of the attribute and its error, both of which can then be plotted. This is typically used - to plot 1D errors on a quantity that are estimated via a Probability Density Function. - - From a mass object lust the following 1D attributes can be extracted for plotting: - - - half_mass_radius: the radius containing 50% of the mass objects total integrated luminosity. - - Parameters - ---------- - mass_obj_list - The list of mass objects (e.g. a `MassProfile`, `Galaxy`) whose mean attributes and error estimates are - extracted for plotting. - low_limit - The value of sigma to which errors are estimated (e.g. 1.0 will estimate errors at the ~0.32 and ~0.68 - intervals of the probability distribution. - - Returns - ------- - Visuals1D - The mean value and errors of each attribute that are plotted in 1D by a `Plotter` object. - """ - - einstein_radius_list = [] - - for mass_obj in mass_obj_list: - try: - einstein_radius_list.append(mass_obj.einstein_radius_from(grid=grid)) - except TypeError: - einstein_radius_list.append(None) - - einstein_radius_list = list(filter(None, einstein_radius_list)) - - ( - einstein_radius, - einstein_radius_errors, - ) = error_util.value_median_and_error_region_via_quantile( - value_list=einstein_radius_list, low_limit=low_limit - ) - - einstein_radius = self.get("einstein_radius", value=einstein_radius) - einstein_radius_errors = self.get( - "einstein_radius", value=einstein_radius_errors - ) - - return self.visuals + self.visuals.__class__( - einstein_radius=einstein_radius, - einstein_radius_errors=einstein_radius_errors, - ) diff --git a/autogalaxy/plot/get_visuals/two_d.py b/autogalaxy/plot/get_visuals/two_d.py deleted file mode 100644 index e595ce52e..000000000 --- a/autogalaxy/plot/get_visuals/two_d.py +++ /dev/null @@ -1,274 +0,0 @@ -from typing import List, Union - -import autoarray as aa -import autoarray.plot as aplt - -from autogalaxy.imaging.fit_imaging import FitImaging -from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.profiles.light.abstract import LightProfile -from autogalaxy.profiles.mass.abstract.abstract import MassProfile -from autogalaxy.galaxy.galaxy import Galaxy - - -class GetVisuals2D(aplt.GetVisuals2D): - def __init__(self, visuals: Visuals2D): - """ - Class which gets 2D attributes and adds them to a `Visuals2D` objects, such that they are plotted on 2D figures. - - The `GetVisuals2D` class adds new visuals to a pre-existing `Visuals2D` object that is passed to - its `__init__` method. This only adds a new entry if the visual are not already in this object. - - Parameters - ---------- - include - Sets which 2D visuals are included on the figure that is to be plotted (only entries which are `True` - are extracted via the `GetVisuals2D` object). - visuals - The pre-existing visuals of the plotter which new visuals are added too via the `GetVisuals2D` class. - """ - super().__init__(visuals=visuals) - - def via_light_obj_from( - self, light_obj: Union[LightProfile, Galaxy], grid - ) -> Visuals2D: - """ - From an object with light profiles (e.g. a `LightProfile`, `Galaxy`) get its attributes that can be - plotted and return them in a `Visuals2D` object. - - Only attributes not already in `self.visuals` are extracted for plotting. - - From a light object the following 2D attributes can be extracted for plotting: - - - origin: the (y,x) origin of the coordinate system used to plot the light object's quantities in 2D. - - mask: the mask of the grid used to plot the light object's quantities in 2D. - - border: the border of this mask. - - light profile centres: the (y,x) centre of every `LightProfile` in the object. - - Parameters - ---------- - light_obj - The light object (e.g. a `LightProfile`, `Galaxy`) whose attributes are extracted for plotting. - grid - The 2D grid of (y,x) coordinates used to plot the light object's quantities in 2D. - - Returns - ------- - vis.Visuals2D - The collection of attributes that can be plotted by a `Plotter` object. - """ - - visuals_via_mask = self.via_mask_from(mask=grid.mask) - - if isinstance(light_obj, LightProfile): - light_profile_centres = self.get( - "light_profile_centres", aa.Grid2DIrregular(values=[light_obj.centre]) - ) - - else: - light_profile_centres = self.get( - "light_profile_centres", - light_obj.extract_attribute(cls=LightProfile, attr_name="centre"), - ) - - return ( - self.visuals - + visuals_via_mask - + self.visuals.__class__(light_profile_centres=light_profile_centres) - ) - - def via_mass_obj_from( - self, mass_obj: Union[MassProfile, Galaxy], grid: aa.type.Grid2DLike - ) -> Visuals2D: - """ - From an object with mass profiles (e.g. a `MassProfile`, `Galaxy`) get its attributes that can be - plotted and return them in a `Visuals2D` object. - - Only attributes not already in `self.visuals` are extracted for plotting. - - From a mass object the following 2D attributes can be extracted for plotting: - - - origin: the (y,x) origin of the coordinate system used to plot the mass object's quantities in 2D. - - mask: the mask of the grid used to plot the mass object's quantities in 2D. - - border: the border of this mask. - - mass profile centres: the (y,x) centre of every `MassProfile` in the mass object. - - critical curves: the critical curves of the mass object. - - Parameters - ---------- - mass_obj - The mass object (e.g. a `MassProfile`, `Galaxy`) whose attributes are extracted for plotting. - grid - The 2D grid of (y,x) coordinates used to plot the mass object's quantities in 2D. - - Returns - ------- - vis.Visuals2D - The collection of attributes that can be plotted by a `Plotter` object. - """ - - visuals_via_mask = self.via_mask_from(mask=grid.mask) - - if isinstance(mass_obj, MassProfile): - mass_profile_centres = self.get( - "mass_profile_centres", aa.Grid2DIrregular(values=[mass_obj.centre]) - ) - - else: - mass_profile_centres = self.get( - "mass_profile_centres", - mass_obj.extract_attribute(cls=MassProfile, attr_name="centre"), - ) - - tangential_critical_curves = self.get( - "tangential_critical_curves", - mass_obj.tangential_critical_curve_list_from(grid=grid), - ) - - radial_critical_curves = None - - radial_critical_curve_area_list = mass_obj.radial_critical_curve_area_list_from( - grid=grid - ) - - if any([area > grid.pixel_scale for area in radial_critical_curve_area_list]): - radial_critical_curves = self.get( - "radial_critical_curves", - mass_obj.radial_critical_curve_list_from(grid=grid), - ) - - return ( - self.visuals - + visuals_via_mask - + self.visuals.__class__( - mass_profile_centres=mass_profile_centres, - tangential_critical_curves=tangential_critical_curves, - radial_critical_curves=radial_critical_curves, - ) - ) - - def via_light_mass_obj_from(self, light_mass_obj: Union[Galaxy], grid) -> Visuals2D: - """ - From an object that contains both light profiles and / or mass profiles (e.g. a `Galaxy`), get the - attributes that can be plotted and returns them in a `Visuals2D` object. - - Only attributes with `True` entries in the `Include` object are extracted. - - From a light and lensing object the following attributes can be extracted for plotting: - - - origin: the (y,x) origin of the coordinate system used to plot the light object's quantities in 2D. - - light profile centres: the (y,x) centre of every `LightProfile` in the object. - - mass profile centres: the (y,x) centre of every `MassProfile` in the object. - - critical curves: the critical curves of all mass profile combined. - - Parameters - ---------- - light_mass_obj - The light and mass object (e.g. a `Galaxy`) whose attributes are extracted for plotting. - grid - The 2D grid of (y,x) coordinates used to plot the light and mass object's quantities in 2D. - - Returns - ------- - vis.Visuals2D - A collection of attributes that can be plotted by a `Plotter` object. - """ - - visuals_2d = self.via_mass_obj_from(mass_obj=light_mass_obj, grid=grid) - visuals_2d.mask = None - - visuals_with_grid = self.visuals.__class__(grid=self.get("grid", grid)) - - return ( - visuals_2d - + visuals_with_grid - + self.via_light_obj_from(light_obj=light_mass_obj, grid=grid) - ) - - def via_galaxies_from( - self, galaxies: List[Galaxy], grid: aa.type.Grid2DLike, galaxy_index: int - ) -> Visuals2D: - """ - From a list of galaxies get the attributes that can be plotted and returns them in a `Visuals2D` object. - - Only attributes with `True` entries in the `Include` object are extracted. - - From a list of galaxie the following attributes can be extracted for plotting: - - - origin: the (y,x) origin of the coordinate system used to plot the light object's quantities in 2D. - - border: the border of the mask of the grid used to plot the light object's quantities in 2D. - - light profile centres: the (y,x) centre of every `LightProfile` in the object. - - mass profile centres: the (y,x) centre of every `MassProfile` in the object. - - critical curves: the critical curves of all of the galaxy's mass profiles combined. - - caustics: the caustics of all of the galaxy's mass profiles combined. - - When plotting galaxies it is common for plots to only display quantities corresponding to one galaxy at a time - (e.g. the image of each galaxy). Therefore, quantities are only extracted from one galaxy, specified by the - input `galaxy_index`. - - Parameters - ---------- - galaxies - The galaxies which have attributes extracted for plotting. - grid - The 2D grid of (y,x) coordinates used to plot the galaxies quantities in 2D. - galaxy_index - The index of the galaxy in the galaxies which is used to extract quantities, as only one galaxy is plotted - at a time. - - Returns - ------- - vis.Visuals2D - A collection of attributes that can be plotted by a `Plotter` object. - """ - origin = self.get("origin", value=aa.Grid2DIrregular(values=[grid.origin])) - - light_profile_centres = self.get( - "light_profile_centres", - galaxies[galaxy_index].extract_attribute( - cls=LightProfile, attr_name="centre" - ), - ) - - mass_profile_centres = self.get( - "mass_profile_centres", - galaxies[galaxy_index].extract_attribute( - cls=MassProfile, attr_name="centre" - ), - ) - - return self.visuals + self.visuals.__class__( - origin=origin, - light_profile_centres=light_profile_centres, - mass_profile_centres=mass_profile_centres, - ) - - def via_fit_imaging_from(self, fit: FitImaging) -> Visuals2D: - """ - From a `FitImaging` get its attributes that can be plotted and return them in a `Visuals2D` object. - - From a `FitImaging` the following attributes can be extracted for plotting: - - - origin: the (y,x) origin of the 2D coordinate system. - - mask: the 2D mask. - - border: the border of the 2D mask, which are all of the mask's exterior edge pixels. - - light profile centres: the (y,x) centre of every `LightProfile` in the object. - - mass profile centres: the (y,x) centre of every `MassProfile` in the object. - - critical curves: the critical curves of all mass profile combined. - - Parameters - ---------- - fit - The fit imaging object whose attributes are extracted for plotting. - - Returns - ------- - Visuals2D - The collection of attributes that are plotted by a `Plotter` object. - """ - visuals_2d_via_fit = super().via_fit_imaging_from(fit=fit) - - visuals_2d_via_light_mass_obj = self.via_light_mass_obj_from( - light_mass_obj=fit.galaxies, grid=fit.grids.lp - ) - - return visuals_2d_via_fit + visuals_2d_via_light_mass_obj diff --git a/autogalaxy/plot/mass_plotter.py b/autogalaxy/plot/mass_plotter.py index 7deedaa24..c6bb69268 100644 --- a/autogalaxy/plot/mass_plotter.py +++ b/autogalaxy/plot/mass_plotter.py @@ -1,10 +1,8 @@ -from typing import Callable +from autoconf import cached_property import autoarray as aa import autoarray.plot as aplt -from autogalaxy.operate.deflections import OperateDeflections - from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.two_d import Visuals2D @@ -16,7 +14,6 @@ def __init__( self, mass_obj, grid: aa.type.Grid2DLike, - get_visuals_2d: Callable, mat_plot_2d: MatPlot2D = None, visuals_2d: Visuals2D = None, ): @@ -24,10 +21,16 @@ def __init__( self.mass_obj = mass_obj self.grid = grid - self._get_visuals_2d = get_visuals_2d - def get_visuals_2d(self) -> Visuals2D: - return self._get_visuals_2d() + @cached_property + def visuals_2d_with_critical_curves(self) -> aplt.Visuals2D: + """ + Returns the `Visuals2D` of the plotter with critical curves and caustics added, which are used to plot + the critical curves and caustics of the `Tracer` object. + """ + return self.visuals_2d.add_critical_curves_or_caustics( + mass_obj=self.mass_obj, grid=self.grid, plane_index=0 + ) def figures_2d( self, @@ -59,10 +62,11 @@ def figures_2d( magnification Whether to make a 2D plot (via `imshow`) of the magnification. """ + if convergence: self.mat_plot_2d.plot_array( array=self.mass_obj.convergence_2d_from(grid=self.grid), - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d_with_critical_curves, auto_labels=aplt.AutoLabels( title=f"Convergence{title_suffix}", filename=f"convergence_2d{filename_suffix}", @@ -73,7 +77,7 @@ def figures_2d( if potential: self.mat_plot_2d.plot_array( array=self.mass_obj.potential_2d_from(grid=self.grid), - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d_with_critical_curves, auto_labels=aplt.AutoLabels( title=f"Potential{title_suffix}", filename=f"potential_2d{filename_suffix}", @@ -89,7 +93,7 @@ def figures_2d( self.mat_plot_2d.plot_array( array=deflections_y, - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d_with_critical_curves, auto_labels=aplt.AutoLabels( title=f"Deflections Y{title_suffix}", filename=f"deflections_y_2d{filename_suffix}", @@ -105,7 +109,7 @@ def figures_2d( self.mat_plot_2d.plot_array( array=deflections_x, - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d_with_critical_curves, auto_labels=aplt.AutoLabels( title=f"Deflections X{title_suffix}", filename=f"deflections_x_2d{filename_suffix}", @@ -116,7 +120,7 @@ def figures_2d( if magnification: self.mat_plot_2d.plot_array( array=self.mass_obj.magnification_2d_from(grid=self.grid), - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d_with_critical_curves, auto_labels=aplt.AutoLabels( title=f"Magnification{title_suffix}", filename=f"magnification_2d{filename_suffix}", diff --git a/autogalaxy/plot/mat_plot/two_d.py b/autogalaxy/plot/mat_plot/two_d.py index eebc44048..060547d4f 100644 --- a/autogalaxy/plot/mat_plot/two_d.py +++ b/autogalaxy/plot/mat_plot/two_d.py @@ -25,6 +25,7 @@ def __init__( output: Optional[aplt.Output] = None, array_overlay: Optional[aplt.ArrayOverlay] = None, contour: Optional[aplt.Contour] = None, + fill: Optional[aplt.Fill] = None, grid_scatter: Optional[aplt.GridScatter] = None, grid_plot: Optional[aplt.GridPlot] = None, vector_yx_quiver: Optional[aplt.VectorYXQuiver] = None, @@ -110,6 +111,8 @@ def __init__( Overlays an input `Array2D` over the figure using `plt.imshow`. contour Overlays contours of an input `Array2D` over the figure using `plt.contour`. + fill + Sets the fill of the figure using `plt.fill` and customizes its appearance, such as the color and alpha. grid_scatter Scatters a `Grid2D` of (y,x) coordinates over the figure using `plt.scatter`. grid_plot @@ -204,6 +207,7 @@ def __init__( patch_overlay=patch_overlay, array_overlay=array_overlay, contour=contour, + fill=fill, grid_plot=grid_plot, interpolated_reconstruction=interpolated_reconstruction, delaunay_drawer=delaunay_drawer, diff --git a/autogalaxy/plot/visuals/one_d.py b/autogalaxy/plot/visuals/one_d.py index f25203137..7d69d112a 100644 --- a/autogalaxy/plot/visuals/one_d.py +++ b/autogalaxy/plot/visuals/one_d.py @@ -1,9 +1,19 @@ +from __future__ import annotations + import numpy as np -from typing import List, Union, Optional +from typing import List, Union, Optional, TYPE_CHECKING import autoarray as aa import autoarray.plot as aplt +if TYPE_CHECKING: + + from autogalaxy.galaxy.galaxy import Galaxy + from autogalaxy.profiles.light.abstract import LightProfile + from autogalaxy.profiles.mass.abstract.abstract import MassProfile + +from autogalaxy.util import error_util + class Visuals1D(aplt.Visuals1D): def __init__( @@ -54,3 +64,174 @@ def plot_via_plotter(self, plotter, grid_indexes=None, mapper=None): plotter.model_fluxes_yx_scatter.scatter_yx( y=self.model_fluxes, x=np.arange(len(self.model_fluxes)) ) + + def add_half_light_radius( + self, light_obj: Union[LightProfile, Galaxy] + ) -> "Visuals1D": + """ + From an object with light profiles (e.g. a `LightProfile`, `Galaxy`) get its attributes that can be plotted + and return them in a `Visuals1D` object. + + Only attributes not already in `self` are extracted for plotting. + + From a light object the following 1D attributes can be extracted for plotting: + + - half_light_radius: the radius containing 50% of the light objects total integrated luminosity. + + Parameters + ---------- + light_obj + The light object (e.g. a `LightProfile`, `Galaxy`) whose attributes are extracted for plotting. + + Returns + ------- + Visuals1D + The collection of attributes that can be plotted by a `Plotter` object. + """ + return self + self.__class__(half_light_radius=light_obj.half_light_radius) + + def add_half_light_radius_errors( + self, light_obj_list: Union[List[LightProfile], List[Galaxy]], low_limit: float + ) -> "Visuals1D": + """ + From a list of objects with light profiles (e.g. a `LightProfile`, `Galaxy`) get its attributes that can be + plotted and return them in a `Visuals1D` object. + + Only attributes not already in `self` are extracted for plotting. + + This function iterates over all light objects in the list and averages over each attribute's values to estimate + the mean value of the attribute and its error, both of which can then be plotted. This is typically used + to plot 1D errors on a quantity that are estimated via a Probability Density Function. + + From a light object lust the following 1D attributes can be extracted for plotting: + + - half_light_radius: the radius containing 50% of the light objects total integrated luminosity. + + Parameters + ---------- + light_obj_list + The list of light objects (e.g. a `LightProfile`, `Galaxy`) whose mean attributes and error estimates are + extracted for plotting. + low_limit + The value of sigma to which errors are estimated (e.g. 1.0 will estimate errors at the ~0.32 and ~0.68 + intervals of the probability distribution. + + Returns + ------- + Visuals1D + The mean value and errors of each attribute that are plotted in 1D by a `Plotter` object. + """ + + half_light_radius_list = [ + light_profile.half_light_radius for light_profile in light_obj_list + ] + + if None in half_light_radius_list: + half_light_radius = None + half_light_radius_errors = None + + else: + ( + half_light_radius, + half_light_radius_errors, + ) = error_util.value_median_and_error_region_via_quantile( + value_list=half_light_radius_list, low_limit=low_limit + ) + + return self + self.__class__( + half_light_radius=half_light_radius, + half_light_radius_errors=half_light_radius_errors, + ) + + def add_einstein_radius( + self, mass_obj: Union[MassProfile, Galaxy], grid: aa.type.Grid2DLike + ) -> "Visuals1D": + """ + From an object with mass profiles (e.g. a `MassProfile`, `Galaxy`) get its attributes that can be plotted + and return them in a `Visuals1D` object. + + Only attributes not already in `self` are extracted for plotting. + + From a mass object the following 1D attributes can be extracted for plotting: + + - einstein_radius: the einstein radius (e.g. area within critical curve) of the mass object. + + Mass profiles can be too shallow to do lensing and therefore an Einstein radius cannot be computed. This + raises a TypeError which is accounted for below. + + Parameters + ---------- + mass_obj + The mass object (e.g. a `MassProfile`, `Galaxy`) whose attributes are extracted for plotting. + + Returns + ------- + Visuals1D + The collection of attributes that can be plotted by a `Plotter` object. + """ + + einstein_radius = None + + try: + einstein_radius = mass_obj.einstein_radius_from(grid=grid) + except (TypeError, AttributeError): + pass + + return self + self.__class__(einstein_radius=einstein_radius) + + def add_einstein_radius_errors( + self, + mass_obj_list: Union[List[MassProfile], List[Galaxy]], + grid: aa.type.Grid2DLike, + low_limit: float, + ) -> "Visuals1D": + """ + From a list of objects with mass profiles (e.g. a `MassProfile`, `Galaxy`) get its attributes that can be + plotted and return them in a `Visuals1D` object. + + Only attributes not already in `self` are extracted for plotting. + + This function iterates over all mass objects in the list and averages over each attribute's values to estimate + the mean value of the attribute and its error, both of which can then be plotted. This is typically used + to plot 1D errors on a quantity that are estimated via a Probability Density Function. + + From a mass object lust the following 1D attributes can be extracted for plotting: + + - half_mass_radius: the radius containing 50% of the mass objects total integrated luminosity. + + Parameters + ---------- + mass_obj_list + The list of mass objects (e.g. a `MassProfile`, `Galaxy`) whose mean attributes and error estimates are + extracted for plotting. + low_limit + The value of sigma to which errors are estimated (e.g. 1.0 will estimate errors at the ~0.32 and ~0.68 + intervals of the probability distribution. + + Returns + ------- + Visuals1D + The mean value and errors of each attribute that are plotted in 1D by a `Plotter` object. + """ + + einstein_radius_list = [] + + for mass_obj in mass_obj_list: + try: + einstein_radius_list.append(mass_obj.einstein_radius_from(grid=grid)) + except TypeError: + einstein_radius_list.append(None) + + einstein_radius_list = list(filter(None, einstein_radius_list)) + + ( + einstein_radius, + einstein_radius_errors, + ) = error_util.value_median_and_error_region_via_quantile( + value_list=einstein_radius_list, low_limit=low_limit + ) + + return self + self.__class__( + einstein_radius=einstein_radius, + einstein_radius_errors=einstein_radius_errors, + ) diff --git a/autogalaxy/plot/visuals/two_d.py b/autogalaxy/plot/visuals/two_d.py index 5cd816214..1c33e86bf 100644 --- a/autogalaxy/plot/visuals/two_d.py +++ b/autogalaxy/plot/visuals/two_d.py @@ -1,115 +1,230 @@ -from typing import List, Union, Optional - -import autoarray as aa -import autoarray.plot as aplt - - -class Visuals2D(aplt.Visuals2D): - def __init__( - self, - origin: aa.Grid2D = None, - border: aa.Grid2D = None, - mask: aa.Mask2D = None, - lines: Optional[Union[List[aa.Array1D], aa.Grid2DIrregular]] = None, - positions: Optional[Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]]] = None, - grid: Union[aa.Grid2D] = None, - mesh_grid: aa.Grid2D = None, - vectors: aa.VectorYX2DIrregular = None, - patches: "Union[ptch.Patch]" = None, - array_overlay: aa.Array2D = None, - light_profile_centres: aa.Grid2DIrregular = None, - mass_profile_centres: aa.Grid2DIrregular = None, - multiple_images: aa.Grid2DIrregular = None, - tangential_critical_curves: Optional[ - Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]] - ] = None, - radial_critical_curves: Optional[ - Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]] - ] = None, - tangential_caustics: Optional[ - Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]] - ] = None, - radial_caustics: Optional[ - Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]] - ] = None, - parallel_overscan=None, - serial_prescan=None, - serial_overscan=None, - indexes: Union[List[int], List[List[int]]] = None, - pix_indexes: Union[List[int], List[List[int]]] = None, - ): - super().__init__( - mask=mask, - positions=positions, - grid=grid, - lines=lines, - mesh_grid=mesh_grid, - vectors=vectors, - patches=patches, - array_overlay=array_overlay, - origin=origin, - border=border, - parallel_overscan=parallel_overscan, - serial_prescan=serial_prescan, - serial_overscan=serial_overscan, - indexes=indexes, - pix_indexes=pix_indexes, - ) - - self.light_profile_centres = light_profile_centres - self.mass_profile_centres = mass_profile_centres - self.multiple_images = multiple_images - self.tangential_critical_curves = tangential_critical_curves - self.radial_critical_curves = radial_critical_curves - self.tangential_caustics = tangential_caustics - self.radial_caustics = radial_caustics - - def plot_via_plotter(self, plotter, grid_indexes=None, mapper=None, geometry=None): - super().plot_via_plotter( - plotter=plotter, grid_indexes=grid_indexes, mapper=mapper, geometry=geometry - ) - - if self.light_profile_centres is not None: - plotter.light_profile_centres_scatter.scatter_grid( - grid=self.light_profile_centres - ) - - if self.mass_profile_centres is not None: - plotter.mass_profile_centres_scatter.scatter_grid( - grid=self.mass_profile_centres - ) - - if self.multiple_images is not None: - plotter.multiple_images_scatter.scatter_grid( - grid=self.multiple_images.array - ) - - if self.tangential_critical_curves is not None: - try: - plotter.tangential_critical_curves_plot.plot_grid( - grid=self.tangential_critical_curves - ) - except TypeError: - pass - - if self.radial_critical_curves is not None: - try: - plotter.radial_critical_curves_plot.plot_grid( - grid=self.radial_critical_curves - ) - except TypeError: - pass - - if self.tangential_caustics is not None: - try: - plotter.tangential_caustics_plot.plot_grid( - grid=self.tangential_caustics - ) - except TypeError: - pass - - if self.radial_caustics is not None: - try: - plotter.radial_caustics_plot.plot_grid(grid=self.radial_caustics) - except TypeError: - pass +from typing import List, Union, Optional + +import autoarray as aa +import autoarray.plot as aplt + + +class Visuals2D(aplt.Visuals2D): + def __init__( + self, + origin: aa.Grid2D = None, + border: aa.Grid2D = None, + mask: aa.Mask2D = None, + lines: Optional[Union[List[aa.Array1D], aa.Grid2DIrregular]] = None, + positions: Optional[Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]]] = None, + grid: Union[aa.Grid2D] = None, + mesh_grid: aa.Grid2D = None, + vectors: aa.VectorYX2DIrregular = None, + patches: "Union[ptch.Patch]" = None, + fill_region: Optional[List] = None, + array_overlay: aa.Array2D = None, + light_profile_centres: aa.Grid2DIrregular = None, + mass_profile_centres: aa.Grid2DIrregular = None, + multiple_images: aa.Grid2DIrregular = None, + tangential_critical_curves: Optional[ + Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]] + ] = None, + radial_critical_curves: Optional[ + Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]] + ] = None, + tangential_caustics: Optional[ + Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]] + ] = None, + radial_caustics: Optional[ + Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]] + ] = None, + parallel_overscan=None, + serial_prescan=None, + serial_overscan=None, + indexes: Union[List[int], List[List[int]]] = None, + ): + super().__init__( + mask=mask, + positions=positions, + grid=grid, + lines=lines, + mesh_grid=mesh_grid, + vectors=vectors, + patches=patches, + fill_region=fill_region, + array_overlay=array_overlay, + origin=origin, + border=border, + parallel_overscan=parallel_overscan, + serial_prescan=serial_prescan, + serial_overscan=serial_overscan, + indexes=indexes, + ) + + self.light_profile_centres = light_profile_centres + self.mass_profile_centres = mass_profile_centres + self.multiple_images = multiple_images + self.tangential_critical_curves = tangential_critical_curves + self.radial_critical_curves = radial_critical_curves + self.tangential_caustics = tangential_caustics + self.radial_caustics = radial_caustics + + def plot_via_plotter(self, plotter, grid_indexes=None): + super().plot_via_plotter( + plotter=plotter, + grid_indexes=grid_indexes, + ) + + if self.light_profile_centres is not None: + plotter.light_profile_centres_scatter.scatter_grid( + grid=self.light_profile_centres + ) + + if self.mass_profile_centres is not None: + plotter.mass_profile_centres_scatter.scatter_grid( + grid=self.mass_profile_centres + ) + + if self.multiple_images is not None: + plotter.multiple_images_scatter.scatter_grid( + grid=self.multiple_images.array + ) + + if self.tangential_critical_curves is not None: + try: + plotter.tangential_critical_curves_plot.plot_grid( + grid=self.tangential_critical_curves + ) + except TypeError: + pass + + if self.radial_critical_curves is not None: + try: + plotter.radial_critical_curves_plot.plot_grid( + grid=self.radial_critical_curves + ) + except TypeError: + pass + + if self.tangential_caustics is not None: + try: + try: + plotter.tangential_caustics_plot.plot_grid( + grid=self.tangential_caustics + ) + except (AttributeError, ValueError): + plotter.tangential_caustics_plot.plot_grid( + grid=self.tangential_caustics.array + ) + except TypeError: + pass + + if self.radial_caustics is not None: + try: + plotter.radial_caustics_plot.plot_grid(grid=self.radial_caustics) + except TypeError: + pass + + def add_critical_curves_or_caustics( + self, mass_obj, grid: aa.type.Grid2DLike, plane_index: int + ): + """ + From a object with mass profiles (e.g. mass profile, galaxy) extract the critical curves or caustics and + returns them in a `Visuals2D` object. + + This includes support for a `plane_index`, which specifies the index of the plane in the tracer, which is + an object used in PyAutoLens to represent a lensing system with multiple planes (e.g. an image plane and a + source plane). The `plane_index` allows for the extraction of quantities from a specific plane in the tracer. + + When plotting a `Tracer` it is common for plots to only display quantities corresponding to one plane at a time + (e.g. the convergence in the image plane, the source in the source plane). Therefore, quantities are only + extracted from one plane, specified by the input `plane_index`. + + Parameters + ---------- + mass_obj + The mass object (e.g. mass profile, galaxy, tracer) object which has attributes extracted for plotting. + grid + The 2D grid of (y,x) coordinates used to plot the tracer's quantities in 2D. + plane_index + The index of the plane in the tracer which is used to extract quantities, as only one plane is plotted + at a time. + + Returns + ------- + vis.Visuals2D + A collection of attributes that can be plotted by a `Plotter` object. + """ + if plane_index == 0: + return self.add_critical_curves(mass_obj=mass_obj, grid=grid) + return self.add_caustics(mass_obj=mass_obj, grid=grid) + + def add_critical_curves(self, mass_obj, grid: aa.type.Grid2DLike): + """ + From a object with mass profiles (e.g. mass profile, galaxy) extract the critical curves and + returns them in a `Visuals2D` object. + + When plotting a `Tracer` it is common for plots to only display quantities corresponding to one plane at a time + (e.g. the convergence in the image plane, the source in the source plane). Therefore, quantities are only + extracted from one plane, specified by the input `plane_index`. + + Parameters + ---------- + mass_obj + The mass object (e.g. mass profile, galaxy, tracer) object which has attributes extracted for plotting. + grid + The 2D grid of (y,x) coordinates used to plot the tracer's quantities in 2D. + plane_index + The index of the plane in the tracer which is used to extract quantities, as only one plane is plotted + at a time. + + Returns + ------- + vis.Visuals2D + A collection of attributes that can be plotted by a `Plotter` object. + """ + + tangential_critical_curves = mass_obj.tangential_critical_curve_list_from( + grid=grid + ) + + radial_critical_curves = None + radial_critical_curve_area_list = mass_obj.radial_critical_curve_area_list_from( + grid=grid + ) + + if any([area > grid.pixel_scale for area in radial_critical_curve_area_list]): + radial_critical_curves = mass_obj.radial_critical_curve_list_from(grid=grid) + + return self + self.__class__( + tangential_critical_curves=tangential_critical_curves, + radial_critical_curves=radial_critical_curves, + ) + + def add_caustics(self, mass_obj, grid: aa.type.Grid2DLike): + """ + From a object with mass profiles (e.g. mass profile, galaxy) extract the caustics and + returns them in a `Visuals2D` object. + + When plotting a `Tracer` it is common for plots to only display quantities corresponding to one plane at a time + (e.g. the convergence in the image plane, the source in the source plane). Therefore, quantities are only + extracted from one plane, specified by the input `plane_index`. + + Parameters + ---------- + mass_obj + The mass object (e.g. mass profile, galaxy, tracer) object which has attributes extracted for plotting. + grid + The 2D grid of (y,x) coordinates used to plot the tracer's quantities in 2D. + plane_index + The index of the plane in the tracer which is used to extract quantities, as only one plane is plotted + at a time. + + Returns + ------- + vis.Visuals2D + A collection of attributes that can be plotted by a `Plotter` object. + """ + + tangential_caustics = mass_obj.tangential_caustic_list_from(grid=grid) + radial_caustics = mass_obj.radial_caustic_list_from(grid=grid) + + return self + self.__class__( + tangential_caustics=tangential_caustics, + radial_caustics=radial_caustics, + ) diff --git a/autogalaxy/profiles/plot/basis_plotters.py b/autogalaxy/profiles/plot/basis_plotters.py index 04c3b03d9..93d4bbc6b 100644 --- a/autogalaxy/profiles/plot/basis_plotters.py +++ b/autogalaxy/profiles/plot/basis_plotters.py @@ -72,12 +72,6 @@ def __init__( visuals_1d=visuals_1d, ) - def get_visuals_1d(self) -> Visuals1D: - return self.get_1d.via_light_obj_from(light_obj=self.basis) - - def get_visuals_2d(self) -> Visuals2D: - return self.get_2d.via_light_obj_from(light_obj=self.basis, grid=self.grid) - def light_profile_plotter_from( self, light_profile: LightProfile, @@ -123,7 +117,7 @@ def subplot_image(self): for light_profile in self.basis.light_profile_list: self.mat_plot_2d.plot_array( array=light_profile.image_2d_from(grid=self.grid), - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels(title=light_profile.coefficient_tag), ) diff --git a/autogalaxy/profiles/plot/light_profile_plotters.py b/autogalaxy/profiles/plot/light_profile_plotters.py index 686e6f379..e8521bb7b 100644 --- a/autogalaxy/profiles/plot/light_profile_plotters.py +++ b/autogalaxy/profiles/plot/light_profile_plotters.py @@ -73,14 +73,6 @@ def __init__( visuals_1d=visuals_1d, ) - def get_visuals_1d(self) -> Visuals1D: - return self.get_1d.via_light_obj_from(light_obj=self.light_profile) - - def get_visuals_2d(self) -> Visuals2D: - return self.get_2d.via_light_obj_from( - light_obj=self.light_profile, grid=self.grid - ) - def figures_1d(self, image: bool = False): """ Plots the individual attributes of the plotter's `LightProfile` object in 1D, which are computed via the @@ -109,7 +101,7 @@ def figures_1d(self, image: bool = False): self.mat_plot_1d.plot_yx( y=image_1d, x=image_1d.grid_radial, - visuals_1d=self.get_visuals_1d(), + visuals_1d=self.visuals_1d, auto_labels=aplt.AutoLabels( title=r"Image ($\mathrm{e^{-}}\,\mathrm{s^{-1}}$) vs Radius (arcsec)", yunit="", @@ -135,7 +127,7 @@ def figures_2d(self, image: bool = False): if image: self.mat_plot_2d.plot_array( array=self.light_profile.image_2d_from(grid=self.grid), - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels(title="Image", filename="image_2d"), ) @@ -245,13 +237,13 @@ def figures_1d(self, image: bool = False): profile_1d_list=image_1d_list, low_limit=self.low_limit ) - visuals_1d_via_light_obj_list = self.get_1d.via_light_obj_list_from( - light_obj_list=self.light_profile_pdf_list, low_limit=self.low_limit - ) - visuals_1d_with_shaded_region = self.visuals_1d.__class__( - shaded_region=errors_image_1d + visuals_1d_via_light_obj_list = Visuals1D().add_half_light_radius_errors( + light_obj_list=self.light_profile_pdf_list, + low_limit=self.low_limit, ) + visuals_1d_with_shaded_region = Visuals1D(shaded_region=errors_image_1d) + visuals_1d = visuals_1d_via_light_obj_list + visuals_1d_with_shaded_region self.mat_plot_1d.plot_yx( diff --git a/autogalaxy/profiles/plot/mass_profile_plotters.py b/autogalaxy/profiles/plot/mass_profile_plotters.py index b7bd0113b..c2d9ea4bd 100644 --- a/autogalaxy/profiles/plot/mass_profile_plotters.py +++ b/autogalaxy/profiles/plot/mass_profile_plotters.py @@ -65,19 +65,12 @@ def __init__( self._mass_plotter = MassPlotter( mass_obj=self.mass_profile, grid=self.grid, - get_visuals_2d=self.get_visuals_2d, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.visuals_2d, ) self.figures_2d = self._mass_plotter.figures_2d - def get_visuals_1d(self) -> Visuals1D: - return self.get_1d.via_mass_obj_from(mass_obj=self.mass_profile, grid=self.grid) - - def get_visuals_2d(self) -> Visuals2D: - return self.get_2d.via_mass_obj_from(mass_obj=self.mass_profile, grid=self.grid) - def figures_1d(self, convergence: bool = False, potential: bool = False): """ Plots the individual attributes of the plotter's `MassProfile` object in 1D, which are computed via the @@ -108,7 +101,7 @@ def figures_1d(self, convergence: bool = False, potential: bool = False): self.mat_plot_1d.plot_yx( y=convergence_1d, x=convergence_1d.grid_radial, - visuals_1d=self.get_visuals_1d(), + visuals_1d=self.visuals_1d, auto_labels=aplt.AutoLabels( title="Convergence vs Radius (arcsec)", yunit="", @@ -124,7 +117,7 @@ def figures_1d(self, convergence: bool = False, potential: bool = False): self.mat_plot_1d.plot_yx( y=potential_1d, x=potential_1d.grid_radial, - visuals_1d=self.get_visuals_1d(), + visuals_1d=self.visuals_1d, auto_labels=aplt.AutoLabels( title="Potential vs Radius (arcsec)", yunit="", @@ -242,12 +235,12 @@ def figures_1d(self, convergence=False, potential=False): profile_1d_list=convergence_1d_list, low_limit=self.low_limit ) - visuals_1d_via_lensing_obj_list = self.get_1d.via_mass_obj_list_from( + visuals_1d_via_lensing_obj_list = Visuals1D().add_einstein_radius_errors( mass_obj_list=self.mass_profile_pdf_list, grid=self.grid, low_limit=self.low_limit, ) - visuals_1d_with_shaded_region = self.visuals_1d.__class__( + visuals_1d_with_shaded_region = Visuals1D( shaded_region=errors_convergence_1d ) @@ -286,14 +279,12 @@ def figures_1d(self, convergence=False, potential=False): profile_1d_list=potential_1d_list, low_limit=self.low_limit ) - visuals_1d_via_lensing_obj_list = self.get_1d.via_mass_obj_list_from( + visuals_1d_via_lensing_obj_list = Visuals1D().add_einstein_radius_errors( mass_obj_list=self.mass_profile_pdf_list, grid=self.grid, low_limit=self.low_limit, ) - visuals_1d_with_shaded_region = self.visuals_1d.__class__( - shaded_region=errors_potential_1d - ) + visuals_1d_with_shaded_region = Visuals1D(shaded_region=errors_potential_1d) visuals_1d = visuals_1d_via_lensing_obj_list + visuals_1d_with_shaded_region diff --git a/autogalaxy/quantity/plot/fit_quantity_plotters.py b/autogalaxy/quantity/plot/fit_quantity_plotters.py index 438056fd0..d0371ab3f 100644 --- a/autogalaxy/quantity/plot/fit_quantity_plotters.py +++ b/autogalaxy/quantity/plot/fit_quantity_plotters.py @@ -44,15 +44,6 @@ def __init__( self.fit = fit - def get_visuals_2d(self) -> Visuals2D: - return self.get_2d.via_fit_imaging_from(fit=self.fit) - - def get_visuals_2d_y(self) -> Visuals2D: - return self.get_2d.via_fit_imaging_from(fit=self.fit.y) - - def get_visuals_2d_x(self) -> Visuals2D: - return self.get_2d.via_fit_imaging_from(fit=self.fit.x) - def figures_2d( self, image: bool = False, @@ -90,7 +81,6 @@ def figures_2d( if isinstance(self.fit.dataset.data, aa.Array2D): fit_plotter = FitImagingPlotterMeta( fit=self.fit, - get_visuals_2d=self.get_visuals_2d, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.visuals_2d, ) @@ -108,7 +98,6 @@ def figures_2d( else: fit_plotter_y = FitImagingPlotterMeta( fit=self.fit.y, - get_visuals_2d=self.get_visuals_2d_y, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.visuals_2d, ) @@ -126,7 +115,6 @@ def figures_2d( fit_plotter_x = FitImagingPlotterMeta( fit=self.fit.y, - get_visuals_2d=self.get_visuals_2d_x, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.visuals_2d, ) @@ -150,7 +138,6 @@ def subplot_fit(self): if isinstance(self.fit.dataset.data, aa.Array2D): fit_plotter = FitImagingPlotterMeta( fit=self.fit, - get_visuals_2d=self.get_visuals_2d, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.visuals_2d, ) @@ -168,7 +155,6 @@ def subplot_fit(self): else: fit_plotter_y = FitImagingPlotterMeta( fit=self.fit.y, - get_visuals_2d=self.get_visuals_2d_y, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.visuals_2d, ) @@ -185,7 +171,6 @@ def subplot_fit(self): fit_plotter_x = FitImagingPlotterMeta( fit=self.fit.x, - get_visuals_2d=self.get_visuals_2d_x, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.visuals_2d, ) diff --git a/test_autogalaxy/plot/mat_wrap/test_get_visuals.py b/test_autogalaxy/plot/mat_wrap/test_get_visuals.py deleted file mode 100644 index 41ae8f5ea..000000000 --- a/test_autogalaxy/plot/mat_wrap/test_get_visuals.py +++ /dev/null @@ -1,156 +0,0 @@ -from os import path -import pytest - -import autogalaxy as ag -import autogalaxy.plot as aplt - -from autogalaxy.plot.get_visuals.one_d import GetVisuals1D -from autogalaxy.plot.get_visuals.two_d import GetVisuals2D - -directory = path.dirname(path.realpath(__file__)) - - -@pytest.fixture(name="plot_path") -def make_profile_plotter_setup(): - return path.join( - "{}".format(path.dirname(path.realpath(__file__))), "files", "plots", "profiles" - ) - - -def test__1d__via_light_obj_from(lp_0): - visuals_1d = aplt.Visuals1D() - - get_visuals = GetVisuals1D(visuals=visuals_1d) - - visuals_1d_via = get_visuals.via_light_obj_from(light_obj=lp_0) - - assert visuals_1d_via.half_light_radius == lp_0.half_light_radius - - -def test__1d__via_light_obj_list_from(lp_0): - visuals_1d = aplt.Visuals1D() - - get_visuals = GetVisuals1D(visuals=visuals_1d) - - visuals_1d_via = get_visuals.via_light_obj_list_from( - light_obj_list=[lp_0, lp_0], low_limit=1.0 - ) - - assert visuals_1d_via.half_light_radius == lp_0.half_light_radius - assert visuals_1d_via.half_light_radius_errors[0][0] == lp_0.half_light_radius - - -def test__1d__via_mass_obj_from(mp_0, grid_2d_7x7): - visuals_1d = aplt.Visuals1D() - - get_visuals = GetVisuals1D(visuals=visuals_1d) - - visuals_1d_via = get_visuals.via_mass_obj_from(mass_obj=mp_0, grid=grid_2d_7x7) - - assert visuals_1d_via.einstein_radius == mp_0.einstein_radius_from(grid=grid_2d_7x7) - - -def test__1d__via_mass_obj_list_from(mp_0, grid_2d_7x7): - - visuals_1d = aplt.Visuals1D() - - get_visuals = GetVisuals1D(visuals=visuals_1d) - - visuals_1d_via = get_visuals.via_mass_obj_list_from( - mass_obj_list=[mp_0, mp_0], grid=grid_2d_7x7, low_limit=1.0 - ) - - assert visuals_1d_via.einstein_radius == mp_0.einstein_radius_from(grid=grid_2d_7x7) - assert visuals_1d_via.einstein_radius_errors[0][0] == mp_0.einstein_radius_from( - grid=grid_2d_7x7 - ) - - -def test__2d__via_light_obj_from(lp_0, grid_2d_7x7): - visuals_2d = aplt.Visuals2D(vectors=2) - - get_visuals = GetVisuals2D(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.derive_grid.border).all() - assert visuals_2d_via.light_profile_centres.in_list == [lp_0.centre] - assert visuals_2d_via.vectors == 2 - - -def test__2d__via_mass_obj(mp_0, grid_2d_7x7): - visuals_2d = aplt.Visuals2D(vectors=2) - - get_visuals = GetVisuals2D(visuals=visuals_2d) - - visuals_2d_via = get_visuals.via_mass_obj_from(mass_obj=mp_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.derive_grid.border).all() - assert visuals_2d_via.mass_profile_centres.in_list == [mp_0.centre] - assert ( - visuals_2d_via.tangential_critical_curves[0] - == mp_0.tangential_critical_curve_list_from(grid=grid_2d_7x7)[0] - ).all() - assert visuals_2d_via.vectors == 2 - - -def test__2d__via_light_mass_obj(gal_x1_lp_x1_mp, grid_2d_7x7): - visuals_2d = aplt.Visuals2D(vectors=2) - - get_visuals = GetVisuals2D(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.derive_grid.border).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.tangential_critical_curves[0] - == gal_x1_lp_x1_mp.tangential_critical_curve_list_from(grid=grid_2d_7x7)[0] - ).all() - assert ( - visuals_2d_via.radial_critical_curves[0] - == gal_x1_lp_x1_mp.radial_critical_curve_list_from(grid=grid_2d_7x7)[0] - ).all() - assert visuals_2d_via.vectors == 2 - - -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) - - get_visuals = GetVisuals2D(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.derive_grid.border - ).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.tangential_critical_curves[0] - == fit_imaging_x2_galaxy_7x7.galaxies.tangential_critical_curve_list_from( - grid=grid_2d_7x7 - )[0] - ).all() - assert ( - visuals_2d_via.radial_critical_curves[0] - == fit_imaging_x2_galaxy_7x7.galaxies.radial_critical_curve_list_from( - grid=grid_2d_7x7 - )[0] - ).all() - assert visuals_2d_via.vectors == 2 diff --git a/test_autogalaxy/plot/mat_wrap/test_visuals.py b/test_autogalaxy/plot/mat_wrap/test_visuals.py new file mode 100644 index 000000000..1cd20d1ca --- /dev/null +++ b/test_autogalaxy/plot/mat_wrap/test_visuals.py @@ -0,0 +1,83 @@ +from os import path +import pytest + +import autogalaxy.plot as aplt + +directory = path.dirname(path.realpath(__file__)) + + +@pytest.fixture(name="plot_path") +def make_profile_plotter_setup(): + return path.join( + "{}".format(path.dirname(path.realpath(__file__))), "files", "plots", "profiles" + ) + + +def test__1d__add_half_light_radius(lp_0): + + visuals_1d_via = aplt.Visuals1D().add_half_light_radius(light_obj=lp_0) + + assert visuals_1d_via.half_light_radius == lp_0.half_light_radius + + +def test__1d__add_half_light_radius_errors(lp_0): + + visuals_1d_via = aplt.Visuals1D().add_half_light_radius_errors( + light_obj_list=[lp_0, lp_0], low_limit=1.0 + ) + + assert visuals_1d_via.half_light_radius == lp_0.half_light_radius + assert visuals_1d_via.half_light_radius_errors[0][0] == lp_0.half_light_radius + + +def test__1d__add_einstein_radius(mp_0, grid_2d_7x7): + + visuals_1d_via = aplt.Visuals1D().add_einstein_radius( + mass_obj=mp_0, grid=grid_2d_7x7 + ) + + assert visuals_1d_via.einstein_radius == mp_0.einstein_radius_from(grid=grid_2d_7x7) + + +def test__1d__add_einstein_radius_errors(mp_0, grid_2d_7x7): + + visuals_1d_via = aplt.Visuals1D().add_einstein_radius_errors( + mass_obj_list=[mp_0, mp_0], grid=grid_2d_7x7, low_limit=1.0 + ) + + assert visuals_1d_via.einstein_radius == mp_0.einstein_radius_from(grid=grid_2d_7x7) + assert visuals_1d_via.einstein_radius_errors[0][0] == mp_0.einstein_radius_from( + grid=grid_2d_7x7 + ) + + +def test__2d__add_critical_curve(gal_x1_mp, grid_2d_7x7): + + visuals_2d_via = aplt.Visuals2D().add_critical_curves_or_caustics( + mass_obj=gal_x1_mp, grid=grid_2d_7x7, plane_index=0 + ) + + assert ( + visuals_2d_via.tangential_critical_curves[0] + == gal_x1_mp.tangential_critical_curve_list_from(grid=grid_2d_7x7)[0] + ).all() + assert ( + visuals_2d_via.radial_critical_curves[0] + == gal_x1_mp.radial_critical_curve_list_from(grid=grid_2d_7x7)[0] + ).all() + + +def test__2d__add_caustic(gal_x1_mp, grid_2d_7x7): + + visuals_2d_via = aplt.Visuals2D().add_critical_curves_or_caustics( + mass_obj=gal_x1_mp, grid=grid_2d_7x7, plane_index=1 + ) + + assert ( + visuals_2d_via.tangential_caustics[0] + == gal_x1_mp.tangential_caustic_list_from(grid=grid_2d_7x7)[0] + ).all() + assert ( + visuals_2d_via.radial_caustics[0] + == gal_x1_mp.radial_caustic_list_from(grid=grid_2d_7x7)[0] + ).all() From 7bddaf2259fa0228320d0bc25c7cff95f2cffaa6 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 21 Jul 2025 21:21:47 +0100 Subject: [PATCH 3/4] visual clean up complete --- autogalaxy/profiles/mass/sheets/external_shear.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autogalaxy/profiles/mass/sheets/external_shear.py b/autogalaxy/profiles/mass/sheets/external_shear.py index dedbf683f..fb71e7bf0 100644 --- a/autogalaxy/profiles/mass/sheets/external_shear.py +++ b/autogalaxy/profiles/mass/sheets/external_shear.py @@ -49,8 +49,8 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): ) ##to be onsistent with autolens deflection angle calculation phig = jnp.deg2rad(shear_angle) shear_amp = self.magnitude - phicoord = jnp.arctan2(grid[:, 0], grid[:, 1]) - rcoord = jnp.sqrt(grid[:, 0] ** 2.0 + grid[:, 1] ** 2.0) + phicoord = jnp.arctan2(grid.array[:, 0], grid.array[:, 1]) + rcoord = jnp.sqrt(grid.array[:, 0] ** 2.0 + grid.array[:, 1] ** 2.0) return -0.5 * shear_amp * rcoord**2 * jnp.cos(2 * (phicoord - phig)) From 4ea74b3966009ca0ef8fec7340dccee3a33f2c93 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Tue, 22 Jul 2025 17:16:52 +0100 Subject: [PATCH 4/4] 2lack --- README.rst | 12 ++++++++++++ autogalaxy/plot/visuals/two_d.py | 1 + docs/api/plot.rst | 1 - 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index c1bf2bd50..29449b180 100644 --- a/README.rst +++ b/README.rst @@ -20,6 +20,18 @@ PyAutoGalaxy: Open-Source Multi Wavelength Galaxy Structure & Morphology .. image:: https://joss.theoj.org/papers/10.21105/joss.04475/status.svg :target: https://doi.org/10.21105/joss.04475 +.. image:: https://www.repostatus.org/badges/latest/active.svg + :target: https://www.repostatus.org/#active + :alt: Project Status: Active + +.. image:: https://img.shields.io/pypi/pyversions/autogalaxy + :target: https://pypi.org/project/autogalaxy/ + :alt: Python Versions + +.. image:: https://img.shields.io/pypi/v/autogalaxy.svg + :target: https://pypi.org/project/autogalaxy/ + :alt: PyPI Version + `Installation Guide `_ | `readthedocs `_ | `Introduction on Binder `_ | diff --git a/autogalaxy/plot/visuals/two_d.py b/autogalaxy/plot/visuals/two_d.py index 1c33e86bf..a93cdab09 100644 --- a/autogalaxy/plot/visuals/two_d.py +++ b/autogalaxy/plot/visuals/two_d.py @@ -150,6 +150,7 @@ def add_critical_curves_or_caustics( vis.Visuals2D A collection of attributes that can be plotted by a `Plotter` object. """ + print("bbbb") if plane_index == 0: return self.add_critical_curves(mass_obj=mass_obj, grid=grid) return self.add_caustics(mass_obj=mass_obj, grid=grid) diff --git a/docs/api/plot.rst b/docs/api/plot.rst index 3fe971efe..38ab6de3c 100644 --- a/docs/api/plot.rst +++ b/docs/api/plot.rst @@ -37,7 +37,6 @@ Create figures and subplots showing quantities of standard **PyAutoGalaxy** obje FitImagingPlotter FitInterferometerPlotter GalaxiesPlotter - AdaptPlotter FitImagingPlotter FitInterferometerPlotter MultiFigurePlotter