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
40 changes: 40 additions & 0 deletions autolens/imaging/plot/fit_imaging_plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ def figures_2d_of_planes(
subtracted_image: bool = False,
model_image: bool = False,
plane_image: bool = False,
plane_errors: bool = False,
plane_signal_to_noise_map: bool = False,
use_source_vmax: bool = False,
zoom_to_brightest: bool = True,
interpolate_to_uniform: bool = False,
Expand Down Expand Up @@ -178,6 +180,14 @@ def figures_2d_of_planes(
Whether to make a 2D plot (via `imshow`) of the image of a plane in its source-plane (e.g. unlensed).
Depending on how the fit is performed, this could either be an image of light profiles of the reconstruction
of an `Inversion`.
plane_errors
Whether to make a 2D plot (via `imshow`) of the errors of a plane in its source-plane, where the
errors can only be computed when a pixelized source reconstruction is performed and they correspond to
the errors in each reconstructed pixel as given by the inverse curvature matrix.
plane_signal_to_noise_map
Whether to make a 2D plot (via `imshow`) of the signal-to-noise map of a plane in its source-plane,
where the signal-to-noise map values can only be computed when a pixelized source reconstruction and they
are the ratio of reconstructed flux to error in each pixel.
use_source_vmax
If `True`, the maximum value of the lensed source (e.g. in the image-plane) is used to set the `vmax` of
certain plots (e.g. the `data`) in order to ensure the lensed source is visible compared to the lens.
Expand Down Expand Up @@ -294,6 +304,36 @@ def figures_2d_of_planes(
interpolate_to_uniform=interpolate_to_uniform
)

if plane_errors:

if self.tracer.planes[plane_index].has(cls=aa.Pixelization):

inversion_plotter = self.inversion_plotter_of_plane(
plane_index=plane_index
)

inversion_plotter.figures_2d_of_pixelization(
pixelization_index=0,
errors=True,
zoom_to_brightest=zoom_to_brightest,
interpolate_to_uniform=interpolate_to_uniform
)

if plane_signal_to_noise_map:

if self.tracer.planes[plane_index].has(cls=aa.Pixelization):

inversion_plotter = self.inversion_plotter_of_plane(
plane_index=plane_index
)

inversion_plotter.figures_2d_of_pixelization(
pixelization_index=0,
signal_to_noise_map=True,
zoom_to_brightest=zoom_to_brightest,
interpolate_to_uniform=interpolate_to_uniform
)

if use_source_vmax:
self.mat_plot_2d.cmap.kwargs.pop("vmax")

Expand Down
41 changes: 41 additions & 0 deletions autolens/interferometer/plot/fit_interferometer_plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,10 @@ def figures_2d_of_planes(
self,
plane_index: Optional[int] = None,
plane_image: bool = False,
plane_errors: bool = False,
plane_signal_to_noise_map: bool = False,
zoom_to_brightest: bool = True,
interpolate_to_uniform: bool = False,
):
"""
Plots images representing each individual `Plane` in the fit's `Tracer` in 2D, which are computed via the
Expand All @@ -390,9 +393,20 @@ def figures_2d_of_planes(
Whether to make a 2D plot (via `imshow`) of the image of a plane in its source-plane (e.g. unlensed).
Depending on how the fit is performed, this could either be an image of light profiles of the reconstruction
of an `Inversion`.
plane_errors
Whether to make a 2D plot (via `imshow`) of the errors of a plane in its source-plane, where the
errors can only be computed when a pixelized source reconstruction is performed and they correspond to
the errors in each reconstructed pixel as given by the inverse curvature matrix.
plane_signal_to_noise_map
Whether to make a 2D plot (via `imshow`) of the signal-to-noise map of a plane in its source-plane,
where the signal-to-noise map values can only be computed when a pixelized source reconstruction and they
are the ratio of reconstructed flux to error in each pixel.
zoom_to_brightest
For images not in the image-plane (e.g. the `plane_image`), whether to automatically zoom the plot to
the brightest regions of the galaxies being plotted as opposed to the full extent of the grid.
interpolate_to_uniform
If `True`, the mapper's reconstruction is interpolated to a uniform grid before plotting, for example
meaning that an irregular Delaunay grid can be plotted as a uniform grid.
"""
if plane_image:
if not self.tracer.planes[plane_index].has(cls=aa.Pixelization):
Expand All @@ -408,6 +422,33 @@ def figures_2d_of_planes(
pixelization_index=0,
reconstruction=True,
zoom_to_brightest=zoom_to_brightest,
interpolate_to_uniform=interpolate_to_uniform,
)

if plane_errors:
if self.tracer.planes[plane_index].has(cls=aa.Pixelization):
inversion_plotter = self.inversion_plotter_of_plane(
plane_index=plane_index
)

inversion_plotter.figures_2d_of_pixelization(
pixelization_index=0,
errors=True,
zoom_to_brightest=zoom_to_brightest,
interpolate_to_uniform=interpolate_to_uniform,
)

if plane_signal_to_noise_map:
if self.tracer.planes[plane_index].has(cls=aa.Pixelization):
inversion_plotter = self.inversion_plotter_of_plane(
plane_index=plane_index
)

inversion_plotter.figures_2d_of_pixelization(
pixelization_index=0,
signal_to_noise_map=True,
zoom_to_brightest=zoom_to_brightest,
interpolate_to_uniform=interpolate_to_uniform,
)

def subplot_fit_real_space(self):
Expand Down
2 changes: 0 additions & 2 deletions test_autolens/imaging/plot/test_fit_imaging_plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ def test__figures_of_plane(
subtracted_image=True, model_image=True, plane_index=0, plane_image=True
)

print(plot_patch.paths)

assert path.join(plot_path, "source_subtracted_image.png") in plot_patch.paths
assert (
path.join(plot_path, "lens_subtracted_image.png") not in plot_patch.paths
Expand Down