Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down
14 changes: 7 additions & 7 deletions autolens/config/visualize/plots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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?
Expand All @@ -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?
Expand All @@ -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?
4 changes: 2 additions & 2 deletions autolens/imaging/fit_imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
24 changes: 12 additions & 12 deletions autolens/imaging/model/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:

Expand All @@ -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(
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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,
)

Expand Down Expand Up @@ -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
)

Expand Down Expand Up @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion autolens/imaging/plot/fit_imaging_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
4 changes: 2 additions & 2 deletions autolens/interferometer/fit_interferometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
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
from autolens.interferometer.plot.fit_interferometer_plots import (
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,
Expand Down
24 changes: 12 additions & 12 deletions autolens/interferometer/model/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:

Expand All @@ -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(
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions autolens/lens/plot/sensitivity_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions autolens/lens/plot/tracer_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---
Expand Down
Loading
Loading