def plot_noise_map( fit, mask=None, extract_array_from_mask=False, zoom_around_mask=False, positions=None, as_subplot=False, units="arcsec", kpc_per_arcsec=None, figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Fit Noise-Map", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, mask_pointsize=10, position_pointsize=10, output_path=None, output_format="show", output_filename="fit_noise_map", ): """Plot the noise-map of a lens fit. Set *autolens.datas.array.plotters.array_plotters* for a description of all input parameters not described below. Parameters ----------- image : datas.imaging.datas.Imaging The datas-datas, which includes the observed datas, noise_map-map, PSF, signal-to-noise_map-map, etc. plot_origin : True If true, the origin of the datas's coordinate system is plotted as a 'x'. """ noise_map = fit.noise_map(return_in_2d=True) array_plotters.plot_array( array=noise_map, mask=mask, extract_array_from_mask=extract_array_from_mask, zoom_around_mask=zoom_around_mask, positions=positions, as_subplot=as_subplot, units=units, kpc_per_arcsec=kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, mask_pointsize=mask_pointsize, position_pointsize=position_pointsize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
def plot_model_image_of_plane( fit, plane_index, mask=None, extract_array_from_mask=False, zoom_around_mask=False, positions=None, plot_mass_profile_centres=True, as_subplot=False, units="arcsec", kpc_per_arcsec=None, figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Model Image", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, mask_pointsize=10, position_pointsize=10, output_path=None, output_format="show", output_filename="fit_model_image_of_plane", ): """Plot the model image of a specific plane of a lens fit. Set *autolens.datas.array.plotters.array_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. """ output_filename += "_" + str(plane_index) centres = get_mass_profile_centes( plot_mass_profile_centres=plot_mass_profile_centres, fit=fit) array_plotters.plot_array( array=fit.model_images_of_planes(return_in_2d=True)[plane_index], mask=mask, extract_array_from_mask=extract_array_from_mask, zoom_around_mask=zoom_around_mask, positions=positions, centres=centres, as_subplot=as_subplot, units=units, kpc_per_arcsec=kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, mask_pointsize=mask_pointsize, position_pointsize=position_pointsize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
def plot_contribution_maps( fit, mask=None, extract_array_from_mask=False, zoom_around_mask=False, positions=None, as_subplot=False, units="arcsec", kpc_per_arcsec=None, figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Contributions", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, mask_pointsize=10, position_pointsize=10, output_path=None, output_format="show", output_filename="fit_contribution_maps", ): """Plot the summed contribution maps of a hyper_galaxies-fit. Set *autolens.datas.array.plotters.array_plotters* for a description of all input parameters not described below. Parameters ----------- fit : datas.fitting.fitting.AbstractLensHyperFit The hyper_galaxies-fit to the datas, which includes 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 contribution_maps are plotted. """ if len(fit.contribution_maps) > 1: contribution_map = sum(fit.contribution_maps) else: contribution_map = fit.contribution_maps[0] array_plotters.plot_array( array=contribution_map, mask=mask, extract_array_from_mask=extract_array_from_mask, zoom_around_mask=zoom_around_mask, positions=positions, as_subplot=as_subplot, units=units, kpc_per_arcsec=kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, mask_pointsize=mask_pointsize, position_pointsize=position_pointsize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
def plot_reconstructed_image( inversion, mask=None, positions=None, grid=None, as_subplot=False, extract_array_from_mask=False, zoom_around_mask=False, units="arcsec", kpc_per_arcsec=None, figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Reconstructed Image", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, output_path=None, output_format="show", output_filename="reconstructed_inversion_image", ): array_plotters.plot_array( array=inversion.reconstructed_data_2d, mask=mask, positions=positions, grid=grid, as_subplot=as_subplot, extract_array_from_mask=extract_array_from_mask, zoom_around_mask=zoom_around_mask, units=units, kpc_per_arcsec=kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
from autolens.array import mask as msk from test.simulation import simulation_util from autolens.plotters import array_plotters # In this tutorial, we'll introduce a new pixelization, called an adaptive-pixelization. This pixelization doesn't use # uniform grid of rectangular pixels, but instead uses ir'Voronoi' pixels. So, why would we want to do that? # Lets take another look at the rectangular grid, and think about its weakness. # Lets quickly remind ourselves of the image, and the 3.0" circular mask we'll use to mask it. imaging_data = simulation_util.load_test_imaging_data( data_type="lens_light_dev_vaucouleurs", data_resolution="LSST") array = imaging_data.image mask = al.Mask.elliptical( shape=imaging_data.shape, pixel_scale=imaging_data.pixel_scale, major_axis_radius_arcsec=3.0, axis_ratio=1.0, phi=0.0, centre=(0.0, 0.0), ) array_plotters.plot_array(array=array)
def plot_deflections_x( tracer, grid, mask=None, extract_array_from_mask=False, zoom_around_mask=False, as_subplot=False, units="arcsec", figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Tracer Deflections (x)", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, output_path=None, output_format="show", output_filename="tracer_deflections_x", ): deflections = tracer.deflections_from_grid( grid=grid, return_in_2d=False, return_binned=True ) deflections_x = grid.mapping.scaled_array_2d_from_array_1d( array_1d=deflections[:, 1] ) array_plotters.plot_array( array=deflections_x, mask=mask, extract_array_from_mask=extract_array_from_mask, zoom_around_mask=zoom_around_mask, as_subplot=as_subplot, units=units, kpc_per_arcsec=tracer.image_plane.kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
def plot_magnification( mass_profile, grid, mask=None, extract_array_from_mask=False, zoom_around_mask=False, positions=None, as_subplot=False, plot_critical_curves=False, plot_caustics=False, units="arcsec", kpc_per_arcsec=None, figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Magnification", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, mask_pointsize=10, position_pointsize=10.0, grid_pointsize=1, output_path=None, output_format="show", output_filename="magnification", ): """Plot the magnification of a mass profile, on a grid of (y,x) coordinates. Set *autolens.hyper_galaxies.array.plotters.array_plotters* for a description of all innput parameters not described below. Parameters ----------- mass_profile : model.profiles.mass_profiles.MassProfile The mass profile whose magnification is plotted. grid : ndarray or hyper_galaxies.array.grid_stacks.Grid The (y,x) coordinates of the grid, in an array of shape (total_coordinates, 2) """ magnification = mass_profile.magnification_from_grid( grid=grid, bypass_decorator=False) lines = plotter_util.get_critical_curve_and_caustic( obj=mass_profile, grid=grid, plot_critical_curve=plot_critical_curves, plot_caustics=plot_caustics, ) array_plotters.plot_array( array=magnification, mask=mask, extract_array_from_mask=extract_array_from_mask, zoom_around_mask=zoom_around_mask, positions=positions, lines=lines, as_subplot=as_subplot, units=units, kpc_per_arcsec=kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, mask_pointsize=mask_pointsize, position_pointsize=position_pointsize, grid_pointsize=grid_pointsize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
from autolens.array import scaled_array from autolens.plotters import array_plotters import numpy as np array = scaled_array.ScaledSquarePixelArray(array=np.ones((50, 50)), pixel_scale=0.1) # array_plotters.plot_array(array=array, centres=[[(1.0, 1.0)], [(-1.0, 1.0)], [(-2.0, -2.0), (-3.0, -3.0)]]) array_plotters.plot_array(array=array, centres=[[(0.0, 0.0)]], axis_ratios=[[0.5]], phis=[[45.0]]) stop array_plotters.plot_array( array=array, centres=[[(0.0, 0.0)], [(-1.0, 1.0)], [(-2.0, -2.0), (-3.0, -3.0)]], axis_ratios=[[0.5], [0.5], [0.3, 0.3]], phis=[[0.0], [90.0], [45.0, 15.0]], ) array_plotters.plot_array(array=array, positions=[[[1.0, 1.0], [2.0, 2.0]], [[-1.0, -1.0]]])
def plot_image( image, plot_origin=True, grid=None, mask=None, extract_array_from_mask=False, zoom_around_mask=False, should_plot_border=False, positions=None, as_subplot=False, units="arcsec", kpc_per_arcsec=None, figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Image", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, mask_pointsize=10, position_pointsize=30, grid_pointsize=1, output_path=None, output_format="show", output_filename="image", ): """Plot the observed image of the imaging data_type. Set *autolens.data_type.array.plotters.array_plotters* for a description of all input parameters not described below. Parameters ----------- image : ScaledSquarePixelArray The image of the data. plot_origin : True If true, the origin of the data's coordinate system is plotted as a 'x'. image_plane_pix_grid : ndarray or data_type.array.grid_stacks.PixGrid If an adaptive pixelization whose pixels are formed by tracing pixels from the data, this plots those pixels \ over the immage. """ origin = get_origin(array=image, plot_origin=plot_origin) array_plotters.plot_array( array=image, origin=origin, grid=grid, mask=mask, extract_array_from_mask=extract_array_from_mask, zoom_around_mask=zoom_around_mask, should_plot_border=should_plot_border, positions=positions, as_subplot=as_subplot, units=units, kpc_per_arcsec=kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, mask_pointsize=mask_pointsize, position_pointsize=position_pointsize, grid_pointsize=grid_pointsize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
def plot_deflections_y( plane, grid, mask=None, extract_array_from_mask=False, zoom_around_mask=False, plot_critical_curves=False, plot_caustics=False, as_subplot=False, units="arcsec", figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Plane Deflections (y)", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, output_path=None, output_format="show", output_filename="plane_deflections_y", ): deflections = plane.deflections_from_grid(grid=grid, return_in_2d=False, return_binned=True) deflections_y = grid.mapping.scaled_array_2d_from_array_1d( array_1d=deflections[:, 0]) lines = plotter_util.get_critical_curve_and_caustic( obj=plane, grid=grid, plot_critical_curve=plot_critical_curves, plot_caustics=plot_caustics, ) array_plotters.plot_array( array=deflections_y, mask=mask, extract_array_from_mask=extract_array_from_mask, zoom_around_mask=zoom_around_mask, lines=lines, as_subplot=as_subplot, units=units, kpc_per_arcsec=plane.kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
def plot_magnification( plane, grid, mask=None, extract_array_from_mask=False, zoom_around_mask=False, plot_critical_curves=False, plot_caustics=False, as_subplot=False, units="arcsec", figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Plane Magnification", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, output_path=None, output_format="show", output_filename="plane_magnification", ): magnification = plane.magnification_from_grid(grid=grid, bypass_decorator=False) lines = plotter_util.get_critical_curve_and_caustic( obj=plane, grid=grid, plot_critical_curve=plot_critical_curves, plot_caustics=plot_caustics, ) array_plotters.plot_array( array=magnification, mask=mask, extract_array_from_mask=extract_array_from_mask, zoom_around_mask=zoom_around_mask, lines=lines, as_subplot=as_subplot, units=units, kpc_per_arcsec=plane.kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
def plot_plane_image( plane, grid, plot_origin=True, positions=None, plot_grid=True, lines=None, as_subplot=False, units="arcsec", figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Plane Image", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, position_pointsize=10, grid_pointsize=1, output_path=None, output_format="show", output_filename="plane_plane_image", ): plane_image = plane.plane_image_from_grid(grid=grid) if not plot_grid: grid = None if plot_origin: origin = plane_image.origin else: origin = None array_plotters.plot_array( array=plane_image, origin=origin, positions=positions, grid=grid, lines=lines, as_subplot=as_subplot, units=units, kpc_per_arcsec=plane.kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, position_pointsize=position_pointsize, grid_pointsize=grid_pointsize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
def plot_profile_image( plane, grid, mask=None, extract_array_from_mask=False, zoom_around_mask=False, positions=None, plot_grid=False, plot_critical_curves=False, plot_caustics=False, as_subplot=False, units="arcsec", figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Plane Profile Image", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, mask_pointsize=10, position_pointsize=10.0, grid_pointsize=1, output_path=None, output_format="show", output_filename="plane_profile_image", ): profile_image = plane.profile_image_from_grid(grid=grid, bypass_decorator=False) if plane.has_mass_profile: lines = plotter_util.get_critical_curve_and_caustic( obj=plane, grid=grid, plot_critical_curve=plot_critical_curves, plot_caustics=plot_caustics, ) else: lines = None if not plot_grid: grid = None array_plotters.plot_array( array=profile_image, mask=mask, extract_array_from_mask=extract_array_from_mask, zoom_around_mask=zoom_around_mask, positions=positions, grid=grid, lines=lines, as_subplot=as_subplot, units=units, kpc_per_arcsec=plane.kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, mask_pointsize=mask_pointsize, position_pointsize=position_pointsize, grid_pointsize=grid_pointsize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
def plot_deflections_x( galaxy, grid, mask=None, extract_array_from_mask=False, zoom_around_mask=False, positions=None, plot_critical_curves=False, plot_caustics=False, as_subplot=False, units="arcsec", kpc_per_arcsec=None, figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Galaxy Deflections (x)", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, mask_pointsize=10, position_pointsize=10.0, grid_pointsize=1, output_path=None, output_format="show", output_filename="galaxy_deflections_x", ): """Plot the x component of the deflection angles of a galaxy, on a grid of (y,x) coordinates. Set *autolens.datas.array.plotters.array_plotters* for a description of all innput parameters not described below. Parameters ----------- galaxy : model.galaxy.galaxy.Galaxy The galaxy whose x deflecton angles are plotted. grid : ndarray or datas.array.grid_stacks.Grid The (y,x) coordinates of the grid, in an array of shape (total_coordinates, 2) """ deflections = galaxy.deflections_from_grid(grid, return_in_2d=False, return_binned=True) deflections_x = grid.mapping.scaled_array_2d_from_array_1d(deflections[:, 1]) lines = plotter_util.get_critical_curve_and_caustic( obj=galaxy, grid=grid, plot_critical_curve=plot_critical_curves, plot_caustics=plot_caustics, ) array_plotters.plot_array( array=deflections_x, mask=mask, extract_array_from_mask=extract_array_from_mask, zoom_around_mask=zoom_around_mask, positions=positions, lines=lines, as_subplot=as_subplot, units=units, kpc_per_arcsec=kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, mask_pointsize=mask_pointsize, position_pointsize=position_pointsize, grid_pointsize=grid_pointsize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
# Lets quickly remind ourselves of the image, and the 3.0" circular mask we'll use to mask it. imaging_data = simulation_util.load_test_imaging_data( data_type="lens_light_dev_vaucouleurs", data_resolution="LSST") array = imaging_data.image mask = al.Mask.circular( shape=imaging_data.shape, pixel_scale=imaging_data.pixel_scale, radius_arcsec=5.0, centre=(0.0, 0.0), ) array_plotters.plot_array( array=array, mask=mask, positions=[[[1.0, 1.0]]], centres=[[(0.0, 0.0)]], zoom_around_mask=True, extract_array_from_mask=True, ) imaging_data = simulation_util.load_test_imaging_data( data_type="lens_sis__source_smooth__offset_centre", data_resolution="LSST") array = imaging_data.image mask = al.Mask.circular( shape=imaging_data.shape, pixel_scale=imaging_data.pixel_scale, radius_arcsec=5.0, centre=(1.0, 1.0), ) array_plotters.plot_array(array=array,
def plot_potential_chi_squared_map( potential_chi_squared_map, plot_origin=True, mask=None, extract_array_from_mask=False, zoom_around_mask=False, as_subplot=False, units="arcsec", kpc_per_arcsec=None, figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Potential Chi-Squared Map", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, mask_pointsize=10, output_path=None, output_format="show", output_filename="potential_chi_squared_map", ): """Plot the signal-to-noise_map of the imaging data_type. Set *autolens.data_type.array.plotters.array_plotters* for a description of all input parameters not described below. Parameters ----------- potential_chi_squared_map : ScaledSquarePixelArray The signal-to-noise map of the data. plot_origin : True If true, the origin of the data's coordinate system is plotted as a 'x'. """ origin = get_origin(array=potential_chi_squared_map, plot_origin=plot_origin) array_plotters.plot_array( array=potential_chi_squared_map, origin=origin, mask=mask, extract_array_from_mask=extract_array_from_mask, zoom_around_mask=zoom_around_mask, as_subplot=as_subplot, units=units, kpc_per_arcsec=kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, mask_pointsize=mask_pointsize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
def plot_potential( tracer, grid, mask=None, extract_array_from_mask=False, zoom_around_mask=False, as_subplot=False, units="arcsec", figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Tracer Potential", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, output_path=None, output_format="show", output_filename="tracer_potential", ): potential = tracer.potential_from_grid( grid=grid, bypass_decorator=False ) array_plotters.plot_array( array=potential, mask=mask, extract_array_from_mask=extract_array_from_mask, zoom_around_mask=zoom_around_mask, as_subplot=as_subplot, units=units, kpc_per_arcsec=tracer.image_plane.kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
def plot_primary_beam( primary_beam, plot_origin=True, as_subplot=False, units="arcsec", kpc_per_arcsec=None, figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Primary Beam", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, output_path=None, output_format="show", output_filename="primary_beam", ): """Plot the PSF of the imaging data_type. Set *autolens.data_type.array.plotters.array_plotters* for a description of all input parameters not described below. Parameters ----------- signal_to_noise_map : ScaledSquarePixelArray The primary_beam of the data. plot_origin : True If true, the origin of the data's coordinate system is plotted as a 'x'. """ origin = get_origin(array=primary_beam, plot_origin=plot_origin) array_plotters.plot_array( array=primary_beam, origin=origin, as_subplot=as_subplot, units=units, kpc_per_arcsec=kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
def plot_galaxy_data_array( galaxy_data, mask=None, extract_array_from_mask=False, zoom_around_mask=False, positions=None, as_subplot=False, units="arcsec", kpc_per_arcsec=None, figsize=None, aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, titlesize=10, xlabelsize=10, ylabelsize=10, xyticksize=10, mask_pointsize=10, position_pointsize=10.0, grid_pointsize=1, output_path=None, output_filename="galaxy_data", output_format="show", ): if galaxy_data.use_image: title = "Galaxy Data Image" elif galaxy_data.use_convergence: title = "Galaxy Data Convergence" elif galaxy_data.use_potential: title = "Galaxy Data Potential" elif galaxy_data.use_deflections_y: title = "Galaxy Data Deflections (y)" elif galaxy_data.use_deflections_x: title = "Galaxy Data Deflections (x)" else: raise exc.PlottingException( "The galaxy data_type array does not have a True use_profile_type") array_plotters.plot_array( array=galaxy_data.image(return_in_2d=True), mask=mask, extract_array_from_mask=extract_array_from_mask, zoom_around_mask=zoom_around_mask, positions=positions, as_subplot=as_subplot, units=units, kpc_per_arcsec=kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, mask_pointsize=mask_pointsize, position_pointsize=position_pointsize, grid_pointsize=grid_pointsize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
def plot_normalized_residual_map( fit, mask=None, extract_array_from_mask=False, zoom_around_mask=False, positions=None, as_subplot=False, units="arcsec", kpc_per_arcsec=None, figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Fit Normalized Residuals", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, mask_pointsize=10, position_pointsize=10, output_path=None, output_format="show", output_filename="fit_normalized_residual_map", ): """Plot the residual-map of a lens fit. Set *autolens.datas.array.plotters.array_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, 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. """ normalized_residual_map = fit.normalized_residual_map(return_in_2d=True) array_plotters.plot_array( array=normalized_residual_map, mask=mask, extract_array_from_mask=extract_array_from_mask, zoom_around_mask=zoom_around_mask, positions=positions, as_subplot=as_subplot, units=units, kpc_per_arcsec=kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, mask_pointsize=mask_pointsize, position_pointsize=position_pointsize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
difference_y = deflections[:, 0] - true_deflections[:, 0] difference_x = deflections[:, 1] - true_deflections[:, 1] print("interpolation y error: ", np.mean(difference_y)) print("interpolation y uncertainty: ", np.std(difference_y)) print("interpolation y max error: ", np.max(difference_y)) print("interpolation x error: ", np.mean(difference_x)) print("interpolation x uncertainty: ", np.std(difference_x)) print("interpolation x max error: ", np.max(difference_x)) difference_y_2d = lens_data.grid.scaled_array_2d_with_sub_dimensions_from_sub_array_1d( sub_array_1d=difference_y) difference_x_2d = lens_data.grid.scaled_array_2d_with_sub_dimensions_from_sub_array_1d( sub_array_1d=difference_x) array_plotters.plot_array(array=true_deflections_y_2d) array_plotters.plot_array(array=difference_y_2d) array_plotters.plot_array(array=true_deflections_x_2d) array_plotters.plot_array(array=difference_x_2d) # difference_percent_y = (np.abs(difference_y) / np.abs(true_deflections[:,0]))*100.0 # difference_percent_x = (np.abs(difference_x) / np.abs(true_deflections[:,1]))*100.0 # # print("interpolation y mean percent difference: ", np.mean(difference_percent_y)) # print("interpolation y std percent difference: ", np.std(difference_percent_y)) # print("interpolation y max percent difference: ", np.max(difference_percent_y)) # print("interpolation x mean percent difference: ", np.mean(difference_percent_x)) # print("interpolation x std percent difference: ", np.std(difference_percent_x)) # print("interpolation x mean percent difference: ", np.max(difference_percent_x)) #
def plot_subtracted_image_of_plane( fit, plane_index, mask=None, extract_array_from_mask=False, zoom_around_mask=False, positions=None, image_plane_pix_grid=None, as_subplot=False, units="arcsec", kpc_per_arcsec=None, figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Fit Model Image", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, mask_pointsize=10, position_pointsize=10, output_path=None, output_format="show", output_filename="fit_subtracted_image_of_plane", ): """Plot the model image of a specific plane of a lens fit. Set *autolens.datas.array.plotters.array_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. image_index : int The index of the datas in the datas-set of which the model image is plotted. plane_indexes : int The plane from which the model image is generated. """ output_filename += "_" + str(plane_index) if fit.tracer.total_planes > 1: other_planes_model_images_2d = [ model_image_2d for i, model_image_2d in enumerate( fit.model_images_of_planes(return_in_2d=True)) if i != plane_index ] subtracted_image = fit.image( return_in_2d=True) - sum(other_planes_model_images_2d) else: subtracted_image = fit.image(return_in_2d=True) array_plotters.plot_array( array=subtracted_image, mask=mask, extract_array_from_mask=extract_array_from_mask, grid=image_plane_pix_grid, zoom_around_mask=zoom_around_mask, positions=positions, as_subplot=as_subplot, units=units, kpc_per_arcsec=kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, mask_pointsize=mask_pointsize, position_pointsize=position_pointsize, output_path=output_path, output_format=output_format, output_filename=output_filename, )
def plot_inversion_with_source_values( inversion, source_pixel_values, plot_origin=True, positions=None, should_plot_centres=False, should_plot_grid=False, should_plot_border=False, image_pixels=None, source_pixels=None, as_subplot=False, units="arcsec", kpc_per_arcsec=None, figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Reconstructed Pixelization", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, output_path=None, output_format="show", output_filename="pixelization_source_values", ): if isinstance(inversion.mapper, mappers.RectangularMapper): reconstructed_pixelization = inversion.mapper.reconstructed_pixelization_from_solution_vector( solution_vector=source_pixel_values) origin = get_origin(image=reconstructed_pixelization, plot_origin=plot_origin) array_plotters.plot_array( array=reconstructed_pixelization, origin=origin, positions=positions, as_subplot=True, units=units, kpc_per_arcsec=kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, output_filename=output_filename, ) mapper_plotters.plot_rectangular_mapper( mapper=inversion.mapper, should_plot_centres=should_plot_centres, should_plot_grid=should_plot_grid, should_plot_border=should_plot_border, image_pixels=image_pixels, source_pixels=source_pixels, as_subplot=True, units=units, kpc_per_arcsec=kpc_per_arcsec, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, ) plotter_util.output_figure( array=reconstructed_pixelization, as_subplot=as_subplot, output_path=output_path, output_filename=output_filename, output_format=output_format, ) elif isinstance(inversion.mapper, mappers.VoronoiMapper): mapper_plotters.plot_voronoi_mapper( mapper=inversion.mapper, source_pixel_values=source_pixel_values, should_plot_centres=should_plot_centres, should_plot_grid=should_plot_grid, should_plot_border=should_plot_border, image_pixels=image_pixels, source_pixels=source_pixels, as_subplot=True, units=units, kpc_per_arcsec=kpc_per_arcsec, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, ) plotter_util.output_figure( array=None, as_subplot=as_subplot, output_path=output_path, output_filename=output_filename, output_format=output_format, )
def plot_hyper_chi_squared_map( hyper_chi_squared_map, mask=None, extract_array_from_mask=False, zoom_around_mask=False, positions=None, image_plane_pix_grid=None, as_subplot=False, units="arcsec", kpc_per_arcsec=None, figsize=(7, 7), aspect="square", cmap="jet", norm="linear", norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None, title="Hyper Chi-Squared Map", titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16, grid_pointsize=1, mask_pointsize=10, position_pointsize=10, output_path=None, output_format="show", output_filename="hyper_chi_squared_map", ): """Plot the image of a hyper_galaxies galaxy image. Set *autolens.datas.array.plotters.array_plotters* for a description of all input parameters not described below. Parameters ----------- hyper_chi_squared_map : datas.imaging.datas.Imaging The hyper_galaxies galaxy image. plot_origin : True If true, the origin of the datas's coordinate system is plotted as a 'x'. """ array_plotters.plot_array( array=hyper_chi_squared_map, mask=mask, extract_array_from_mask=extract_array_from_mask, zoom_around_mask=zoom_around_mask, grid=image_plane_pix_grid, positions=positions, as_subplot=as_subplot, units=units, kpc_per_arcsec=kpc_per_arcsec, figsize=figsize, aspect=aspect, cmap=cmap, norm=norm, norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale, cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad, cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels, title=title, titlesize=titlesize, xlabelsize=xlabelsize, ylabelsize=ylabelsize, xyticksize=xyticksize, grid_pointsize=grid_pointsize, mask_pointsize=mask_pointsize, position_pointsize=position_pointsize, output_path=output_path, output_format=output_format, output_filename=output_filename, )