lenstronomy.Plots package

Submodules

lenstronomy.Plots.chain_plot module

plot_chain_list(chain_list, index=0, num_average=100)[source]

Plots the output of a chain of samples (MCMC or PSO) with the some diagnostics of convergence. This routine is an example and more tests might be appropriate to analyse a specific chain.

Parameters:
  • chain_list (list) – Chains with arguments [type string, samples etc…]

  • index (int) – index of chain to be plotted

  • num_average (int) – in chains, number of steps to average over in plotting diagnostics

Returns:

plotting instance figure, axes (potentially multiple)

plot_chain(chain, param_list)[source]

Plot PSO chain diagnostics.

Parameters:
  • chain (tuple) – chi2, position, and velocity history

  • param_list (list) – Parameter names

Returns:

plotting instance figure and axes

plot_mcmc_behaviour(ax, samples_mcmc, param_mcmc, dist_mcmc=None, num_average=100)[source]

Plots the MCMC behaviour and looks for convergence of the chain.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • samples_mcmc (numpy.ndarray) – sampled parameters

  • param_mcmc (list) – Parameters

  • dist_mcmc (numpy.ndarray or None) – log likelihood of the chain

  • num_average (int) – number of samples to average (should coincide with the number of samples in the emcee process)

Returns:

psf_iteration_compare(kwargs_psf, **kwargs_matshow: Unpack[plot_util.MatshowKwargs])[source]

Compare initial and iteratively reconstructed PSF kernels.

Parameters:
  • kwargs_psf (dict) – keyword arguments that initiate a PSF() class

  • kwargs_matshow – kwargs to send to matplotlib.pyplot.matshow()

Returns:

lenstronomy.Plots.lens_plot module

lens_model_plot(ax, lens_model, kwargs_lens, num_pix=500, delta_pix=0.01, source_pos_x=0, source_pos_y=0, point_source=False, with_convergence=True, coord_center_ra=0, coord_center_dec=0, coord_inverse=False, fast_caustic=True, name_list=None, index=None, kwargs_convergence=None, kwargs_caustics: CausticCriticalKwargs | None = {}, kwargs_point_source=None)[source]

Plots a lens model (convergence) and the critical curves and caustics.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • lens_model (LensModel) – LensModel() class instance

  • kwargs_lens (list or dict) – lens model keyword argument list

  • num_pix (int) – total number of pixels (for convergence map)

  • delta_pix (float) – width of pixel (total frame size is delta_pix x num_pix)

  • source_pos_x (float) – X-position of point source (image positions computed by the lens equation)

  • source_pos_y (float) – Y-position of point source (image positions computed by the lens equation)

  • point_source (bool) – If True, illustrates and computes the image positions of the point source

  • with_convergence (bool) – If True, illustrates the convergence map

  • coord_center_ra (float) – X-coordinate of the center of the frame

  • coord_center_dec (float) – Y-coordinate of the center of the frame

  • coord_inverse (bool) – If True, inverts the x-coordinates to go from right-to- left (effectively the RA definition)

  • fast_caustic (bool) – If True, uses faster but less precise caustic calculation (might have troubles for the outer caustic (inner critical curve)

  • with_convergence – If True, plots the convergence of the deflector

  • name_list (list) – Strings, longer or equal the number of point sources. If changing this parameter, input as name_list=[…]

  • index (int or None) – number of sources, an integer number. Default None.

  • color_value (str) – color for critical curves and caustics

  • kwargs_convergence (dict) – keyword arguments for convergence plot

  • kwargs_caustics (dict) – keyword arguments for caustic and critical-curve plotting, see CausticCriticalKwargs. Set to None to exclude this element from the plot. The dictionary takes "critical_curve_color" as an additional optional key to specify the color of the critical curves.

  • kwargs_point_source (dict) – keyword arguments for point source plot

Returns:

matplotlib axis instance with plot

arrival_time_surface(ax, lens_model, kwargs_lens, num_pix=500, delta_pix=0.01, source_pos_x=0, source_pos_y=0, point_source=False, n_levels=10, kwargs_caustics: CausticCriticalKwargs | None = {}, image_color_value=None, letter_font_size=20, name_list=None, **kwargs_contours: Unpack[PlotKwargs])[source]

Plot Fermat potential contours and optional images.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • lens_model (LensModel) – LensModel() class instance

  • kwargs_lens (list or dict) – lens model keyword argument list

  • num_pix (int)

  • delta_pix (float)

  • source_pos_x (float)

  • source_pos_y (float)

  • point_source (bool)

  • n_levels (int) – number of contour levels to plot for the Fermat potential

  • kwargs_caustics (dict) – keyword arguments for caustic and critical-curve plotting, see CausticCriticalKwargs. Set to None to exclude this element from the plot. The dictionary takes "critical_curve_color" as an additional optional key to specify the color of the critical curves.

  • image_color_value (str) – color for image names

  • letter_font_size (float) – font size for image names

  • name_list (list of strings, longer or equal the number of point sources) – list of names of images

Returns:

curved_arc_illustration(ax, lens_model, kwargs_lens, with_centroid=True, stretch_scale=0.1, color='k')[source]

Illustrate curved-arc lens model components.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • lens_model (LensModel) – LensModel() instance

  • kwargs_lens (list or dict) – list of lens model keyword arguments (only those of CURVED_ARC considered)

  • with_centroid (bool) – plots the center of the curvature radius

  • stretch_scale (float) – Relative scale of banana to the tangential and radial stretches (effectively intrinsic source size)

  • color (str) – Matplotlib color for plot

Returns:

matplotlib axis instance

plot_arc(ax, tangential_stretch, radial_stretch, curvature, direction, center_x, center_y, stretch_scale=0.1, with_centroid=True, linewidth=1, color='k', dtan_dtan=0)[source]

Plot a curved arc illustration for one model component.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • tangential_stretch (float direction) – Stretch of intrinsic source in tangential

  • radial_stretch (float) – Stretch of intrinsic source in radial direction

  • curvature (float) – 1/curvature radius

  • direction (float) – Angle in radian

  • center_x (float) – center of source in image plane

  • center_y (float) – center of source in image plane

  • with_centroid (bool) – plots the center of the curvature radius

  • stretch_scale (float) – Relative scale of banana to the tangential and radial stretches (effectively intrinsic source size)

  • linewidth (float) – linewidth

  • color (string in matplotlib color convention) – color

  • dtan_dtan (float) – tangential eigenvector differential in tangential direction (not implemented yet as illustration)

Returns:

distortions(lensModel, kwargs_lens, num_pix=100, delta_pix=0.05, center_ra=0, center_dec=0, differential_scale=0.0001, smoothing_scale=None)[source]

Plot lensing distortion diagnostics.

Parameters:
  • lensModel (LensModel) – LensModel instance

  • kwargs_lens (list or dict) – lens model keyword argument list

  • num_pix (int) – number of pixels per axis

  • delta_pix (float) – pixel scale per axis

  • center_ra (float) – center of the grid

  • center_dec (float) – center of the grid

  • differential_scale (float) – scale of the finite derivative length in units of angles

  • smoothing_scale (float) – Or None, Gaussian FWHM of a smoothing kernel applied before plotting

Returns:

matplotlib instance with different panels

lenstronomy.Plots.model_band_plot module

class ModelBandPlot(multi_band_list, kwargs_model, model, error_map, cov_param, param, kwargs_params, likelihood_mask_list=None, band_index=0, fast_caustic=True, linear_solver=True)[source]

Bases: ModelBand

Class to plot a single band given the modeling results.

__init__(multi_band_list, kwargs_model, model, error_map, cov_param, param, kwargs_params, likelihood_mask_list=None, band_index=0, fast_caustic=True, linear_solver=True)[source]

Initialize the model-band plotting class.

Parameters:
  • multi_band_list (list) – Imaging data configuration [[kwargs_data, kwargs_psf, kwargs_numerics], […]]

  • kwargs_model (dict) – model keyword argument list for the full multi-band modeling

  • model (numpy.ndarray) – Of modeled image for the specified band

  • error_map (numpy.ndarray) – Of size of the image, additional error in the pixels coming from PSF uncertainties

  • cov_param (numpy.ndarray) – covariance matrix of the linear inversion

  • param (numpy.ndarray or list) – 1d numpy array of the linear coefficients of this imaging band

  • kwargs_params (dict) – keyword argument of keyword argument lists of the different model components selected for the imaging band, NOT including linear amplitudes (not required as being overwritten by the param list)

  • likelihood_mask_list (list) – 2d numpy arrays of likelihood masks (for all bands)

  • band_index (int) – Of the band to be considered in this class

  • fast_caustic (bool) – ; if True, uses fast (but less accurate) caustic calculation method

  • linear_solver (bool) – If True (default) fixes the linear amplitude parameters ‘amp’ (avoid sampling) such that they get overwritten by the linear solver solution.

property font_size

Default font size for all texts in the subplots.

Font size in individual subplots can be adjusted by font_size argument in the plotting methods. Font size for different text elements can be further fine- tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

data_plot(ax, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot observed imaging data.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib axis instance

model_plot(ax, image_names=False, original_position=True, image_name_list=None, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot reconstructed imaging model.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • image_names (bool) – If True, prints image names

  • label (str) – Label for the colorbar

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • original_position (bool) – If True, uses original image positions

  • image_name_list (list) – Names for images

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib axis instance

convergence_plot(ax, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot lensing convergence in the data frame.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • label (str) – Label for the colorbar

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

convergence plot in ax instance

substructure_plot(ax, index_macromodel, subtract_mean=True, font_size=None, with_critical_curves=False, critical_curve_color='k', image_name_list=None, super_sample_factor=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plots the convergence of a full lens model minus the convergence from a few specified lens models to more clearly show the presence of substructure.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • index_macromodel (list) – a list of indices corresponding to the lens models with convergence to be subtracted

  • subtract_mean (bool) – ; displays the substructure convergence relative to the mean convergence in the frame

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • label (str) – label for the color bar

  • with_critical_curves (bool) – ; plots the critical curves in the frame

  • critical_curve_color (str) – color of the critical curves

  • image_name_list (list) – labels the images, default is A, B, C, …

  • super_sample_factor (int) – a integer the specifies supersampling of the coordinate grid to create the convergence map

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotib axis and colorbar

normalized_residual_plot(ax, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot normalized residuals between data and model.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • label (str) – label for the color bar

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib axis instance

absolute_residual_plot(ax, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot absolute residuals between data and model.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • label (str) – label for the color bar

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib axis instance

source(num_pix, delta_pix, center=None, image_orientation=True)[source]

Compute source surface brightness on a source grid.

Parameters:
  • num_pix (int) – number of pixels per axes

  • delta_pix (float) – pixel size

  • image_orientation (bool otherwise in RA-DEC coordinates) – If True, uses frame in orientation of the image,

Returns:

2d surface brightness grid of the reconstructed source and Coordinates() instance of source grid

source_plot(ax, num_pix, delta_pix_source, center=None, font_size=None, plot_scale='log', point_source_position=True, kwargs_caustics: CausticKwargs | None = {}, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot reconstructed source brightness.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • num_pix (int) – number of pixels in plot per axis

  • delta_pix_source (float) – pixel spacing in the source resolution illustrated in plot

  • center (list or None) – [center_x, center_y], if specified, uses this as the center

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • plot_scale (str) – Log or linear, scale of surface brightness plot

  • label (str) – Label for the colorbar

  • point_source_position (bool) – If True, plots a point at the position of the point source

  • kwargs_caustics (dict) – keyword arguments for caustic plotting, see CausticKwargs. Set to None to exclude this element from the plot.

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib axis instance

error_map_source_plot(ax, num_pix, delta_pix_source, font_size=None, point_source_position=True, kwargs_caustics: CausticKwargs | None = {}, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plots the uncertainty in the surface brightness in the source from the linear inversion by taking the diagonal elements of the covariance matrix of the inversion of the basis set to be propagated to the source plane. #TODO illustration of the uncertainties in real space with the full covariance matrix is subtle. # The best way is probably to draw realizations from the covariance matrix.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • num_pix (int) – number of pixels in plot per axis

  • delta_pix_source (float) – pixel spacing in the source resolution illustrated in plot

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • point_source_position (bool) – If True, plots a point at the position of the point source

  • kwargs_caustics (dict) – keyword arguments for caustic plotting. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

plot of source surface brightness errors in the reconstruction on the axis instance

magnification_plot(ax, image_name_list=None, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot magnification map in the data frame.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • image_name_list (list) – Strings for names of the images in the same order as the positions

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • label (str) – Label for the colorbar

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib axis instance

deflection_plot(ax, axis=0, image_name_list=None, font_size=None, kwargs_caustics: CausticCriticalKwargs | None = {}, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot deflection-angle map in the data frame.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • axis (int) – 0 or 1, specifies the deflection angle axis to be plotted

  • image_name_list (list) – Strings for names of the images

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • label (str) – Label for the colorbar

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_caustics (dict) – keyword arguments for caustic and critical-curve plotting, see CausticCriticalKwargs. Set to None to exclude this element from the plot. The dictionary takes "critical_curve_color" as an additional optional key to specify the color of the critical curves.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib axis instance

decomposition_plot(ax, unconvolved=False, point_source_add=False, font_size=None, source_add=False, lens_light_add=False, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Make a plot displaying all or a subset of light components.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • unconvolved (bool) – If True, does not perform PSF convolution on the image

  • point_source_add (bool) – If True, includes the lensed point source(s) in the plot

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • source_add (bool) – If True, includes the lensed image of the source in the plot

  • lens_light_add (bool) – If True, includes the lens light in the plot from the plot

  • label (str) – Label for the colorbar

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

the instance of matplotlib.axes.Axes

subtract_from_data_plot(ax, subtract_point_source=False, subtract_source=False, subtract_lens_light=False, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot data after subtracting selected model components.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • subtract_point_source (bool) – If True, subtracts the lensed point source(s) from the data in the plot

  • subtract_source (bool) – If True, subtracts the lensed image of the source from the data in the plot

  • subtract_lens_light (bool) – If True, subtracts the lens light from the data in the plot

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • kwargs_colorbar (dict) – keyword arguments for the colorbar, see ColorBarKwargs

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

the instance of matplotlib.axes.Axes

plot_main(kwargs_caustics=None)[source]

Print the main plots together in a joint frame.

Returns:

plot_separate()[source]

Plot the different model components separately.

Returns:

plot_subtract_from_data_all()[source]

Subtract model components from data.

Returns:

plot_extinction_map(ax, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot differential extinction map.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib axis instance

lenstronomy.Plots.model_plot module

class ModelPlot(multi_band_list, kwargs_model, kwargs_params, image_likelihood_mask_list=None, bands_compute=None, multi_band_type='multi-linear', source_marg=False, linear_prior=None, fast_caustic=True, linear_solver=True)[source]

Bases: object

Class that manages the summary plots of a lens model The class uses the same conventions as being used in the FittingSequence and interfaces with the ImSim module.

The linear inversion is re-done given the likelihood settings in the init of this class (make sure this is the same as you perform the FittingSequence) to make sure the linear amplitude parameters are computed as they are not part of the output of the FittingSequence results.

__init__(multi_band_list, kwargs_model, kwargs_params, image_likelihood_mask_list=None, bands_compute=None, multi_band_type='multi-linear', source_marg=False, linear_prior=None, fast_caustic=True, linear_solver=True)[source]

Initialize the multi-band plotting manager.

Parameters:
  • multi_band_list (list) – [[kwargs_data, kwargs_psf, kwargs_numerics], [], ..]

  • multi_band_type (str) – Option when having multiple imaging data sets modelled simultaneously. Options are: - ‘multi-linear’: linear amplitudes are inferred on single data set - ‘linear-joint’: linear amplitudes ae jointly inferred - ‘single-band’: single band

  • kwargs_model (dict) – model keyword arguments

  • bands_compute (list) – (optional), bool list to indicate which band to be included in the modeling

  • image_likelihood_mask_list (lis) – Image likelihood mask (same size as image_data with 1 indicating being evaluated and 0 being left out)

  • kwargs_params (dict) – keyword arguments of ‘kwargs_lens’, ‘kwargs_source’ etc. as coming as kwargs_result from FittingSequence

  • source_marg (bool)

  • linear_prior (object)

  • fast_caustic (bool) – ; if True, uses fast (but less accurate) caustic calculation method

  • linear_solver (bool) – If True (default) fixes the linear amplitude parameters ‘amp’ (avoid sampling) such that they get overwritten by the linear solver solution.

property font_size

Default font size for all texts in the subplots.

Font size in individual subplots can be adjusted by font_size argument in the plotting methods. Font size for different text elements can be further fine- tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

reconstruction_all_bands(**kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot data, model, and normalized residuals for all computed bands.

Parameters:

kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

3 x n_data plot with data, model, reduced residual plots of all the images/bands that are being modeled

data_plot(band_index=0, ax=None, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Illustrates data.

Parameters:
  • band_index (int) – index of band

  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • kwargs_colorbar (dict) – keyword arguments for the colorbar, see ColorBarKwargs

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

plot instance

model_plot(band_index=0, ax=None, image_names=False, original_position=True, image_name_list=None, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Illustrates model.

Parameters:
  • band_index (int) – index of band

  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • image_names (bool) – If True, prints image names

  • label (str) – Label for the colorbar

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • original_position (bool) – If True, uses original image positions

  • image_name_list (list) – Names for images

  • kwargs_colorbar (dict) – keyword arguments for the colorbar, see ColorBarKwargs

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

plot instance

convergence_plot(band_index=0, ax=None, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Illustrates lensing convergence in data frame.

Parameters:
  • band_index (int) – index of band

  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • label (str) – Label for the colorbar

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

plot instance

substructure_plot(band_index=0, ax=None, index_macromodel=None, subtract_mean=True, font_size=None, with_critical_curves=False, critical_curve_color='k', image_name_list=None, super_sample_factor=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Illustrates substructure in the lens system.

Parameters:
  • band_index (int) – index of band

  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • index_macromodel (list) – a list of indices corresponding to the lens models with convergence to be subtracted

  • subtract_mean (bool) – ; displays the substructure convergence relative to the mean convergence in the frame

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • label (str) – label for the color bar

  • with_critical_curves (bool) – ; plots the critical curves in the frame

  • critical_curve_color (str) – color of the critical curves

  • image_name_list (list) – labels the images, default is A, B, C, …

  • super_sample_factor (int) – a integer the specifies supersampling of the coordinate grid to create the convergence map

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

plot instance

normalized_residual_plot(band_index=0, ax=None, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Illustrates normalized residuals between data and model fit.

Parameters:
  • band_index (int) – index of band

  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • label (str) – label for the color bar

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

plot instance

absolute_residual_plot(band_index=0, ax=None, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Illustrates absolute residuals between data and model fit.

Parameters:
  • band_index (int) – index of band

  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • label (str) – label for the color bar

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

plot instance

source_plot(band_index=0, ax=None, num_pix=100, delta_pix_source=0.01, center=None, font_size=None, plot_scale='log', point_source_position=True, kwargs_caustics: CausticKwargs | None = {}, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Illustrates reconstructed source (de-lensed de-convolved)

Parameters:
  • band_index (int) – index of band

  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • num_pix (int) – number of pixels in plot per axis

  • delta_pix_source (float) – pixel spacing in the source resolution illustrated in plot

  • center (list or None) – [center_x, center_y], if specified, uses this as the center

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • plot_scale (str) – Log or linear, scale of surface brightness plot

  • label (str) – Label for the colorbar

  • point_source_position (bool) – If True, plots a point at the position of the point source

  • kwargs_caustics (dict) – keyword arguments for caustic plotting, see CausticKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

plot instance

error_map_source_plot(band_index=0, ax=None, num_pix=100, delta_pix_source=0.01, font_size=None, point_source_position=True, kwargs_caustics: CausticKwargs | None = {}, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Illustrates surface brightness variance in the reconstruction in the source plane.

Parameters:
  • band_index (int) – index of band

  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • num_pix (int) – number of pixels in plot per axis

  • delta_pix_source (float) – pixel spacing in the source resolution illustrated in plot

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • point_source_position (bool) – If True, plots a point at the position of the point source

  • kwargs_caustics (dict) – keyword arguments for caustic plotting, see CausticKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

plot instance

magnification_plot(band_index=0, ax=None, image_name_list=None, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Illustrates lensing magnification in the field of view of the data frame.

Parameters:
  • band_index (int) – index of band

  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • image_name_list (list) – Strings for names of the images in the same order as the positions

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • label (str) – Label for the colorbar

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

plot instance

deflection_plot(band_index=0, ax=None, axis=0, image_name_list=None, font_size=None, kwargs_caustics: CausticCriticalKwargs | None = {}, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Illustrates lensing deflections on the field of view of the data frame.

Parameters:
  • band_index (int) – index of band

  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • axis (int) – 0 or 1, specifies the deflection angle axis to be plotted

  • image_name_list (list) – Strings for names of the images

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • label (str) – Label for the colorbar

  • kwargs_caustics (dict) – keyword arguments for caustic and critical-curve plotting, see CausticCriticalKwargs. Set to None to exclude this element from the plot. The dictionary additionally takes "critical_curve_color" as an additional optional key to specify the color of the critical curves.

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

plot instance

decomposition_plot(band_index=0, ax=None, unconvolved=False, point_source_add=False, source_add=False, lens_light_add=False, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Illustrates decomposition of model components.

Parameters:
  • band_index (int) – index of band

  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • unconvolved (bool) – If True, does not perform PSF convolution on the image

  • point_source_add (bool) – If True, includes the lensed point source(s) in the plot

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • source_add (bool) – If True, includes the lensed image of the source in the plot

  • lens_light_add (bool) – If True, includes the lens light in the plot from the plot

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

plot instance

subtract_from_data_plot(band_index=0, ax=None, subtract_point_source=False, subtract_source=False, subtract_lens_light=False, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Subtracts individual model components from the data.

Parameters:
  • band_index (int) – index of band

  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • subtract_point_source (bool) – If True, subtracts the lensed point source(s) from the data in the plot

  • subtract_source (bool) – If True, subtracts the lensed image of the source from the data in the plot

  • subtract_lens_light (bool) – If True, subtracts the lens light from the data in the plot

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

plot instance

plot_main(band_index=0, kwargs_data_plot=None, kwargs_model_plot=None, kwargs_residual_plot=None, kwargs_source_plot=None, kwargs_convergence_plot=None, kwargs_magnification_plot=None, kwargs_caustics: CausticKwargs | None = None)[source]

Plot a set of ‘main’ modelling diagnostics.

Parameters:
  • band_index (int) – index of band

  • kwargs_data_plot (dict or None) – keyword arguments passed to data_plot()

  • kwargs_model_plot (dict or None) – keyword arguments passed to model_plot()

  • kwargs_residual_plot (dict or None) – keyword arguments passed to normalized_residual_plot()

  • kwargs_source_plot (dict or None) – keyword arguments passed to source_plot()

  • kwargs_convergence_plot (dict or None) – keyword arguments passed to convergence_plot()

  • kwargs_magnification_plot (dict or None) – keyword arguments passed to magnification_plot()

  • kwargs_caustics (dict) – keyword arguments for caustic plotting, see CausticKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

Returns:

plot instance

plot_separate(band_index=0)[source]

Plot a set of ‘main’ modelling diagnostics.

Parameters:

band_index (int) – index of band

Returns:

plot instance

plot_subtract_from_data_all(band_index=0)[source]

Plot a set of ‘main’ modelling diagnostics.

Parameters:

band_index (int) – index of band

Returns:

plot instance

plot_extinction_map(band_index=0, ax=None, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot differential extinction map for one band.

Parameters:
  • band_index (int) – index of band

  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

plot instance of differential extinction map

source(band_index=0, num_pix=None, delta_pix=None, center=None, image_orientation=True)[source]

Compute source surface brightness for one band.

Parameters:
  • band_index (int) – index of band

  • num_pix (int) – number of pixels per axes

  • delta_pix (float) – pixel size

  • center (list or None) – center position of source

  • image_orientation (bool) – If True, uses frame in orientation of the image, otherwise in RA-DEC coordinates

Returns:

2d array of source surface brightness

single_band_chi2(band_index=0)[source]

Return reduced chi-square for one band.

Parameters:

band_index (int) – index of band

Returns:

the reduced chi-square value of the band as a float

lenstronomy.Plots.multi_patch_plot module

class MultiPatchPlot(multi_band_list, kwargs_model, kwargs_params, multi_band_type='joint-linear', kwargs_likelihood=None, kwargs_pixel_grid=None, verbose=True)[source]

Bases: MultiPatchReconstruction

This class illustrates the model of disconnected multi-patch modeling with ‘joint-linear’ option in one single array.

__init__(multi_band_list, kwargs_model, kwargs_params, multi_band_type='joint-linear', kwargs_likelihood=None, kwargs_pixel_grid=None, verbose=True)[source]

Initialize the multi-patch plotting class.

Parameters:
  • multi_band_list (list) – Imaging data configuration [[kwargs_data, kwargs_psf, kwargs_numerics], […]]

  • kwargs_model (dict) – model keyword argument list

  • kwargs_params (dict) – keyword arguments of the model parameters, same as output of FittingSequence() ‘kwargs_result’

  • multi_band_type (str) – Option when having multiple imaging data sets modelled simultaneously. Options are: - ‘multi-linear’: linear amplitudes are inferred on single data set - ‘linear-joint’: linear amplitudes ae jointly inferred - ‘single-band’: single band

  • kwargs_likelihood (dict or None) – likelihood keyword arguments as supported by the Likelihood() class

  • kwargs_pixel_grid (dict or None) – keyword argument of PixelGrid() class. This is optional and overwrites a minimal grid. Attention for consistent pixel grid definitions!

  • verbose (bool) – if True (default), computes and prints the total log-likelihood. This can deactivated for speedup purposes (does not run linear inversion again), and reduces the number of prints.

data_plot(ax, log_scale=True, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Illustrates data.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • log_scale (bool) – If True, plots the map in log_10 scale

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows.

  • kwargs_colorbar (dict) – keyword arguments for the colorbar, see ColorBarKwargs

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib instance

model_plot(ax, log_scale=True, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Illustrates model.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • log_scale (bool) – If True, plots the map in log_10 scale

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows.

  • kwargs_colorbar (dict) – keyword arguments for the colorbar, see ColorBarKwargs

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib instance

source_plot(ax, delta_pix, num_pix, center=None, log_scale=True, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Illustrates source.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • delta_pix (float) – scale of the pixel size of the source plot

  • num_pix (int) – number of pixels per axis of the source plot

  • center (list) – With two entries [center_x, center_y] (optional)

  • log_scale (bool) – If True, plots the map in log_10 scale

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows.

  • kwargs_colorbar (dict) – keyword arguments for the colorbar, see ColorBarKwargs

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib instance

normalized_residual_plot(ax, v_min=-6, v_max=6, log_scale=False, white_on_black=False, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Illustrates normalized residuals of (data - model) / error.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • v_min (float) – minimum plotting scale

  • v_max (float) – maximum plotting scale

  • log_scale (bool) – If True, plots the map in log_10 scale

  • white_on_black (bool) – If True, prints white text on black background, otherwise the opposite

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows.

  • kwargs_colorbar (dict) – keyword arguments for the colorbar, see ColorBarKwargs

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib instance

convergence_plot(ax, log_scale=True, v_min=-2, v_max=0.2, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Illustrates lensing convergence.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • log_scale (bool) – If True, plots the map in log_10 scale

  • v_min (float) – minimum plotting scale

  • v_max (float) – maximum plotting scale

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows.

  • kwargs_colorbar (dict) – keyword arguments for the colorbar, see ColorBarKwargs

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib instance

magnification_plot(ax, log_scale=False, v_min=-10, v_max=10, white_on_black=False, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Illustrates lensing magnification.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • log_scale (bool) – If True, plots the map in log_10 scale

  • v_min (float) – minimum plotting scale

  • v_max (float) – maximum plotting scale

  • white_on_black (bool) – If True, prints white text on black background, otherwise the opposite

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows.

  • kwargs_colorbar (dict) – keyword arguments for the colorbar, see ColorBarKwargs

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib instance

plot_main(**kwargs_plot)[source]

Print the main plots together in a joint frame.

Parameters:

kwargs_plot (dict) – keyword arguments passed to matplotlib.pyplot.plot()

Returns:

figure and axes instances

lenstronomy.Plots.plot_quasar_images module

plot_quasar_images(lens_model, x_image, y_image, kwargs_lens, source_light_model, kwargs_light_source, grid_resolution, grid_radius_arcsec)[source]

This function plots the surface brightness in the image plane of a background source. The flux is computed inside a circular aperture with radius grid_radius_arcsec. This new updates allows for more flexibility in the source light model by requiring the user to specify the source light mode, grid size and grid resolution before calling the function. The functions auto_raytrracing_grid_size and auto_raytracing_grid_resolution give good estimates for appropriate parameter choices for grid_radius_arcsec and grid_resolution.

Parameters:
  • lens_model (LensModel) – an instance of LensModel

  • x_image (list or numpy.ndarray) – a list or array of x coordinates [units arcsec]

  • y_image (list or numpy.ndarray) – a list or array of y coordinates [units arcsec]

  • kwargs_lens (list) – keyword arguments for the lens model

  • source_light_model (LightModel) – instance of LightModel for the source

  • kwargs_light_source (list) – the keyword arguments for the source light

  • grid_resolution (float) – the grid resolution in units arcsec/pixel

  • grid_radius_arcsec (float) – the size of the ray tracing region in arcsec

lenstronomy.Plots.plot_util module

sqrt(inputArray, scale_min=None, scale_max=None)[source]

Performs sqrt scaling of the input numpy array.

Parameters:
  • inputArray (numpy array) – image data array

  • scale_min (float) – minimum data value

  • scale_max (float) – maximum data value

Return type:

numpy array

Returns:

image data array

show_title_text(ax, **kwargs_title: Unpack[TitleKwargs])[source]

Add title text to an axis in normalized coordinates.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

Returns:

None, updates the axis in place

show_scale_bar(ax, d, **kwargs_scale_bar: Unpack[ScaleBarKwargs])[source]

Plot a scale bar.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • d (float) – diameter of frame

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

Returns:

None, updated ax instance

show_colorbar(cb, font_size=15, **kwargs_colorbar: Unpack[ColorBarKwargs])[source]

Apply a label and tick styling to a matplotlib colorbar.

Parameters:
  • cb (matplotlib.colorbar.Colorbar) – matplotlib colorbar instance

  • font_size (int) – default font size used when bundle entries are omitted

  • kwargs_colorbar (dict) – keyword arguments for the colorbar, see ColorBarKwargs

Returns:

None, updates the colorbar in place

show_coordinate_arrows(ax, d, coords, font_size=15, **kwargs_coordinate_arrows: Unpack[CoordArrowKwargs])[source]

Plot East and North coordinate arrows.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • d (float) – diameter of frame in ax

  • coords (Coordinates) – lenstronomy.Data.coord_transforms Coordinates() instance

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

Returns:

updated ax instance

plot_line_set(ax, coords, line_set_list_x, line_set_list_y, origin=None, flipped_x=False, points_only=False, label=None, *args, **kwargs_plot: Unpack[PlotKwargs])[source]

Plotting a line set on a matplotlib instance where the coordinates are defined in pixel units with the lower left corner (defined as origin) is by default (0, 0). The coordinates are moved by 0.5 pixels to be placed in the center of the pixel in accordance with the matplotlib.matshow() routine.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • coords (Coordinates) – Coordinates() class instance

  • origin (list or None) – [x0, y0], lower left pixel coordinate in the frame of the pixels

  • line_set_list_x (numpy.ndarray of the line (e.g. caustic or critical curve)) – S corresponding of different disconnected regions

  • line_set_list_y (numpy.ndarray of the line (e.g. caustic or critical curve)) – S corresponding of different disconnected regions

  • color (str) – With matplotlib color

  • flipped_x (bool) – If True, flips x-axis

  • points_only (bool without connecting lines) – If True, sets plotting keywords to plot single points

  • kwargs_plot (dict) – keyword arguments for the plot, see PlotKwargs

Returns:

plot with line sets on matplotlib axis in pixel coordinates

image_position_plot(ax, coords, ra_image, dec_image, color='w', image_name_list=None, origin=None, flipped_x=False, plot_out_of_image=True)[source]

Plot lensed image positions.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • coords (Coordinates) – Coordinates() class instance or inherited class (such as PixelGrid(), or Data())

  • ra_image (list or numpy.ndarray) – Ra/x-coordinates of image positions (list of arrays in angular units)

  • dec_image (list or numpy.ndarray) – Dec/y-coordinates of image positions (list of arrays in angular units)

  • color (str) – color of ticks and text

  • image_name_list (list the positions) – Strings for names of the images in the same order as

  • origin (list or None) – [x0, y0], lower left pixel coordinate in the frame of the pixels

  • flipped_x (bool) – If True, flips x-axis

  • plot_out_of_image (bool) – if True, plots images even appearing out of the Coordinate frame

Returns:

matplotlib axis instance with images plotted on

source_position_plot(ax, coords, ra_source, dec_source, marker='*', markersize=10, **kwargs_plot: Unpack[PlotKwargs])[source]

Plot source positions.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • coords (Coordinates) – Coordinates() class instance or inherited class (such as PixelGrid(), or Data())

  • ra_source (list) – Source position in angular units

  • dec_source (list) – Source position in angular units

  • marker (str) – marker style for matplotlib

  • markersize (float) – marker size for matplotlib

  • kwargs_plot (dict) – keyword arguments for the plot, see PlotKwargs

Returns:

matplotlib axis instance with images plotted on

result_string(x, weights=None, title_fmt='.2f', label=None)[source]

Format posterior summary string.

Parameters:
  • x (numpy.ndarray) – marginalized 1-d posterior

  • weights (numpy.ndarray or None) – weights of posteriors (optional)

  • title_fmt (str) – format to what digit the results are presented

  • label (str) – Of parameter label (optional)

Returns:

string with mean \(\pm\) quartile

cmap_conf(cmap_string)[source]

Configures matplotlib color map.

Parameters:

cmap_string (str) – Of cmap name, or cmap instance

Returns:

cmap instance with setting for bad pixels and values below the threshold

lenstronomy.Plots.tracer_plot module

class TracerPlot(kwargs_data_joint, kwargs_model, kwargs_params, kwargs_likelihood, fast_caustic=True)[source]

Bases: object

Class to plot a single band given the modeling results.

__init__(kwargs_data_joint, kwargs_model, kwargs_params, kwargs_likelihood, fast_caustic=True)[source]

Initialize the tracer plotting class.

Parameters:
  • kwargs_data_joint (dict) – joint data keyword argument list

  • kwargs_model (dict) – model keyword argument list for the full multi-band modeling

  • kwargs_params (dict) – keyword argument of keyword argument lists of the different model components selected for the imaging band, NOT including linear amplitudes (not required as being overwritten by the param list)

  • kwargs_likelihood (dict or None) – likelihood keyword arguments

  • fast_caustic (bool) – ; if True, uses fast (but less accurate) caustic calculation method

property font_size

Default font size for all texts in the subplots.

Font size in individual subplots can be adjusted by font_size argument in the plotting methods. Font size for different text elements can be further fine- tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

data_plot(ax, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot observed tracer data.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib axis instance

model_plot(ax, image_names=False, original_position=True, image_name_list=None, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot reconstructed tracer model.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • image_names (bool) – If True, prints image names

  • label (str) – Label for the colorbar

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • original_position (bool) – If True, uses original image positions

  • image_name_list (list) – Names for images

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib axis instance

convergence_plot(ax, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot lensing convergence in the tracer frame.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • label (str) – Label for the colorbar

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

convergence plot in ax instance

normalized_residual_plot(ax, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot normalized residuals between data and model.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • label (str) – label for the color bar

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib axis instance

absolute_residual_plot(ax, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot absolute residuals between data and model.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • label (str) – label for the color bar

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib axis instance

source(num_pix, delta_pix, center=None, image_orientation=True)[source]

Compute tracer source surface brightness on a source grid.

Parameters:
  • num_pix (int) – number of pixels per axes

  • delta_pix (float) – pixel size

  • image_orientation (bool otherwise in RA-DEC coordinates) – If True, uses frame in orientation of the image,

Returns:

2d surface brightness grid of the reconstructed source and Coordinates() instance of source grid

source_plot(ax, num_pix, delta_pix_source, center=None, font_size=None, plot_scale='log', point_source_position=True, kwargs_caustics: CausticKwargs | None = {}, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot reconstructed tracer source brightness.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • num_pix (int) – number of pixels in plot per axis

  • delta_pix_source (float) – pixel spacing in the source resolution illustrated in plot

  • center (list or None) – [center_x, center_y], if specified, uses this as the center

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • plot_scale (str) – Log or linear, scale of surface brightness plot

  • label (str) – Label for the colorbar

  • point_source_position (bool) – If True, plots a point at the position of the point source

  • kwargs_caustics (dict) – keyword arguments for caustic plotting, see CausticKwargs. Set to None to exclude this element from the plot. Set to None to exclude this element from the plot.

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib axis instance

magnification_plot(ax, image_name_list=None, font_size=None, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot magnification map in the tracer frame.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • image_name_list (list) – Strings for names of the images in the same order as the positions

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • label (str) – Label for the colorbar

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib axis instance

deflection_plot(ax, axis=0, image_name_list=None, font_size=None, kwargs_caustics: CausticCriticalKwargs | None = {}, kwargs_colorbar: ColorBarKwargs | None = {}, kwargs_title: TitleKwargs | None = {}, kwargs_scale_bar: ScaleBarKwargs | None = {}, kwargs_coordinate_arrows: CoordArrowKwargs | None = {}, **kwargs_matshow: Unpack[MatshowKwargs])[source]

Plot deflection-angle map in the tracer frame.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes instance

  • axis (int) – 0 or 1, specifies the deflection angle axis to be plotted

  • image_name_list (list) – Strings for names of the images

  • font_size (int) – Font size to override the class-level default. Font size for different text elements can be further fine-tuned by kwargs_colorbar, kwargs_title, kwargs_scale_bar, and kwargs_coordinate_arrows arguments in the plotting methods.

  • label (str) – Label for the colorbar

  • kwargs_title (dict) – keyword arguments for the title, see TitleKwargs. Set to None to exclude this element from the plot.

  • kwargs_scale_bar (dict) – keyword arguments for the scale bar, see ScaleBarKwargs. Set to None to exclude this element from the plot.

  • kwargs_coordinate_arrows (dict) – keyword arguments for coordinate arrows, see CoordArrowKwargs. Set to None to exclude this element from the plot.

  • kwargs_matshow (dict) – keyword arguments passed to matplotlib.pyplot.matshow()

Returns:

matplotlib axis instance

plot_main(kwargs_caustics: CausticKwargs | None = None)[source]

Print the main plots together in a joint frame.

Kwargs_caustics:

keyword arguments for caustic plotting, see CausticKwargs. Set to None to exclude this element from the plot.

Returns:

Module contents