From a4af8ef70b76d40b089d40a303935e0387df1f90 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Wed, 25 Mar 2026 10:04:15 +0000 Subject: [PATCH 1/2] Rename PlotterInterface to Plotter; fix _to_lines calls; update docs - Rename plotter_interface.py -> plotter.py and PlotterInterface* -> Plotter* across all dataset types (imaging, interferometer, point, quantity) - Fix _to_lines(tan, rad) calls in tracer_plots, fit_imaging_plots, sensitivity_plots: numpy_lines() takes one argument, so concatenate tangential+radial before passing - Add docstrings to all Plotter methods in imaging, interferometer, and point plotters - Update docs/api/plot.rst to list new aplt standalone functions with correct currentmodule (autolens.plot, not autogalaxy.plot) - Update docs/overview/overview_1_start_here.rst to use new aplt.plot_array / plot_grid API - Rename test_plotter_interface* -> test_plotter* to match source rename Co-Authored-By: Claude Sonnet 4.6 --- .../{plotter_interface.py => plotter.py} | 10 +-- autolens/config/visualize/plots.yaml | 14 ++-- autolens/imaging/fit_imaging.py | 4 +- .../{plotter_interface.py => plotter.py} | 14 ++-- autolens/imaging/model/visualizer.py | 24 +++--- autolens/imaging/plot/fit_imaging_plots.py | 2 +- autolens/interferometer/fit_interferometer.py | 4 +- .../{plotter_interface.py => plotter.py} | 14 ++-- autolens/interferometer/model/visualizer.py | 24 +++--- autolens/lens/plot/sensitivity_plots.py | 6 +- autolens/lens/plot/tracer_plots.py | 4 +- .../{plotter_interface.py => plotter.py} | 6 +- autolens/point/model/visualizer.py | 14 ++-- autolens/quantity/model/visualizer.py | 12 +-- docs/api/plot.rst | 81 ++++++++++++++----- docs/overview/overview_1_start_here.rst | 58 +++++-------- ...t_plotter_interface.py => test_plotter.py} | 12 +-- ...ace_imaging.py => test_plotter_imaging.py} | 10 +-- ...eter.py => test_plotter_interferometer.py} | 10 +-- ...terface_point.py => test_plotter_point.py} | 8 +- 20 files changed, 179 insertions(+), 152 deletions(-) rename autolens/analysis/{plotter_interface.py => plotter.py} (92%) rename autolens/imaging/model/{plotter_interface.py => plotter.py} (87%) rename autolens/interferometer/model/{plotter_interface.py => plotter.py} (76%) rename autolens/point/model/{plotter_interface.py => plotter.py} (89%) rename test_autolens/analysis/{test_plotter_interface.py => test_plotter.py} (72%) rename test_autolens/imaging/model/{test_plotter_interface_imaging.py => test_plotter_imaging.py} (81%) rename test_autolens/interferometer/model/{test_plotter_interface_interferometer.py => test_plotter_interferometer.py} (77%) rename test_autolens/point/model/{test_plotter_interface_point.py => test_plotter_point.py} (62%) diff --git a/autolens/analysis/plotter_interface.py b/autolens/analysis/plotter.py similarity index 92% rename from autolens/analysis/plotter_interface.py rename to autolens/analysis/plotter.py index 7af2690f5..f95f81fd2 100644 --- a/autolens/analysis/plotter_interface.py +++ b/autolens/analysis/plotter.py @@ -8,23 +8,23 @@ import autoarray as aa import autogalaxy as ag -from autogalaxy.analysis.plotter_interface import plot_setting +from autogalaxy.analysis.plotter import plot_setting -from autogalaxy.analysis.plotter_interface import PlotterInterface as AgPlotterInterface +from autogalaxy.analysis.plotter import Plotter as AgPlotter from autolens.lens.tracer import Tracer from autolens.lens.plot.tracer_plots import subplot_galaxies_images from autoarray.plot.array import plot_array -class PlotterInterface(AgPlotterInterface): +class Plotter(AgPlotter): """ Visualizes the maximum log likelihood model of a model-fit, including components of the model and fit objects. - The methods of the `PlotterInterface` are called throughout a non-linear search using the `Analysis` + The methods of the `Plotter` are called throughout a non-linear search using the `Analysis` classes `visualize` method. - The images output by the `PlotterInterface` are customized using the file `config/visualize/plots.yaml`. + The images output by the `Plotter` are customized using the file `config/visualize/plots.yaml`. Parameters ---------- diff --git a/autolens/config/visualize/plots.yaml b/autolens/config/visualize/plots.yaml index fd253913d..1f7dcc2f6 100644 --- a/autolens/config/visualize/plots.yaml +++ b/autolens/config/visualize/plots.yaml @@ -13,14 +13,14 @@ subplot_format: [png] # Output format of all subplots, can be png, pdf or both (e.g. [png, pdf]) fits_are_zoomed: false # If true, output .fits files are zoomed in on the center of the unmasked region image, saving hard-disk space. -dataset: # Settings for plots of all datasets (e.g. ImagingPlotter, InterferometerPlotter). +dataset: # Settings for plots of all datasets (e.g. Imaging, Interferometer). subplot_dataset: true # Plot subplot containing all dataset quantities (e.g. the data, noise-map, etc.)? fits_dataset: true # Output a .fits file containing the dataset data, noise-map and other quantities? positions: # Settings for plots with resampling image-positions on (e.g. the image). image_with_positions: true -fit: # Settings for plots of all fits (e.g. FitImagingPlotter, FitInterferometerPlotter). +fit: # Settings for plots of all fits (e.g. FitImaging, FitInterferometer). subplot_fit: true # Plot subplot of all fit quantities for any dataset (e.g. the model data, residual-map, etc.)? subplot_fit_log10: true # Plot subplot of all fit quantities for any dataset using log10 color maps (e.g. the model data, residual-map, etc.)? subplot_of_planes: false # Plot subplot of the model-image, subtracted image and other quantities of each plane? @@ -29,9 +29,9 @@ fit: # Settings for plots of all fits (e.g fits_galaxy_images : true # Output a .fits file containing the images (e.g. without PSF convolution) of every galaxy? fits_model_galaxy_images : true # Output a .fits file containing the model images (e.g. with PSF convolution) of every galaxy? -fit_imaging: {} # Settings for plots of fits to imaging datasets (e.g. FitImagingPlotter). +fit_imaging: {} # Settings for plots of fits to imaging datasets (e.g. FitImaging). -tracer: # Settings for plots of tracers (e.g. TracerPlotter). +tracer: # Settings for plots of tracers (e.g. Tracer). subplot_tracer: true # Plot subplot of all quantities in each tracer (e.g. images, convergence)? subplot_galaxies_images: false # Plot subplot of the image of each plane in the tracer? fits_tracer: true # Output tracer.fits file of tracer's convergence, potential, deflections_y and deflections_x? @@ -47,7 +47,7 @@ adapt: # Settings for plots of adapt images subplot_adapt_images: true # Plot subplot showing each adapt image used for adaptive pixelization? fits_adapt_images: true # Output a .fits file containing the adapt images used for adaptive pixelization? -fit_interferometer: # Settings for plots of fits to interferometer datasets (e.g. FitInterferometerPlotter). +fit_interferometer: # Settings for plots of fits to interferometer datasets (e.g. FitInterferometer). subplot_fit_dirty_images: false # Plot subplot of the dirty-images of all interferometer datasets? subplot_fit_real_space: false # Plot subplot of the real-space images of all interferometer datasets? fits_dirty_images: true # output dirty_images.fits showing the dirty image, noise-map, model-data, resiual-map, normalized residual map and chi-squared map? @@ -61,9 +61,9 @@ fit_ellipse: # Settings for plots of ellipse fitti data : true # Plot the data of the ellipse fit? data_no_ellipse: true # Plot the data without the black data ellipses, which obscure noisy data? -fit_quantity: # Settings for plots of fit quantities (e.g. FitQuantityPlotter). +fit_quantity: # Settings for plots of fit quantities (e.g. FitQuantity). subplot_fit: true -galaxies: # Settings for plots of galaxies (e.g. GalaxiesPlotter). +galaxies: # Settings for plots of galaxies (e.g. Galaxies). subplot_galaxies: true # Plot subplot of all quantities in each galaxies group (e.g. images, convergence)? subplot_galaxy_images: false # Plot subplot of the image of each galaxy in the model? diff --git a/autolens/imaging/fit_imaging.py b/autolens/imaging/fit_imaging.py index 036268a9e..805ce3499 100644 --- a/autolens/imaging/fit_imaging.py +++ b/autolens/imaging/fit_imaging.py @@ -367,7 +367,7 @@ def tracer_linear_light_profiles_to_light_profiles(self) -> Tracer: The `Tracer` where all linear light profiles have been converted to ordinary light profiles, where their `intensity` values are set to the values inferred by this fit. - This is typically used for visualization, because linear light profiles cannot be used in `LightProfilePlotter` - or `GalaxyPlotter` objects. + This is typically used for visualization, because linear light profiles cannot be used in `LightProfile` + or `Galaxy` objects. """ return self.model_obj_linear_light_profiles_to_light_profiles diff --git a/autolens/imaging/model/plotter_interface.py b/autolens/imaging/model/plotter.py similarity index 87% rename from autolens/imaging/model/plotter_interface.py rename to autolens/imaging/model/plotter.py index 6722e2694..23780883e 100644 --- a/autolens/imaging/model/plotter_interface.py +++ b/autolens/imaging/model/plotter.py @@ -2,10 +2,10 @@ import numpy as np from typing import List -from autogalaxy.imaging.model.plotter_interface import PlotterInterfaceImaging as AgPlotterInterfaceImaging -from autogalaxy.imaging.model.plotter_interface import fits_to_fits +from autogalaxy.imaging.model.plotter import PlotterImaging as AgPlotterImaging +from autogalaxy.imaging.model.plotter import fits_to_fits -from autolens.analysis.plotter_interface import PlotterInterface +from autolens.analysis.plotter import Plotter from autolens.imaging.fit_imaging import FitImaging from autolens.imaging.plot.fit_imaging_plots import ( subplot_fit, @@ -16,13 +16,13 @@ subplot_fit_combined_log10, ) -from autolens.analysis.plotter_interface import plot_setting +from autolens.analysis.plotter import plot_setting -class PlotterInterfaceImaging(PlotterInterface): +class PlotterImaging(Plotter): - imaging = AgPlotterInterfaceImaging.imaging - imaging_combined = AgPlotterInterfaceImaging.imaging_combined + imaging = AgPlotterImaging.imaging + imaging_combined = AgPlotterImaging.imaging_combined def fit_imaging( self, fit: FitImaging, quick_update: bool = False diff --git a/autolens/imaging/model/visualizer.py b/autolens/imaging/model/visualizer.py index d28e2d07a..e8b40c439 100644 --- a/autolens/imaging/model/visualizer.py +++ b/autolens/imaging/model/visualizer.py @@ -5,7 +5,7 @@ import autofit as af import autogalaxy as ag -from autolens.imaging.model.plotter_interface import PlotterInterfaceImaging +from autolens.imaging.model.plotter import PlotterImaging from autolens import exc @@ -33,11 +33,11 @@ def visualize_before_fit( the imaging data. """ - plotter_interface = PlotterInterfaceImaging( + plotter = PlotterImaging( image_path=paths.image_path, title_prefix=analysis.title_prefix ) - plotter_interface.imaging(dataset=analysis.dataset) + plotter.imaging(dataset=analysis.dataset) if analysis.positions_likelihood_list is not None: @@ -51,13 +51,13 @@ def visualize_before_fit( positions = ag.Grid2DIrregular(positions_list) - plotter_interface.image_with_positions( + plotter.image_with_positions( image=analysis.dataset.data, positions=positions, ) if analysis.adapt_images is not None: - plotter_interface.adapt_images(adapt_images=analysis.adapt_images) + plotter.adapt_images(adapt_images=analysis.adapt_images) @staticmethod def visualize( @@ -96,13 +96,13 @@ def visualize( fit = analysis.fit_from(instance=instance) tracer = fit.tracer_linear_light_profiles_to_light_profiles - plotter_interface = PlotterInterfaceImaging( + plotter = PlotterImaging( image_path=paths.image_path, title_prefix=analysis.title_prefix, ) try: - plotter_interface.fit_imaging( + plotter.fit_imaging( fit=fit, quick_update=quick_update, ) @@ -142,17 +142,17 @@ def visualize( grid = ag.Grid2D.from_extent(extent=extent, shape_native=shape_native) - plotter_interface.tracer( + plotter.tracer( tracer=tracer, grid=grid, ) - plotter_interface.galaxies( + plotter.galaxies( galaxies=tracer.galaxies, grid=fit.grids.lp, ) if fit.inversion is not None: if fit.inversion.has(cls=ag.Mapper): - plotter_interface.inversion( + plotter.inversion( inversion=fit.inversion, ) @@ -184,7 +184,7 @@ def visualize_before_fit_combined( if analyses is None: return - plotter = PlotterInterfaceImaging( + plotter = PlotterImaging( image_path=paths.image_path, title_prefix=analyses[0].title_prefix ) @@ -224,7 +224,7 @@ def visualize_combined( if analyses is None: return - plotter = PlotterInterfaceImaging( + plotter = PlotterImaging( image_path=paths.image_path, title_prefix=analyses[0].title_prefix ) diff --git a/autolens/imaging/plot/fit_imaging_plots.py b/autolens/imaging/plot/fit_imaging_plots.py index 3a5d2f498..5e60443a7 100644 --- a/autolens/imaging/plot/fit_imaging_plots.py +++ b/autolens/imaging/plot/fit_imaging_plots.py @@ -581,7 +581,7 @@ def subplot_tracer_from_fit( ) tan_cc, rad_cc = _critical_curves_from(tracer, grid) - image_plane_lines = _to_lines(tan_cc, rad_cc) + image_plane_lines = _to_lines(list(tan_cc) + list(rad_cc)) traced_grids = tracer.traced_grid_2d_list_from(grid=grid) lens_galaxies = ag.Galaxies(galaxies=tracer.planes[0]) diff --git a/autolens/interferometer/fit_interferometer.py b/autolens/interferometer/fit_interferometer.py index 4e73477d2..d3f889713 100644 --- a/autolens/interferometer/fit_interferometer.py +++ b/autolens/interferometer/fit_interferometer.py @@ -276,7 +276,7 @@ def tracer_linear_light_profiles_to_light_profiles(self) -> Tracer: The `Tracer` where all linear light profiles have been converted to ordinary light profiles, where their `intensity` values are set to the values inferred by this fit. - This is typically used for visualization, because linear light profiles cannot be used in `LightProfilePlotter` - or `GalaxyPlotter` objects. + This is typically used for visualization, because linear light profiles cannot be used in `LightProfile` + or `Galaxy` objects. """ return self.model_obj_linear_light_profiles_to_light_profiles diff --git a/autolens/interferometer/model/plotter_interface.py b/autolens/interferometer/model/plotter.py similarity index 76% rename from autolens/interferometer/model/plotter_interface.py rename to autolens/interferometer/model/plotter.py index 122ffcf0f..b69604eda 100644 --- a/autolens/interferometer/model/plotter_interface.py +++ b/autolens/interferometer/model/plotter.py @@ -1,8 +1,8 @@ -from autogalaxy.interferometer.model.plotter_interface import ( - PlotterInterfaceInterferometer as AgPlotterInterfaceInterferometer, +from autogalaxy.interferometer.model.plotter import ( + PlotterInterferometer as AgPlotterInterferometer, ) -from autogalaxy.interferometer.model.plotter_interface import fits_to_fits +from autogalaxy.interferometer.model.plotter import fits_to_fits from autogalaxy.interferometer.plot import fit_interferometer_plots as ag_fit_interferometer_plots from autolens.interferometer.fit_interferometer import FitInterferometer @@ -10,13 +10,13 @@ subplot_fit, subplot_fit_real_space, ) -from autolens.analysis.plotter_interface import PlotterInterface +from autolens.analysis.plotter import Plotter -from autolens.analysis.plotter_interface import plot_setting +from autolens.analysis.plotter import plot_setting -class PlotterInterfaceInterferometer(PlotterInterface): - interferometer = AgPlotterInterfaceInterferometer.interferometer +class PlotterInterferometer(Plotter): + interferometer = AgPlotterInterferometer.interferometer def fit_interferometer( self, diff --git a/autolens/interferometer/model/visualizer.py b/autolens/interferometer/model/visualizer.py index 86fbf1789..a9d203315 100644 --- a/autolens/interferometer/model/visualizer.py +++ b/autolens/interferometer/model/visualizer.py @@ -3,8 +3,8 @@ import autofit as af import autogalaxy as ag -from autolens.interferometer.model.plotter_interface import ( - PlotterInterfaceInterferometer, +from autolens.interferometer.model.plotter import ( + PlotterInterferometer, ) from autogalaxy import exc @@ -33,11 +33,11 @@ def visualize_before_fit( the imaging data. """ - plotter_interface = PlotterInterfaceInterferometer( + plotter = PlotterInterferometer( image_path=paths.image_path, title_prefix=analysis.title_prefix ) - plotter_interface.interferometer(dataset=analysis.interferometer) + plotter.interferometer(dataset=analysis.interferometer) if analysis.positions_likelihood_list is not None: @@ -48,12 +48,12 @@ def visualize_before_fit( positions = ag.Grid2DIrregular(positions_list) - plotter_interface.image_with_positions( + plotter.image_with_positions( image=analysis.dataset.dirty_image, positions=positions ) if analysis.adapt_images is not None: - plotter_interface.adapt_images(adapt_images=analysis.adapt_images) + plotter.adapt_images(adapt_images=analysis.adapt_images) @staticmethod def visualize( @@ -94,12 +94,12 @@ def visualize( """ fit = analysis.fit_from(instance=instance) - plotter_interface = PlotterInterfaceInterferometer( + plotter = PlotterInterferometer( image_path=paths.image_path, title_prefix=analysis.title_prefix ) try: - plotter_interface.fit_interferometer( + plotter.fit_interferometer( fit=fit, quick_update=quick_update, ) @@ -140,21 +140,21 @@ def visualize( grid = ag.Grid2D.from_extent(extent=extent, shape_native=shape_native) try: - plotter_interface.fit_interferometer(fit=fit) + plotter.fit_interferometer(fit=fit) except exc.InversionException: pass - plotter_interface.tracer( + plotter.tracer( tracer=tracer, grid=grid, ) - plotter_interface.galaxies( + plotter.galaxies( galaxies=tracer.galaxies, grid=fit.grids.lp, ) if fit.inversion is not None: try: - plotter_interface.inversion( + plotter.inversion( inversion=fit.inversion, ) except IndexError: diff --git a/autolens/lens/plot/sensitivity_plots.py b/autolens/lens/plot/sensitivity_plots.py index 7341d260d..b7699e686 100644 --- a/autolens/lens/plot/sensitivity_plots.py +++ b/autolens/lens/plot/sensitivity_plots.py @@ -76,19 +76,19 @@ def subplot_tracer_images( try: tan_cc_p, rad_cc_p = _critical_curves_from(tracer_perturb, unmasked_grid) - perturb_cc_lines = _to_lines(list(tan_cc_p), list(rad_cc_p)) + perturb_cc_lines = _to_lines(list(tan_cc_p) + list(rad_cc_p)) except Exception: perturb_cc_lines = None try: tan_ca_p, rad_ca_p = _caustics_from(tracer_perturb, unmasked_grid) - perturb_ca_lines = _to_lines(list(tan_ca_p), list(rad_ca_p)) + perturb_ca_lines = _to_lines(list(tan_ca_p) + list(rad_ca_p)) except Exception: perturb_ca_lines = None try: tan_cc_n, rad_cc_n = critical_curves_from(tracer=tracer_no_perturb, grid=unmasked_grid) - no_perturb_cc_lines = _to_lines(list(tan_cc_n), list(rad_cc_n)) + no_perturb_cc_lines = _to_lines(list(tan_cc_n) + list(rad_cc_n)) except Exception: no_perturb_cc_lines = None diff --git a/autolens/lens/plot/tracer_plots.py b/autolens/lens/plot/tracer_plots.py index f4209fd20..7027aa4d4 100644 --- a/autolens/lens/plot/tracer_plots.py +++ b/autolens/lens/plot/tracer_plots.py @@ -40,8 +40,8 @@ def subplot_tracer( tan_cc, rad_cc = _critical_curves_from(tracer, grid) tan_ca, rad_ca = _caustics_from(tracer, grid) - image_plane_lines = _to_lines(tan_cc, rad_cc) - source_plane_lines = _to_lines(tan_ca, rad_ca) + image_plane_lines = _to_lines(list(tan_cc) + list(rad_cc)) + source_plane_lines = _to_lines(list(tan_ca) + list(rad_ca)) pos_list = _to_positions(positions) # --- compute arrays --- diff --git a/autolens/point/model/plotter_interface.py b/autolens/point/model/plotter.py similarity index 89% rename from autolens/point/model/plotter_interface.py rename to autolens/point/model/plotter.py index a5982c393..9c25c82da 100644 --- a/autolens/point/model/plotter_interface.py +++ b/autolens/point/model/plotter.py @@ -1,14 +1,14 @@ -from autolens.analysis.plotter_interface import PlotterInterface +from autolens.analysis.plotter import Plotter from autolens.point.fit.dataset import FitPointDataset from autolens.point.plot.fit_point_plots import subplot_fit as subplot_fit_point from autolens.point.dataset import PointDataset from autolens.point.plot.point_dataset_plots import subplot_dataset -from autolens.analysis.plotter_interface import plot_setting +from autolens.analysis.plotter import plot_setting -class PlotterInterfacePoint(PlotterInterface): +class PlotterPoint(Plotter): def dataset_point(self, dataset: PointDataset): """ Output visualization of a `PointDataset` dataset. diff --git a/autolens/point/model/visualizer.py b/autolens/point/model/visualizer.py index 8b90c41df..c070bb056 100644 --- a/autolens/point/model/visualizer.py +++ b/autolens/point/model/visualizer.py @@ -1,7 +1,7 @@ import autofit as af import autogalaxy as ag -from autolens.point.model.plotter_interface import PlotterInterfacePoint +from autolens.point.model.plotter import PlotterPoint class VisualizerPoint(af.Visualizer): @@ -26,11 +26,11 @@ def visualize_before_fit( the imaging data. """ - plotter_interface = PlotterInterfacePoint( + plotter = PlotterPoint( image_path=paths.image_path, title_prefix=analysis.title_prefix ) - plotter_interface.dataset_point(dataset=analysis.dataset) + plotter.dataset_point(dataset=analysis.dataset) @staticmethod def visualize( @@ -65,11 +65,11 @@ def visualize( """ fit = analysis.fit_from(instance=instance) - plotter_interface = PlotterInterfacePoint( + plotter = PlotterPoint( image_path=paths.image_path, title_prefix=analysis.title_prefix ) - plotter_interface.fit_point(fit=fit, quick_update=quick_update) + plotter.fit_point(fit=fit, quick_update=quick_update) if quick_update: return @@ -80,11 +80,11 @@ def visualize( extent=fit.dataset.extent_from(), shape_native=(100, 100) ) - plotter_interface.tracer( + plotter.tracer( tracer=tracer, grid=grid, ) - plotter_interface.galaxies( + plotter.galaxies( galaxies=tracer.galaxies, grid=grid, ) diff --git a/autolens/quantity/model/visualizer.py b/autolens/quantity/model/visualizer.py index 65ced6396..b31454271 100644 --- a/autolens/quantity/model/visualizer.py +++ b/autolens/quantity/model/visualizer.py @@ -2,9 +2,9 @@ import autofit as af -from autogalaxy.quantity.model.plotter_interface import PlotterInterfaceQuantity +from autogalaxy.quantity.model.plotter import PlotterQuantity -from autolens.analysis.plotter_interface import PlotterInterface +from autolens.analysis.plotter import Plotter class VisualizerQuantity(af.Visualizer): @@ -44,11 +44,11 @@ def visualize( fit = analysis.fit_quantity_for_instance(instance=instance) - plotter_interface = PlotterInterfaceQuantity(image_path=paths.image_path) - plotter_interface.fit_quantity(fit=fit) + plotter = PlotterQuantity(image_path=paths.image_path) + plotter.fit_quantity(fit=fit) - plotter_interface = PlotterInterface(image_path=paths.image_path) - plotter_interface.tracer( + plotter = Plotter(image_path=paths.image_path) + plotter.tracer( tracer=fit.tracer, grid=analysis.dataset.grids.lp, ) diff --git a/docs/api/plot.rst b/docs/api/plot.rst index acac39c44..c5a1fb358 100644 --- a/docs/api/plot.rst +++ b/docs/api/plot.rst @@ -17,30 +17,71 @@ Plotters [aplt] Create figures and subplots showing quantities of standard **PyAutoLens** objects. -.. currentmodule:: autogalaxy.plot +.. currentmodule:: autolens.plot + +**Basic Plot Functions:** + +.. autosummary:: + :toctree: _autosummary + + plot_array + plot_grid + +**Tracer and Galaxies Subplots:** + +.. autosummary:: + :toctree: _autosummary + + subplot_tracer + subplot_lensed_images + subplot_galaxies_images + +**Imaging Fit Subplots:** + +.. autosummary:: + :toctree: _autosummary + + subplot_fit_imaging + subplot_fit_imaging_log10 + subplot_fit_imaging_x1_plane + subplot_fit_imaging_log10_x1_plane + subplot_fit_imaging_of_planes + subplot_fit_imaging_tracer + subplot_fit_combined + subplot_fit_combined_log10 + +**Interferometer Fit Subplots:** + +.. autosummary:: + :toctree: _autosummary + + subplot_fit_interferometer + subplot_fit_interferometer_real_space + +**Point Source Subplots:** + +.. autosummary:: + :toctree: _autosummary + + subplot_fit_point + subplot_point_dataset + +**Subhalo Detection Subplots:** + +.. autosummary:: + :toctree: _autosummary + + subplot_detection_imaging + subplot_detection_fits + +**Sensitivity Mapping Subplots:** .. autosummary:: :toctree: _autosummary - :template: custom-class-template.rst - :recursive: - Array2DPlotter - Grid2DPlotter - MapperPlotter - YX1DPlotter - InversionPlotter - ImagingPlotter - InterferometerPlotter - LightProfilePlotter - GalaxyPlotter - FitImagingPlotter - FitInterferometerPlotter - GalaxiesPlotter - AdaptPlotter - FitImagingPlotter - FitInterferometerPlotter - MultiFigurePlotter - MultiYX1DPlotter + subplot_sensitivity_tracer_images + subplot_sensitivity + subplot_sensitivity_figures_of_merit Non-linear Search Plotters [aplt] --------------------------------- diff --git a/docs/overview/overview_1_start_here.rst b/docs/overview/overview_1_start_here.rst index 1c1f9cd6a..4d3c187da 100644 --- a/docs/overview/overview_1_start_here.rst +++ b/docs/overview/overview_1_start_here.rst @@ -29,11 +29,9 @@ You'll see these imports in the majority of workspace examples. .. code:: python import autolens as al + import autoarray as aa import autolens.plot as aplt - import matplotlib.pyplot as plt - from os import path - Lets illustrate a simple gravitational lensing calculation, creating an an image of a lensed galaxy using a light profile and mass profile. @@ -52,8 +50,7 @@ We make and plot a uniform Cartesian grid: pixel_scales=0.05, # The pixel-scale describes the conversion from pixel units to arc-seconds. ) - grid_plotter = aplt.Grid2DPlotter(grid=grid) - grid_plotter.figure_2d() + aplt.plot_grid(grid=grid, title="") The ``Grid2D`` looks like this: @@ -99,19 +96,16 @@ Plotting In-built plotting methods are provided for plotting objects and their properties, like the image of a light profile we just created. -By using a ``LightProfilePlotter`` to plot the light profile's image, the figured is improved. +By using ``aplt.plot_array`` to plot the light profile's image, the figure is improved. -Its axis units are scaled to arc-seconds, a color-bar is added, its given a descriptive labels, etc. +Its axis units are scaled to arc-seconds, a color-bar is added, descriptive labels are included, etc. The plot module is highly customizable and designed to make it straight forward to create clean and informative figures for fits to large datasets. .. code:: python - light_profile_plotter = aplt.LightProfilePlotter( - light_profile=sersic_light_profile, grid=grid - ) - light_profile_plotter.figures_2d(image=True) + aplt.plot_array(array=sersic_light_profile.image_2d_from(grid=grid), title="Image") .. image:: https://raw.githubusercontent.com/Jammy2211/PyAutoLens/main/docs/overview/images/overview_1/1_image_2d.png :width: 600 @@ -140,19 +134,19 @@ the deflection angles describe how the lens galaxy’s mass bends the source’s The deflection angles are easily plotted using the **PyAutoLens** plot module. -(Many other lensing quantities are also easily plotted, for example the ``convergence`` and ``potential``). +Many other lensing quantities are also easily plotted, for example the ``convergence`` and ``potential``. .. code:: python - mass_profile_plotter = aplt.MassProfilePlotter( - mass_profile=isothermal_mass_profile, grid=grid - ) - mass_profile_plotter.figures_2d( - deflections_y=True, - deflections_x=True, - # convergence=True, - # potential=True - ) + deflections_y = aa.Array2D(values=deflections.slim[:, 0], mask=grid.mask) + aplt.plot_array(array=deflections_y, title="Deflections Y") + + deflections = isothermal_mass_profile.deflections_yx_2d_from(grid=grid) + deflections_x = aa.Array2D(values=deflections.slim[:, 1], mask=grid.mask) + aplt.plot_array(array=deflections_x, title="Deflections X") + + aplt.plot_array(array=isothermal_mass_profile.convergence_2d_from(grid=grid), title="Convergence") + aplt.plot_array(array=isothermal_mass_profile.potential_2d_from(grid=grid), title="Potential") .. image:: https://raw.githubusercontent.com/Jammy2211/PyAutoLens/main/docs/overview/images/overview_1/2_deflections_y_2d.png :width: 600 @@ -194,15 +188,12 @@ We create two galaxies representing the lens and source galaxies shown in the st source_galaxy = al.Galaxy(redshift=1.0, light=source_light_profile) -The ``GalaxyPlotter`` object plots properties of the lens and source galaxies. +We can plot properties of the lens and source galaxies using ``aplt.plot_array``: .. code:: python - lens_galaxy_plotter = aplt.GalaxyPlotter(galaxy=lens_galaxy, grid=grid) - lens_galaxy_plotter.figures_2d(image=True, deflections_y=True, deflections_x=True) - - source_galaxy_plotter = aplt.GalaxyPlotter(galaxy=source_galaxy, grid=grid) - source_galaxy_plotter.figures_2d(image=True) + aplt.plot_array(array=lens_galaxy.image_2d_from(grid=grid), title="Lens Galaxy Image") + aplt.plot_array(array=source_galaxy.image_2d_from(grid=grid), title="Source Galaxy Image") .. image:: https://raw.githubusercontent.com/Jammy2211/PyAutoLens/main/docs/overview/images/overview_1/4_image_2d.png :width: 400 @@ -220,12 +211,11 @@ The ``GalaxyPlotter`` object plots properties of the lens and source galaxies. :width: 400 :alt: Alternative text -One example of the plotter's customizability is the ability to plot the individual light profiles of the galaxy -on a subplot. +The individual light profiles of the galaxy can be plotted on a subplot: .. code:: python - lens_galaxy_plotter.subplot_of_light_profiles(image=True) + aplt.subplot_galaxy_light_profiles(galaxy=lens_galaxy, grid=grid) .. image:: https://raw.githubusercontent.com/Jammy2211/PyAutoLens/main/docs/overview/images/overview_1/8_subplot_image.png :width: 600 @@ -247,10 +237,7 @@ This is shown below, where the image of the tracer shows a distinct Einstein rin tracer = al.Tracer(galaxies=[lens_galaxy, source_galaxy], cosmology=al.cosmo.Planck15()) - image = tracer.image_2d_from(grid=grid) - - tracer_plotter = aplt.TracerPlotter(tracer=tracer, grid=grid) - tracer_plotter.figures_2d(image=True) + aplt.plot_array(array=tracer.image_2d_from(grid=grid), title="Image") .. image:: https://raw.githubusercontent.com/Jammy2211/PyAutoLens/main/docs/overview/images/overview_1/9_image_2d.png :width: 600 @@ -335,8 +322,7 @@ the stellar components use a ``LightAndMassProfile`` via the ``lmp`` module. tracer = al.Tracer(galaxies=[lens_galaxy_0, lens_galaxy_1, source_galaxy]) - tracer_plotter = aplt.TracerPlotter(tracer=tracer, grid=grid) - tracer_plotter.figures_2d(image=True) + aplt.plot_array(array=tracer.image_2d_from(grid=grid), title="Image") .. image:: https://raw.githubusercontent.com/Jammy2211/PyAutoLens/main/docs/overview/images/overview_1/10_image_2d.png :width: 600 diff --git a/test_autolens/analysis/test_plotter_interface.py b/test_autolens/analysis/test_plotter.py similarity index 72% rename from test_autolens/analysis/test_plotter_interface.py rename to test_autolens/analysis/test_plotter.py index 34809ef4e..b4df8b0cf 100644 --- a/test_autolens/analysis/test_plotter_interface.py +++ b/test_autolens/analysis/test_plotter.py @@ -4,13 +4,13 @@ import pytest import autolens as al -from autolens.analysis import plotter_interface as vis +from autolens.analysis import plotter as vis directory = path.dirname(path.realpath(__file__)) @pytest.fixture(name="plot_path") -def make_plotter_interface_plotter_setup(): +def make_plotter_plotter_setup(): return path.join("{}".format(directory), "files") @@ -18,9 +18,9 @@ def test__tracer(masked_imaging_7x7, tracer_x2_plane_7x7, plot_path, plot_patch) if os.path.exists(plot_path): shutil.rmtree(plot_path) - plotter_interface = vis.PlotterInterface(image_path=plot_path) + plotter = vis.Plotter(image_path=plot_path) - plotter_interface.tracer( + plotter.tracer( tracer=tracer_x2_plane_7x7, grid=masked_imaging_7x7.grids.lp, ) @@ -38,8 +38,8 @@ def test__image_with_positions(image_7x7, positions_x2, plot_path, plot_patch): if os.path.exists(plot_path): shutil.rmtree(plot_path) - plotter_interface = vis.PlotterInterface(image_path=plot_path) + plotter = vis.Plotter(image_path=plot_path) - plotter_interface.image_with_positions(image=image_7x7, positions=positions_x2) + plotter.image_with_positions(image=image_7x7, positions=positions_x2) assert path.join(plot_path, "image_with_positions.png") in plot_patch.paths diff --git a/test_autolens/imaging/model/test_plotter_interface_imaging.py b/test_autolens/imaging/model/test_plotter_imaging.py similarity index 81% rename from test_autolens/imaging/model/test_plotter_interface_imaging.py rename to test_autolens/imaging/model/test_plotter_imaging.py index 389719d2d..8c70e79ba 100644 --- a/test_autolens/imaging/model/test_plotter_interface_imaging.py +++ b/test_autolens/imaging/model/test_plotter_imaging.py @@ -4,13 +4,13 @@ import pytest import autolens as al -from autolens.imaging.model.plotter_interface import PlotterInterfaceImaging +from autolens.imaging.model.plotter import PlotterImaging directory = path.dirname(path.realpath(__file__)) @pytest.fixture(name="plot_path") -def make_plotter_interface_plotter_setup(): +def make_plotter_plotter_setup(): return path.join("{}".format(directory), "files") @@ -20,9 +20,9 @@ def test__fit_imaging( if os.path.exists(plot_path): shutil.rmtree(plot_path) - plotter_interface = PlotterInterfaceImaging(image_path=plot_path) + plotter = PlotterImaging(image_path=plot_path) - plotter_interface.fit_imaging( + plotter.fit_imaging( fit=fit_imaging_x2_plane_inversion_7x7, ) @@ -48,7 +48,7 @@ def test__fit_imaging_combined( if path.exists(plot_path): shutil.rmtree(plot_path) - visualizer = PlotterInterfaceImaging(image_path=plot_path) + visualizer = PlotterImaging(image_path=plot_path) visualizer.fit_imaging_combined(fit_list=2 * [fit_imaging_x2_plane_inversion_7x7]) diff --git a/test_autolens/interferometer/model/test_plotter_interface_interferometer.py b/test_autolens/interferometer/model/test_plotter_interferometer.py similarity index 77% rename from test_autolens/interferometer/model/test_plotter_interface_interferometer.py rename to test_autolens/interferometer/model/test_plotter_interferometer.py index b869a7b15..dc0741366 100644 --- a/test_autolens/interferometer/model/test_plotter_interface_interferometer.py +++ b/test_autolens/interferometer/model/test_plotter_interferometer.py @@ -4,15 +4,15 @@ import autolens as al -from autolens.interferometer.model.plotter_interface import ( - PlotterInterfaceInterferometer, +from autolens.interferometer.model.plotter import ( + PlotterInterferometer, ) directory = path.dirname(path.realpath(__file__)) @pytest.fixture(name="plot_path") -def make_plotter_interface_plotter_setup(): +def make_plotter_plotter_setup(): return path.join("{}".format(directory), "files") @@ -21,9 +21,9 @@ def test__fit_interferometer( plot_path, plot_patch, ): - plotter_interface = PlotterInterfaceInterferometer(image_path=plot_path) + plotter = PlotterInterferometer(image_path=plot_path) - plotter_interface.fit_interferometer( + plotter.fit_interferometer( fit=fit_interferometer_x2_plane_7x7, ) diff --git a/test_autolens/point/model/test_plotter_interface_point.py b/test_autolens/point/model/test_plotter_point.py similarity index 62% rename from test_autolens/point/model/test_plotter_interface_point.py rename to test_autolens/point/model/test_plotter_point.py index a10eeaf82..5467c50e8 100644 --- a/test_autolens/point/model/test_plotter_interface_point.py +++ b/test_autolens/point/model/test_plotter_point.py @@ -3,13 +3,13 @@ from os import path import pytest -from autolens.point.model.plotter_interface import PlotterInterfacePoint +from autolens.point.model.plotter import PlotterPoint directory = path.dirname(path.realpath(__file__)) @pytest.fixture(name="plot_path") -def make_plotter_interface_plotter_setup(): +def make_plotter_plotter_setup(): return path.join("{}".format(directory), "files") @@ -17,8 +17,8 @@ def test__fit_point(fit_point_dataset_x2_plane, plot_path, plot_patch): if os.path.exists(plot_path): shutil.rmtree(plot_path) - plotter_interface = PlotterInterfacePoint(image_path=plot_path) + plotter = PlotterPoint(image_path=plot_path) - plotter_interface.fit_point(fit=fit_point_dataset_x2_plane) + plotter.fit_point(fit=fit_point_dataset_x2_plane) assert path.join(plot_path, "subplot_fit.png") in plot_patch.paths From 232cdd4f1232858c7bd5808256e043fb9942b25a Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Wed, 25 Mar 2026 10:07:15 +0000 Subject: [PATCH 2/2] Re-export autoarray and autogalaxy plot functions from autolens.plot Makes all AG galaxy/profile/fit subplot functions and autoarray dataset subplot functions accessible via import autolens.plot as aplt, without requiring users to import from lower-level packages directly. Co-Authored-By: Claude Sonnet 4.6 --- autolens/plot/__init__.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/autolens/plot/__init__.py b/autolens/plot/__init__.py index 6441de706..f1f26923c 100644 --- a/autolens/plot/__init__.py +++ b/autolens/plot/__init__.py @@ -3,11 +3,35 @@ from autofit.non_linear.plot.mle_plotters import MLEPlotter # --------------------------------------------------------------------------- -# Standalone plot helpers +# Standalone plot helpers (autoarray) # --------------------------------------------------------------------------- from autoarray.plot.array import plot_array from autoarray.plot.grid import plot_grid +from autoarray.dataset.plot.imaging_plots import ( + subplot_imaging, + subplot_imaging_dataset_list, +) +from autoarray.dataset.plot.interferometer_plots import subplot_interferometer_dirty_images + +# --------------------------------------------------------------------------- +# Galaxy / profile subplots (autogalaxy) +# --------------------------------------------------------------------------- +from autogalaxy.plot import ( + subplot_galaxy_light_profiles, + subplot_galaxy_mass_profiles, + subplot_basis_image, + subplot_galaxies, + subplot_galaxy_images, + subplot_adapt_images, + subplot_fit_imaging_of_galaxy, + subplot_fit_dirty_images, + subplot_fit_real_space, + subplot_fit_quantity, + subplot_fit_ellipse, + subplot_ellipse_errors, +) + # --------------------------------------------------------------------------- # subplot_* public API # ---------------------------------------------------------------------------