Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@lensing_plotters.set_include_and_plotter
@plotters.set_labels
def normalized_residual_map(fit, include=None, plotter=None):
"""Plot the residual-map of a lens fit.
Set *autolens.datas.array.plotters.plotters* for a description of all input parameters not described below.
Parameters
-----------
fit : datas.fitting.fitting.AbstractFitter
The fit to the datas, which include a list of every model image, normalized_residual_map, chi-squareds, etc.
image_index : int
The index of the datas in the datas-set of which the normalized_residual_map are plotted.
"""
plotter.plot_array(
array=fit.normalized_residual_map,
mask=include.mask_from_fit(fit=fit),
@lensing_plotters.set_include_and_plotter
@plotters.set_labels
def chi_squared_map(fit, include=None, plotter=None):
"""Plot the chi-squared map of a lens fit.
Set *autolens.datas.array.plotters.plotters* for a description of all input parameters not described below.
Parameters
-----------
fit : datas.fitting.fitting.AbstractFitter
The fit to the datas, which include a list of every model image, residual_map, chi-squareds, etc.
image_index : int
The index of the datas in the datas-set of which the chi-squareds are plotted.
"""
plotter.plot_array(
array=fit.chi_squared_map,
mask=include.mask_from_fit(fit=fit),
mass_profile_centres=self.include.mass_profile_centres_from_obj(
obj=fit.tracer.image_plane
),
critical_curves=self.include.critical_curves_from_obj(
obj=fit.tracer
),
caustics=self.include.caustics_from_obj(obj=fit.tracer),
include=self.include,
sub_plotter=self.sub_plotter,
)
plotter = self.plotter.plotter_with_new_output(
path=self.plotter.output.path + "inversion/"
)
inversion_plots.individuals(
inversion=fit.inversion,
image_positions=self.include.positions_from_fit(fit=fit),
source_positions=self.include.positions_of_plane_from_fit_and_plane_index(
fit=fit, plane_index=-1
),
grid=self.include.inversion_image_pixelization_grid_from_fit(fit=fit),
light_profile_centres=self.include.light_profile_centres_from_obj(
obj=fit.tracer.image_plane
),
mass_profile_centres=self.include.mass_profile_centres_from_obj(
obj=fit.tracer.image_plane
),
critical_curves=self.include.critical_curves_from_obj(obj=fit.tracer),
caustics=self.include.caustics_from_obj(obj=fit.tracer),
plot_reconstructed_image=self.plot_inversion_reconstruction,
plot_reconstruction=self.plot_inversion_reconstruction,
fit_interferometer_plots.individuals(
fit=fit,
plot_visibilities=True,
plot_noise_map=True,
plot_signal_to_noise_map=True,
plot_model_visibilities=True,
plot_residual_map=True,
plot_normalized_residual_map=True,
plot_chi_squared_map=True,
include=self.include,
plotter=fits_plotter,
)
if fit.inversion is not None:
inversion_plots.individuals(
inversion=fit.inversion,
image_positions=self.include.positions_from_fit(fit=fit),
source_positions=self.include.positions_of_plane_from_fit_and_plane_index(
fit=fit, plane_index=-1
),
grid=self.include.inversion_image_pixelization_grid_from_fit(
fit=fit
),
light_profile_centres=self.include.light_profile_centres_from_obj(
obj=fit.tracer.image_plane
),
mass_profile_centres=self.include.mass_profile_centres_from_obj(
obj=fit.tracer.image_plane
),
critical_curves=self.include.critical_curves_from_obj(
obj=fit.tracer
if self.plot_fit_all_at_end_png:
fit_interferometer_plots.individuals(
fit=fit,
plot_visibilities=True,
plot_noise_map=True,
plot_signal_to_noise_map=True,
plot_model_visibilities=True,
plot_residual_map=True,
plot_normalized_residual_map=True,
plot_chi_squared_map=True,
include=self.include,
plotter=plotter,
)
if fit.inversion is not None:
inversion_plots.individuals(
inversion=fit.inversion,
image_positions=self.include.positions_from_fit(fit=fit),
source_positions=self.include.positions_of_plane_from_fit_and_plane_index(
fit=fit, plane_index=-1
),
grid=self.include.inversion_image_pixelization_grid_from_fit(
fit=fit
),
light_profile_centres=self.include.light_profile_centres_from_obj(
obj=fit.tracer.image_plane
),
mass_profile_centres=self.include.mass_profile_centres_from_obj(
obj=fit.tracer.image_plane
),
critical_curves=self.include.critical_curves_from_obj(
obj=fit.tracer
sub_plotter.setup_subplot(number_subplots=number_subplots, subplot_index=1)
if fit.inversion is None:
ray_tracing_plots.image(
tracer=fit.tracer,
grid=fit.masked_interferometer.grid,
positions=include.positions_from_fit(fit=fit),
include=include,
plotter=sub_plotter,
)
sub_plotter.setup_subplot(number_subplots=number_subplots, subplot_index=2)
ag.plot.Plane.plane_image(
plane=fit.tracer.source_plane,
grid=fit.masked_interferometer.grid,
positions=include.positions_of_plane_from_fit_and_plane_index(
fit=fit, plane_index=-1
),
caustics=include.caustics_from_obj(obj=fit.tracer),
plotter=sub_plotter,
)
elif fit.inversion is not None:
ag.plot.Inversion.reconstructed_image(
inversion=fit.inversion,
light_profile_centres=include.light_profile_centres_from_obj(
fit.tracer.image_plane
),
plot_signal_to_noise_map=self.plot_fit_signal_to_noise_map,
plot_model_image=self.plot_fit_model_data,
plot_residual_map=self.plot_fit_residual_map,
plot_chi_squared_map=self.plot_fit_chi_squared_map,
plot_normalized_residual_map=self.plot_fit_normalized_residual_map,
plot_subtracted_images_of_planes=self.plot_fit_subtracted_images_of_planes,
plot_model_images_of_planes=self.plot_fit_model_images_of_planes,
plot_plane_images_of_planes=self.plot_fit_plane_images_of_planes,
include=self.include,
plotter=plotter,
)
if fit.inversion is not None:
if self.plot_subplot_inversion:
inversion_plots.subplot_inversion(
inversion=fit.inversion,
image_positions=self.include.positions_from_fit(fit=fit),
source_positions=self.include.positions_of_plane_from_fit_and_plane_index(
fit=fit, plane_index=-1
),
grid=self.include.inversion_image_pixelization_grid_from_fit(
fit=fit
),
light_profile_centres=self.include.light_profile_centres_from_obj(
obj=fit.tracer.image_plane
),
mass_profile_centres=self.include.mass_profile_centres_from_obj(
obj=fit.tracer.image_plane
),
critical_curves=self.include.critical_curves_from_obj(
obj=fit.tracer
@lensing_plotters.set_include_and_plotter
@plotters.set_labels
def deflections_y(tracer, grid, include=None, plotter=None):
deflections = tracer.deflections_from_grid(grid=grid)
deflections_y = arrays.MaskedArray.manual_1d(
array=deflections.in_1d[:, 0], mask=grid.mask
)
plotter.plot_array(
array=deflections_y,
mask=include.mask_from_grid(grid=grid),
critical_curves=include.critical_curves_from_obj(obj=tracer),
light_profile_centres=include.light_profile_centres_from_obj(obj=tracer),
mass_profile_centres=include.mass_profile_centres_from_obj(obj=tracer),
include_origin=include.origin,
)
@lensing_plotters.set_include_and_plotter
@plotters.set_labels
def model_image_of_plane(fit, plane_index, include=None, plotter=None):
"""Plot the model image of a specific plane of a lens fit.
Set *autolens.datas.arrays.plotters.plotters* for a description of all input parameters not described below.
Parameters
-----------
fit : datas.fitting.fitting.AbstractFitter
The fit to the datas, which includes a list of every model image, residual_map, chi-squareds, etc.
plane_indexes : [int]
The plane from which the model image is generated.
"""
if isinstance(plotter, lensing_plotters.Plotter):
plotter = plotter.plotter_with_new_output(
@lensing_plotters.set_include_and_plotter
@plotters.set_labels
def image(tracer, grid, positions=None, include=None, plotter=None):
plotter.plot_array(
array=tracer.image_from_grid(grid=grid),
mask=include.mask_from_grid(grid=grid),
positions=positions,
critical_curves=include.critical_curves_from_obj(obj=tracer),
light_profile_centres=include.light_profile_centres_from_obj(obj=tracer),
mass_profile_centres=include.mass_profile_centres_from_obj(obj=tracer),
include_origin=include.origin,
)