lenstronomy.Plots package¶
Submodules¶
lenstronomy.Plots.chain_plot module¶
-
lenstronomy.Plots.chain_plot.
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 of chains with arguments [type string, samples etc…]
- index – index of chain to be plotted
- num_average – in chains, number of steps to average over in plotting diagnostics
Returns: plotting instance
-
lenstronomy.Plots.chain_plot.
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 :param samples_mcmc: parameters sampled 2d numpy array :param param_mcmc: list of parameters :param dist_mcmc: log likelihood of the chain :param num_average: number of samples to average (should coincide with the number of samples in the emcee process) :return:
lenstronomy.Plots.lens_plot module¶
-
lenstronomy.Plots.lens_plot.
lens_model_plot
(ax, lensModel, kwargs_lens, numPix=500, deltaPix=0.01, sourcePos_x=0, sourcePos_y=0, point_source=False, with_caustics=False, with_convergence=True, coord_center_ra=0, coord_center_dec=0, coord_inverse=False, fast_caustic=False)[source]¶ plots a lens model (convergence) and the critical curves and caustics
Parameters: - ax –
- kwargs_lens –
- numPix –
- deltaPix –
- fast_caustic – boolean, if True, uses faster but less precise caustic calculation (might have troubles for the outer caustic (inner critical curve)
- with_convergence – boolean, if True, plots the convergence of the deflector
Returns:
-
lenstronomy.Plots.lens_plot.
distortions
(lensModel, kwargs_lens, num_pix=100, delta_pix=0.05, center_ra=0, center_dec=0, differential_scale=0.0001, smoothing_scale=None, **kwargs)[source]¶ Parameters: - lensModel – LensModel instance
- kwargs_lens – lens model keyword argument list
- num_pix – number of pixels per axis
- delta_pix – pixel scale per axis
- center_ra – center of the grid
- center_dec – center of the grid
- differential_scale – 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.lens_plot.
arrival_time_surface
(ax, lensModel, kwargs_lens, numPix=500, deltaPix=0.01, sourcePos_x=0, sourcePos_y=0, with_caustics=False, point_source=False, n_levels=10, kwargs_contours={}, image_color_list=None, letter_font_size=20)[source]¶ Parameters: - ax –
- lensModel –
- kwargs_lens –
- numPix –
- deltaPix –
- sourcePos_x –
- sourcePos_y –
- with_caustics –
Returns:
lenstronomy.Plots.model_band_plot module¶
-
class
lenstronomy.Plots.model_band_plot.
ModelBandPlot
(multi_band_list, kwargs_model, model, error_map, cov_param, param, kwargs_params, likelihood_mask_list=None, band_index=0, arrow_size=0.02, cmap_string='gist_heat')[source]¶ Bases:
lenstronomy.Analysis.image_reconstruction.ModelBand
class to plot a single band given the modeling results
-
absolute_residual_plot
(ax, v_min=-1, v_max=1, font_size=15, text='Residuals', colorbar_label='(f$_{model}$-f$_{data}$)')[source]¶ Parameters: - ax –
- residuals –
Returns:
-
convergence_plot
(ax, text='Convergence', v_min=None, v_max=None, font_size=15, colorbar_label='$\\log_{10}\\ \\kappa$', **kwargs)[source]¶ Parameters: - x_grid –
- y_grid –
- kwargs_lens –
- kwargs_else –
Returns:
-
data_plot
(ax, v_min=None, v_max=None, text='Observed', font_size=15, colorbar_label='log$_{10}$ flux', **kwargs)[source]¶ Parameters: ax – Returns:
-
decomposition_plot
(ax, text='Reconstructed', v_min=None, v_max=None, unconvolved=False, point_source_add=False, font_size=15, source_add=False, lens_light_add=False, **kwargs)[source]¶ Parameters: - ax –
- text –
- v_min –
- v_max –
- unconvolved –
- point_source_add –
- source_add –
- lens_light_add –
- kwargs – kwargs to send matplotlib.pyplot.matshow()
Returns:
-
deflection_plot
(ax, v_min=None, v_max=None, axis=0, with_caustics=False, image_name_list=None, text='Deflection model', font_size=15, colorbar_label='arcsec')[source]¶ Parameters: - kwargs_lens –
- kwargs_else –
Returns:
-
error_map_source_plot
(ax, numPix, deltaPix_source, v_min=None, v_max=None, with_caustics=False, font_size=15, point_source_position=True)[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 axis instance
- numPix – number of pixels in plot per axis
- deltaPix_source – pixel spacing in the source resolution illustrated in plot
- v_min – minimum plotting scale of the map
- v_max – maximum plotting scale of the map
- with_caustics – plot the caustics on top of the source reconstruction (may take some time)
- font_size – font size of labels
- point_source_position – boolean, if True, plots a point at the position of the point source
Returns: plot of source surface brightness errors in the reconstruction on the axis instance
-
magnification_plot
(ax, v_min=-10, v_max=10, image_name_list=None, font_size=15, no_arrow=False, text='Magnification model', colorbar_label='$\\det\\ (\\mathsf{A}^{-1})$', **kwargs)[source]¶ Parameters: - ax – matplotib axis instance
- v_min – minimum range of plotting
- v_max – maximum range of plotting
- kwargs – kwargs to send to matplotlib.pyplot.matshow()
Returns:
-
model_plot
(ax, v_min=None, v_max=None, image_names=False, colorbar_label='log$_{10}$ flux', font_size=15, text='Reconstructed', **kwargs)[source]¶ Parameters: - ax –
- model –
- v_min –
- v_max –
Returns:
-
normalized_residual_plot
(ax, v_min=-6, v_max=6, font_size=15, text='Normalized Residuals', colorbar_label='(f${}_{\\rm model}$ - f${}_{\\rm data}$)/$\\sigma$', no_arrow=False, **kwargs)[source]¶ Parameters: - ax –
- v_min –
- v_max –
- kwargs – kwargs to send to matplotlib.pyplot.matshow()
Returns:
-
plot_extinction_map
(ax, v_min=None, v_max=None, **kwargs)[source]¶ Parameters: - ax –
- v_min –
- v_max –
Returns:
-
source
(numPix, deltaPix, center=None, image_orientation=True)[source]¶ Parameters: - numPix – number of pixels per axes
- deltaPix – pixel size
- image_orientation – bool, if True, uses frame in orientation of the image, otherwise in RA-DEC coordinates
Returns: 2d surface brightness grid of the reconstructed source and Coordinates() instance of source grid
-
source_plot
(ax, numPix, deltaPix_source, center=None, v_min=None, v_max=None, with_caustics=False, caustic_color='yellow', font_size=15, plot_scale='log', scale_size=0.1, text='Reconstructed source', colorbar_label='log$_{10}$ flux', point_source_position=True, **kwargs)[source]¶ Parameters: - ax –
- numPix –
- deltaPix_source –
- center – [center_x, center_y], if specified, uses this as the center
- v_min –
- v_max –
- with_caustics –
- caustic_color –
- font_size –
- plot_scale – string, log or linear, scale of surface brightness plot
- kwargs –
Returns:
-
lenstronomy.Plots.model_plot module¶
-
class
lenstronomy.Plots.model_plot.
ModelPlot
(multi_band_list, kwargs_model, kwargs_params, arrow_size=0.02, cmap_string='gist_heat', likelihood_mask_list=None, bands_compute=None, multi_band_type='multi-linear', source_marg=False, linear_prior=None)[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.
-
absolute_residual_plot
(band_index=0, **kwargs)[source]¶ illustrates absolute residuals between data and model fit
Parameters: - band_index – index of band
- kwargs – arguments of plotting
Returns: plot instance
-
convergence_plot
(band_index=0, **kwargs)[source]¶ illustrates lensing convergence in data frame
Parameters: - band_index – index of band
- kwargs – arguments of plotting
Returns: plot instance
-
data_plot
(band_index=0, **kwargs)[source]¶ illustrates data
Parameters: - band_index – index of band
- kwargs – arguments of plotting
Returns: plot instance
-
decomposition_plot
(band_index=0, **kwargs)[source]¶ illustrates decomposition of model components
Parameters: - band_index – index of band
- kwargs – arguments of plotting
Returns: plot instance
-
deflection_plot
(band_index=0, **kwargs)[source]¶ illustrates lensing deflections on the field of view of the data frame
Parameters: - band_index – index of band
- kwargs – arguments of plotting
Returns: plot instance
-
error_map_source_plot
(band_index=0, **kwargs)[source]¶ illustrates surface brightness variance in the reconstruction in the source plane
Parameters: - band_index – index of band
- kwargs – arguments of plotting
Returns: plot instance
-
magnification_plot
(band_index=0, **kwargs)[source]¶ illustrates lensing magnification in the field of view of the data frame
Parameters: - band_index – index of band
- kwargs – arguments of plotting
Returns: plot instance
-
model_plot
(band_index=0, **kwargs)[source]¶ illustrates model
Parameters: - band_index – index of band
- kwargs – arguments of plotting
Returns: plot instance
-
normalized_residual_plot
(band_index=0, **kwargs)[source]¶ illustrates normalized residuals between data and model fit
Parameters: - band_index – index of band
- kwargs – arguments of plotting
Returns: plot instance
-
plot_extinction_map
(band_index=0, **kwargs)[source]¶ Parameters: - band_index – index of band
- kwargs – arguments of plotting
Returns: plot instance of differential extinction map
-
plot_main
(band_index=0, **kwargs)[source]¶ plot a set of ‘main’ modelling diagnostics
Parameters: - band_index – index of band
- kwargs – arguments of plotting
Returns: plot instance
-
plot_separate
(band_index=0)[source]¶ plot a set of ‘main’ modelling diagnostics
Parameters: band_index – 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 – index of band Returns: plot instance
-
reconstruction_all_bands
(**kwargs)[source]¶ Parameters: kwargs – arguments of plotting Returns: 3 x n_data plot with data, model, reduced residual plots of all the images/bands that are being modeled
-
source
(band_index=0, **kwargs)[source]¶ Parameters: - band_index – index of band
- kwargs – keyword arguments accessible in model_band_plot.source()
Returns: 2d array of source surface brightness
-
lenstronomy.Plots.plot_util module¶
-
lenstronomy.Plots.plot_util.
sqrt
(inputArray, scale_min=None, scale_max=None)[source]¶ Performs sqrt scaling of the input numpy array.
@type inputArray: numpy array @param inputArray: image data array @type scale_min: float @param scale_min: minimum data value @type scale_max: float @param scale_max: maximum data value @rtype: numpy array @return: image data array
-
lenstronomy.Plots.plot_util.
text_description
(ax, d, text, color='w', backgroundcolor='k', flipped=False, font_size=15)[source]¶
-
lenstronomy.Plots.plot_util.
scale_bar
(ax, d, dist=1.0, text='1"', color='w', font_size=15, flipped=False)[source]¶
-
lenstronomy.Plots.plot_util.
coordinate_arrows
(ax, d, coords, color='w', font_size=15, arrow_size=0.05)[source]¶
-
lenstronomy.Plots.plot_util.
plot_line_set_list
(ax, coords, line_set_list_x, line_set_list_y, shift=0.0, color='g')[source]¶ Parameters: - coords – Coordinates() class instance
- line_set_list_x – list of numpy arrays corresponding of different disconnected regions of the line (e.g. caustic or critical curve)
- line_set_list_y – list of numpy arrays corresponding of different disconnected regions of the line (e.g. caustic or critical curve)
Returns: plot with line sets on matplotlib axis
-
lenstronomy.Plots.plot_util.
plot_line_set
(ax, coords, line_set_list_x, line_set_list_y, shift=0.0, color='g')[source]¶ Parameters: - coords – Coordinates() class instance
- line_set_list_x – numpy arrays corresponding of different disconnected regions of the line (e.g. caustic or critical curve)
- line_set_list_y – numpy arrays corresponding of different disconnected regions of the line (e.g. caustic or critical curve)
Returns: plot with line sets on matplotlib axis
-
lenstronomy.Plots.plot_util.
image_position_plot
(ax, coords, ra_image, dec_image, color='w', image_name_list=None)[source]¶ Parameters: - ax –
- coords –
- kwargs_else –
Returns:
-
lenstronomy.Plots.plot_util.
source_position_plot
(ax, coords, ra_pos, dec_pos)[source]¶ Parameters: - ax –
- coords –
- kwargs_source –
Returns:
-
lenstronomy.Plots.plot_util.
result_string
(x, weights=None, title_fmt='.2f', label=None)[source]¶ Parameters: - x – marginalized 1-d posterior
- weights – weights of posteriors (optional)
- title_fmt – format to what digit the results are presented
- label – string of parameter label (optional)
Returns: string with mean pm quartile