lenstronomy.ImSim package¶
Subpackages¶
- lenstronomy.ImSim.MultiBand package
- Submodules
- lenstronomy.ImSim.MultiBand.joint_linear module
- lenstronomy.ImSim.MultiBand.joint_linear_vary_background module
- lenstronomy.ImSim.MultiBand.multi_data_base module
- lenstronomy.ImSim.MultiBand.multi_linear module
- lenstronomy.ImSim.MultiBand.single_band_multi_model module
SingleBandMultiModelSingleBandMultiModel.__init__()SingleBandMultiModel.image()SingleBandMultiModel.source_surface_brightness()SingleBandMultiModel.lens_surface_brightness()SingleBandMultiModel.point_source()SingleBandMultiModel.image_linear_solve()SingleBandMultiModel.likelihood_data_given_model()SingleBandMultiModel.update_linear_kwargs()SingleBandMultiModel.num_param_linear()SingleBandMultiModel.linear_response_matrix()SingleBandMultiModel.error_map_source()SingleBandMultiModel.error_response()SingleBandMultiModel.extinction_map()SingleBandMultiModel.linear_param_from_kwargs()SingleBandMultiModel.select_kwargs()
- Module contents
- lenstronomy.ImSim.Numerics package
- Submodules
- lenstronomy.ImSim.Numerics.adaptive_numerics module
- lenstronomy.ImSim.Numerics.convolution module
- lenstronomy.ImSim.Numerics.grid module
- lenstronomy.ImSim.Numerics.numba_convolution module
- lenstronomy.ImSim.Numerics.numerics module
- lenstronomy.ImSim.Numerics.numerics_subframe module
- lenstronomy.ImSim.Numerics.partial_image module
- lenstronomy.ImSim.Numerics.point_source_rendering module
- Module contents
- lenstronomy.ImSim.SourceReconstruction package
- Submodules
- lenstronomy.ImSim.SourceReconstruction.pixelated_source_reconstruction module
PixelatedSourceReconstructionPixelatedSourceReconstruction.__init__()PixelatedSourceReconstruction.generate_M_b()PixelatedSourceReconstruction.generate_M_b_diagonal_likelihood()PixelatedSourceReconstruction.generate_M_b_interferometry_natwt_likelihood()PixelatedSourceReconstruction.lens_pixel_source_of_a_rectangular_region()PixelatedSourceReconstruction.lens_an_image_by_rayshooting()PixelatedSourceReconstruction.sparse_to_array()PixelatedSourceReconstruction.sum_sparse_elementwise_product()PixelatedSourceReconstruction.sparse_convolve_and_dot_product()PixelatedSourceReconstruction.sparse_convolution()
- lenstronomy.ImSim.SourceReconstruction.regularization_matrix_pixel module
- lenstronomy.ImSim.SourceReconstruction.solve_regularization_strength module
- Module contents
Submodules¶
lenstronomy.ImSim.de_lens module¶
- get_param_WLS(A, C_D_inv, d, inv_bool=True)[source]¶
Returns the parameter values given.
- Parameters:
A – response matrix Nd x Ns (Nd = # data points, Ns = # parameters)
C_D_inv – inverse covariance matrix of the data, Nd x Nd, diagonal form
d – data array, 1-d Nd
inv_bool – boolean, whether returning also the inverse matrix or just solve the linear system
- Returns:
1-d array of parameter values
- get_param_WLS_interferometry(M, b, inv_bool=True)[source]¶
Returns the linear parameters and its covariance matrix.
- Parameters:
M – the interferometric equivalent of the M matrix in the get_param_WLS function. inverse covariance matrix of the linear parameters, Ns x Ns positive-semi-definite and symmetric (Ns = # parameters)
b – the interferometric equivalent of the R matrix in the get_param_WLS function, 1-d Ns
inv_bool – boolean, whether returning also the covariance matrix of the linear parameters or just solve the linear system
- Returns:
param_amps: 1-d array of linear parameter values, M_inv the covariance matrix of linear parameters
lenstronomy.ImSim.differential_extinction module¶
- class DifferentialExtinction(optical_depth_model=None, profile_kwargs_list=None, tau0_index=0)[source]¶
Bases:
objectClass to compute an extinction (for a specific band/wavelength).
This class uses the functionality available in the LightModel module to describe an optical depth tau_ext to compute the extinction on the sky/image.
- __init__(optical_depth_model=None, profile_kwargs_list=None, tau0_index=0)[source]¶
- Parameters:
optical_depth_model – list of strings naming the profiles (same convention as LightModel module) describing the optical depth of the extinction
profile_kwargs_list – list of dicts, keyword arguments used to initialize light model profile classes in the same order of the optical_depth_model list. If any of the profile_kwargs, are None, then that profile will be initialized using default settings.
- property compute_bool¶
- Returns:
True when a differential extinction is set, False otherwise
- extinction(x, y, kwargs_extinction=None, kwargs_special=None)[source]¶
- Parameters:
x – coordinate in image plane of flux intensity
y – coordinate in image plane of flux intensity
kwargs_extinction – keyword argument list matching the extinction profile
kwargs_special – keyword arguments hosting special parameters, here required ‘tau0_list’
- Returns:
extinction corrected flux
lenstronomy.ImSim.image2source_mapping module¶
- class Image2SourceMapping(lens_model, source_model)[source]¶
Bases:
objectThis class handles multiple source planes and performs the computation of predicted surface brightness at given image positions. The class is enable to deal with an arbitrary number of different source planes. There are two different settings:
Single lens plane modelling: In case of a single deflector, lenstronomy models the reduced deflection angles (matched to the source plane in single source plane mode). Each source light model can be added a number (scale_factor) that rescales the reduced deflection angle to the specific source plane.
Multiple lens plane modelling: The multi-plane lens modelling requires the assumption of a cosmology and the redshifts of the multiple lens and source planes. The backwards ray-tracing is performed and stopped at the different source plane redshift to compute the mapping between source to image plane.
- __init__(lens_model, source_model)[source]¶
- Parameters:
lens_model – LensModel() class instance
source_model –
LightModel() class instance. The lightModel includes:
source_scale_factor_list: list of floats corresponding to the rescaled deflection angles to the specific source components. None indicates that the list will be set to 1, meaning a single source plane model (in single lens plane mode).
source_redshift_list: list of redshifts of the light components (in multi lens plane mode)
- property T_ij_start_list¶
List of transverse distances from the observer to the start of the source plane.
- property T_ij_end_list¶
List of transverse distances from the observer to the end of the source plane.
- image2source(x, y, kwargs_lens, index_source, kwargs_special=None)[source]¶
mapping of image plane to source plane coordinates WARNING: for multi lens plane computations and multi source planes, this computation can be slow and should be used as rarely as possible.
- Parameters:
x – image plane coordinate (angle)
y – image plane coordinate (angle)
kwargs_lens – lens model kwargs list
index_source – int, index of source model
- Returns:
source plane coordinate corresponding to the source model of index index_source
- update_distances(kwargs_special)[source]¶
Updates the distances for the multi-lens-plane case if distance_ratio_sampling or cosmology_sampling is True.
- image_flux_joint(x, y, kwargs_lens, kwargs_source, kwargs_special=None, k=None)[source]¶
Computes the surface brightness of all light components at image position (x, y)
- Parameters:
x – coordinate in image plane
y – coordinate in image plane
kwargs_lens – lens model kwargs list
kwargs_source – source model kwargs list
k – None or int or list of int for partial evaluation of light models
- Returns:
surface brightness of all joint light components at image position (x, y)
- image_flux_split(x, y, kwargs_lens, kwargs_source, kwargs_special=None)[source]¶
Computes the surface brightness of all light components at image position (x, y)
- Parameters:
x – coordinate in image plane
y – coordinate in image plane
kwargs_lens – lens model kwargs list
kwargs_source – source model kwargs list
- Returns:
list of responses of every single basis component with default amplitude amp=1, in the same order as the light_model_list
lenstronomy.ImSim.image_linear_solve module¶
- class ImageLinearFit(data_class, psf_class, lens_model_class=None, source_model_class=None, lens_light_model_class=None, point_source_class=None, extinction_class=None, kwargs_numerics=None, likelihood_mask=None, psf_error_map_bool_list=None, kwargs_pixelbased=None)[source]¶
Bases:
ImageModelLinear version class, inherits ImageModel.
When light models use pixel-based profile types, such as ‘SLIT_STARLETS’, the WLS linear inversion is replaced by the regularized inversion performed by an external solver. The current pixel-based solver is provided by the SLITronomy plug-in.
- __init__(data_class, psf_class, lens_model_class=None, source_model_class=None, lens_light_model_class=None, point_source_class=None, extinction_class=None, kwargs_numerics=None, likelihood_mask=None, psf_error_map_bool_list=None, kwargs_pixelbased=None)[source]¶
- Parameters:
data_class – ImageData() instance
psf_class – PSF() instance
lens_model_class – LensModel() instance
source_model_class – LightModel() instance
lens_light_model_class – LightModel() instance
point_source_class – PointSource() instance
extinction_class – DifferentialExtinction() instance
kwargs_numerics – keyword arguments passed to the Numerics module
likelihood_mask – 2d boolean array of pixels to be counted in the likelihood calculation/linear optimization
psf_error_map_bool_list – list of boolean of length of point source models. Indicates whether PSF error map is used for the point source model stated as the index.
kwargs_pixelbased – keyword arguments with various settings related to the pixel-based solver (see SLITronomy documentation) being applied to the point sources.
- image_linear_solve(kwargs_lens=None, kwargs_source=None, kwargs_lens_light=None, kwargs_ps=None, kwargs_extinction=None, kwargs_special=None, inv_bool=False)[source]¶
Computes the image (lens and source surface brightness with a given lens model). By default, the linear parameters are computed with a weighted linear least square optimization (i.e. flux normalization of the brightness profiles) However in case of pixel-based modelling, pixel values are constrained by an external solver (e.g. SLITronomy).
- Parameters:
kwargs_lens – list of keyword arguments corresponding to the superposition of different lens profiles
kwargs_source – list of keyword arguments corresponding to the superposition of different source light profiles
kwargs_lens_light – list of keyword arguments corresponding to different lens light surface brightness profiles
kwargs_ps – keyword arguments corresponding to “other” parameters, such as external shear and point source image positions
kwargs_extinction – list of keyword arguments for extinction model
kwargs_special – list of special keyword arguments
inv_bool – if True, invert the full linear solver Matrix Ax = y for the purpose of the covariance matrix. This has no impact in case of pixel-based modelling.
- Returns:
2d array of surface brightness pixels of the optimal solution of the linear parameters to match the data. For the “interferometry_natwt” likelihood, the output model is a list [unconvolved_model, convolved_model], where the unconvolved_model is the sky model affected by the primary beam.
- image_pixelbased_solve(kwargs_lens=None, kwargs_source=None, kwargs_lens_light=None, kwargs_ps=None, kwargs_extinction=None, kwargs_special=None, init_lens_light_model=None)[source]¶
Computes the image (lens and source surface brightness with a given lens model) using the pixel-based solver.
- Parameters:
kwargs_lens – list of keyword arguments corresponding to the superposition of different lens profiles
kwargs_source – list of keyword arguments corresponding to the superposition of different source light profiles
kwargs_lens_light – list of keyword arguments corresponding to different lens light surface brightness profiles
kwargs_ps – keyword arguments corresponding to point sources
kwargs_extinction – keyword arguments corresponding to dust extinction
kwargs_special – keyword arguments corresponding to “special” parameters
init_lens_light_model – optional initial guess for the lens surface brightness
- Returns:
2d array of surface brightness pixels of the optimal solution of the linear parameters to match the data
- likelihood_data_given_model(kwargs_lens=None, kwargs_source=None, kwargs_lens_light=None, kwargs_ps=None, kwargs_extinction=None, kwargs_special=None, source_marg=False, linear_prior=None, check_positive_flux=False)[source]¶
Computes the likelihood of the data given a model This is specified with the non-linear parameters and a linear inversion and prior marginalisation.
- Parameters:
kwargs_lens – list of keyword arguments corresponding to the superposition of different lens profiles
kwargs_source – list of keyword arguments corresponding to the superposition of different source light profiles
kwargs_lens_light – list of keyword arguments corresponding to different lens light surface brightness profiles
kwargs_ps – keyword arguments corresponding to “other” parameters, such as external shear and point source image positions
kwargs_extinction – list of keyword arguments for extinction model
kwargs_special – list of special keyword arguments
source_marg – bool, performs a marginalization over the linear parameters
linear_prior – linear prior width in eigenvalues
check_positive_flux – bool, if True, checks whether the linear inversion resulted in non-negative flux components and applies a punishment in the likelihood if so.
- Returns:
log likelihood (natural logarithm), linear parameter list
- likelihood_data_given_model_solution(model, model_error, cov_matrix, param, kwargs_lens, kwargs_source, kwargs_lens_light, kwargs_ps, source_marg=False, linear_prior=None, check_positive_flux=False)[source]¶
- Parameters:
model – 2d array, image model
model_error – 2d array, uncertainties in each pixel
cov_matrix – 2d array, covariance matrix
param – linear parameter vector corresponding to the response matrix
kwargs_lens – list of dicts containing lens model keyword arguments
kwargs_source – list of dicts containing source model keyword arguments
kwargs_lens_light – list of dicts containing lens light model keyword arguments
kwargs_ps – list of dicts containing point source keyword arguments
kwargs_extinction – list of keyword arguments for extinction model
kwargs_special – list of special keyword arguments
source_marg – bool, performs a marginalization over the linear parameters
linear_prior – linear prior width in eigenvalues
check_positive_flux – bool, if True, checks whether the linear inversion resulted in non-negative flux components and applies a punishment in the likelihood if so.
- Returns:
float, likelihood data given model
- num_param_linear(kwargs_lens, kwargs_source, kwargs_lens_light, kwargs_ps)[source]¶
- Parameters:
kwargs_lens – list of dicts containing lens model keyword arguments
kwargs_source – list of dicts containing source model keyword arguments
kwargs_lens_light – list of dicts containing lens light model keyword arguments
kwargs_ps – list of dicts containing point source keyword arguments
- Returns:
number of linear coefficients to be solved for in the linear inversion
- linear_response_matrix(kwargs_lens, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_extinction=None, kwargs_special=None, unconvolved=False)[source]¶
Computes the linear response matrix (m x n), with n being the data size and m being the coefficients.
The calculation is done by - first (optional) computing differential extinctions - adding linear components of the lensed source(s) - adding linear components of the unlensed components (i.e. deflector) - adding point sources (can be multiple lensed or stars in the field)
- Parameters:
kwargs_lens – list of keyword arguments corresponding to the superposition of different lens profiles
kwargs_source – list of keyword arguments corresponding to the superposition of different source light profiles
kwargs_lens_light – list of keyword arguments corresponding to different lens light surface brightness profiles
kwargs_ps – keyword arguments corresponding to “other” parameters, such as external shear and point source image positions
kwargs_extinction – list of keyword arguments for extinction model
kwargs_special – list of special keyword arguments
unconvolved – bool, if True, computes components without convolution kernel (will not work for point sources)
- Returns:
response matrix (m x n)
- update_linear_kwargs(param, kwargs_lens, kwargs_source, kwargs_lens_light, kwargs_ps)[source]¶
Links linear parameters to kwargs arguments.
- Parameters:
param – linear parameter vector corresponding to the response matrix
kwargs_lens – list of dicts containing lens model keyword arguments
kwargs_source – list of dicts containing source model keyword arguments
kwargs_lens_light – list of dicts containing lens light model keyword arguments
kwargs_ps – list of dicts containing point source keyword arguments
- Returns:
updated list of kwargs with linear parameter values
- linear_param_from_kwargs(kwargs_source, kwargs_lens_light, kwargs_ps)[source]¶
Inverse function of update_linear() returning the linear amplitude list for the keyword argument list.
- Parameters:
kwargs_source – list of dicts containing source model keyword arguments
kwargs_lens_light – list of dicts containing lens light model keyword arguments
kwargs_ps – list of dicts containing point source keyword arguments
- Returns:
list of linear coefficients
- update_pixel_kwargs(kwargs_source, kwargs_lens_light)[source]¶
Update kwargs arguments for pixel-based profiles with fixed properties such as their number of pixels, scale, and center coordinates (fixed to the origin).
- Parameters:
kwargs_source – list of keyword arguments corresponding to the superposition of different source light profiles
kwargs_lens_light – list of keyword arguments corresponding to the superposition of different lens light profiles
- Returns:
updated kwargs_source and kwargs_lens_light
- error_map_source(kwargs_source, x_grid, y_grid, cov_param)[source]¶
Variance of the linear source reconstruction in the source plane coordinates, computed by the diagonal elements of the covariance matrix of the source reconstruction as a sum of the errors of the basis set.
- Parameters:
kwargs_source – keyword arguments of source model
x_grid – x-axis of positions to compute error map
y_grid – y-axis of positions to compute error map
cov_param – covariance matrix of liner inversion parameters
- Returns:
diagonal covariance errors at the positions (x_grid, y_grid)
- point_source_linear_response_set(kwargs_ps, kwargs_lens, kwargs_special=None, with_amp=True)[source]¶
- Parameters:
kwargs_ps – point source keyword argument list
kwargs_lens – lens model keyword argument list
kwargs_special – special keyword argument list, may include ‘delta_x_image’ and ‘delta_y_image’
with_amp – bool, if True, relative magnification between multiply imaged point sources are held fixed.
- Returns:
list of positions and amplitudes split in different basis components with applied astrometric corrections
- check_positive_flux(kwargs_source, kwargs_lens_light, kwargs_ps)[source]¶
Checks whether the surface brightness profiles contain positive fluxes and returns bool if True.
- Parameters:
kwargs_source – source surface brightness keyword argument list
kwargs_lens_light – lens surface brightness keyword argument list
kwargs_ps – point source keyword argument list
- Returns:
boolean
- linear_response_matrix_interferometry_unconvolved(kwargs_lens, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_extinction=None, kwargs_special=None)[source]¶
Computes the linear response matrix (m x n) for interferometric likelihood fitting, with n being the data size and m being the coefficients. This function is similar to linear_response_matrix but includes specific modifications for interferometry:
The linear response images are not convolved with the psf.
Unconvolved point sources are also included in the response images.
Apply the primary beam to the sky image if a primary beam is provided.
- Parameters:
kwargs_lens – list of keyword arguments corresponding to the superposition of different lens profiles
kwargs_source – list of keyword arguments corresponding to the superposition of different source light profiles
kwargs_lens_light – list of keyword arguments corresponding to different lens light surface brightness profiles
kwargs_ps – keyword arguments corresponding to “other” parameters, such as external shear and point source image positions
kwargs_extinction – list of keyword arguments for extinction model
kwargs_special – list of special keyword arguments
- Returns:
response matrix (m x n)
lenstronomy.ImSim.image_model module¶
- class ImageModel(data_class, psf_class, lens_model_class=None, source_model_class=None, lens_light_model_class=None, point_source_class=None, extinction_class=None, kwargs_numerics=None, likelihood_mask=None, psf_error_map_bool_list=None, kwargs_pixelbased=None)[source]¶
Bases:
objectThis class uses functions of lens_model and source_model to make a lensed image.
- __init__(data_class, psf_class, lens_model_class=None, source_model_class=None, lens_light_model_class=None, point_source_class=None, extinction_class=None, kwargs_numerics=None, likelihood_mask=None, psf_error_map_bool_list=None, kwargs_pixelbased=None)[source]¶
- Parameters:
data_class – instance of ImageData() or PixelGrid() class
psf_class – instance of PSF() class
lens_model_class – instance of LensModel() class
source_model_class – instance of LightModel() class describing the source parameters
lens_light_model_class – instance of LightModel() class describing the lens light parameters
point_source_class – instance of PointSource() class describing the point sources
extinction_class – instance of DifferentialExtinction() class
kwargs_numerics – keyword arguments with various numeric description (see ImageNumerics class for options)
likelihood_mask – 2d boolean array of pixels to be counted in the likelihood calculation/linear optimization
psf_error_map_bool_list – list of boolean of length of point source models. Indicates whether PSF error map is used for the point source model stated as the index.
kwargs_pixelbased – keyword arguments with various settings related to the pixel-based solver (see SLITronomy documentation)
- likelihood_data_given_model(kwargs_lens=None, kwargs_source=None, kwargs_lens_light=None, kwargs_ps=None, kwargs_extinction=None, kwargs_special=None, linear_prior=None, source_marg=False, check_positive_flux=False)[source]¶
Computes the likelihood of the data given a model This is specified with the non-linear parameters and a linear inversion and prior marginalisation.
- Parameters:
kwargs_lens – list of keyword arguments corresponding to the superposition of different lens profiles
kwargs_source – list of keyword arguments corresponding to the superposition of different source light profiles
kwargs_lens_light – list of keyword arguments corresponding to different lens light surface brightness profiles
kwargs_ps – keyword arguments corresponding to “other” parameters, such as external shear and point source image positions
kwargs_extinction – list of keyword arguments for extinction model
kwargs_special – list of special keyword arguments
source_marg – unused param; kept to match ImageLinearFit.likelihood_data_given_model API
linear_prior – unused param
check_positive_flux – unused param
- Returns:
log likelihood (natural logarithm)
- source_surface_brightness(kwargs_source, kwargs_lens=None, kwargs_extinction=None, kwargs_special=None, unconvolved=False, apply_primary_beam=True, de_lensed=False, k=None, update_pixelbased_mapping=True)[source]¶
Computes the source surface brightness distribution.
- Parameters:
kwargs_source – list of keyword arguments corresponding to the superposition of different source light profiles
kwargs_lens – list of keyword arguments corresponding to the superposition of different lens profiles
kwargs_extinction – list of keyword arguments for extinction model
kwargs_special – list of special keyword arguments
unconvolved – if True: returns the unconvolved light distribution (prefect seeing)
apply_primary_beam – if True: returns the light distribution affected by the interferometry primary beam. This only applies when the class instance has a primary beam (for interferometric images).
de_lensed – if True: returns the un-lensed source surface brightness profile, otherwise the lensed.
k – integer, if set, will only return the model of the specific index
- Returns:
2d array of surface brightness pixels
- lens_surface_brightness(kwargs_lens_light, unconvolved=False, apply_primary_beam=True, k=None)[source]¶
Computes the lens surface brightness distribution.
- Parameters:
kwargs_lens_light – list of keyword arguments corresponding to different lens light surface brightness profiles
unconvolved – if True, returns unconvolved surface brightness (perfect seeing), otherwise convolved with PSF kernel
apply_primary_beam – if True: returns the light distribution affected by the interferometry primary beam. This only applies when the class instance has a primary beam (for interferometric images).
- Returns:
2d array of surface brightness pixels
- point_source(kwargs_ps, kwargs_lens=None, kwargs_special=None, unconvolved=False, apply_primary_beam=True, k=None)[source]¶
Computes the point source positions and paints PSF convolutions on them.
- Parameters:
kwargs_ps – list of dicts containing point source keyword arguments
kwargs_lens – list of dicts containing lens model keyword arguments
kwargs_special – list of dicts containing “special” keywords
unconvolved – bool, if False, applies convolution
apply_primary_beam – if True: returns the point source light affected by the interferometry primary beam. This only applies when the class instance has a primary beam (for interferometric images).
k – int or tuple, only evaluate the k-th point source model
- Returns:
image of point source
- image(kwargs_lens=None, kwargs_source=None, kwargs_lens_light=None, kwargs_ps=None, kwargs_extinction=None, kwargs_special=None, unconvolved=False, apply_primary_beam=True, source_add=True, lens_light_add=True, point_source_add=True)[source]¶
Make an image with a realisation of linear parameter values “param”.
- Parameters:
kwargs_lens – list of keyword arguments corresponding to the superposition of different lens profiles
kwargs_source – list of keyword arguments corresponding to the superposition of different source light profiles
kwargs_lens_light – list of keyword arguments corresponding to different lens light surface brightness profiles
kwargs_ps – keyword arguments corresponding to “other” parameters, such as external shear and point source image positions
kwargs_extinction – list of keyword arguments for dust extinction
kwargs_special – list of special keyword arguments
unconvolved – if True: returns the unconvolved light distribution (prefect seeing)
apply_primary_beam – if True: returns the light distribution affected by the interferometry primary beam. This only applies when the class instance has a primary beam (for interferometric images).
source_add – if True, compute source, otherwise without
lens_light_add – if True, compute lens light, otherwise without
point_source_add – if True, add point sources, otherwise without
- Returns:
2d array of surface brightness pixels of the simulation
- extinction_map(kwargs_extinction=None, kwargs_special=None)[source]¶
Differential extinction per pixel.
- Parameters:
kwargs_extinction – list of keyword arguments corresponding to the optical depth models tau, such that extinction is exp(-tau)
kwargs_special – keyword arguments, additional parameter to the extinction
- Returns:
2d array of size of the image
- property data_response¶
Returns the 1d array of the data element that is fitted for (including masking)
- Returns:
1d numpy array
- error_response(kwargs_lens, kwargs_ps, kwargs_special)[source]¶
Returns the 1d array of the error estimate corresponding to the data response.
- Parameters:
kwargs_lens – list of dicts, keyword arguments corresponding to the lens profiles
kwargs_ps – list of dicts, keyword arguments corresponding to the point source models
kwargs_special – list of dicts, special parameter keyword arguments
- Returns:
1d numpy array of response, 2d array of additional errors (e.g. point source uncertainties)
- reset_point_source_cache(cache=True)[source]¶
Deletes all the cache in the point source class and saves it from then on.
- Parameters:
cache – boolean, if True, saves the next occuring point source positions in the cache
- Returns:
None
- update_psf(psf_class)[source]¶
Update the instance of the class with a new instance of PSF() with a potentially different point spread function.
- Parameters:
psi_class – instance of lenstronomy.Data.psf.PSF class
- Returns:
no return. Class is updated.
- update_data(data_class)[source]¶
- Parameters:
data_class – instance of Data() class
- Returns:
no return. Class is updated.
- property num_data_evaluate¶
Number of data points to be used in the likelihood calculation.
- Returns:
number of evaluated data points
- Return type:
int.
- reduced_residuals(model, error_map=0)[source]¶
- Parameters:
model – 2d numpy array of the modeled image
error_map – 2d numpy array of additional noise/error terms from model components (such as PSF model uncertainties)
- Returns:
2d numpy array of reduced residuals per pixel
- reduced_chi2(model, error_map=0)[source]¶
Returns reduced chi2.
- Parameters:
model – 2d numpy array of a model predicted image
error_map – same format as model, additional error component (such as PSF errors)
- Returns:
reduced chi2.
lenstronomy.ImSim.multiplane_organizer module¶
- class MultiPlaneOrganizer(lens_redshift_list, source_redshift_list, sorted_lens_redshift_index, sorted_source_redshift_index, z_lens_convention, z_source_convention, cosmo)[source]¶
Bases:
objectThis class organizes the lens and source planes in multi-lens plane and multi- source plane setting.
In the multi-lens-plane setting with \(P\) lens planes (and the last source plane being the \(P+1\)-th plane), the effective Fermat potential is defined as (eq. 9 of Shajib et al. 2020):
\[\phi^{\rm eff} (\theta) \equiv \sum_{i=1}^{P} \frac{1+z_i}{1+z_{\rm d}} \frac{D_i D_{i+1} D_{\rm ds}}{D_{\rm d} D_{\rm s}D_{i\ i+1} } \left[ \frac{(\theta_{i} - \theta_{ i+1})^2}{2} - \beta_{i,i+1} \psi_{i}(\theta_{i}) \right].\]Satisfying \(\Delta \phi^{\rm eff} = 0\) will lead to the lens equation in the multiplane, where $beta_{ij}$ parameters are free parameters that are defined as:
\[\beta_{ij} \equiv \frac{D_{ij} D_{\rm s}}{D_{j} D_{i\rm s}}.\]For $P$ lens planes, there are $rm{comb}(P, 2)$ number of $beta_{ij}$ parameters to track. This class converts the $beta_{ij}$ to the relevant cosmological distances needed for ray-tracing. However, instead of sampling absolute values of $beta_{ij}$, lenstronomy uses factor_beta parameters that are defined using a fiducial cosmology as follows:
factor_beta_ij = beta_ij / beta_ij_fiducial
- __init__(lens_redshift_list, source_redshift_list, sorted_lens_redshift_index, sorted_source_redshift_index, z_lens_convention, z_source_convention, cosmo)[source]¶
Initialize the MultiPlaneOrganizer class.
- Parameters:
lens_redshift_list (list) – list of lens redshifts
source_redshift_list (list) – list of source redshifts
sorted_lens_redshift_index (list) – sorted index of lens redshifts
sorted_source_redshift_index (list) – sorted index of source redshifts
z_lens_convention (float) – lens convention redshift
z_source_convention (float) – source convention redshift
cosmo (lenstronomy.Cosmo.background.Background) – instance of Background class
- update_lens_T_lists(lens_model, kwargs_special)[source]¶
Updates the lens model’s T_ij, T_ij_start, T_ij_stop, and T_z lists.
- Parameters:
lens_model (lenstronomy.LensModel.lens_model.LensModel) – instance of LensModel class
kwargs_special (dict) – dictionary of special keyword arguments
- Returns:
None
- Return type:
None
- update_source_mapping_T_lists(source_mapping_class, kwargs_special)[source]¶
Updates the source mapping class’s T_ij_start_list and T_ij_end_list.
- Parameters:
source_mapping_class (lenstronomy.LensModel.Solver.source_mapping.SourceMapping) – instance of SourceMapping class
kwargs_special (dict) – dictionary of special keyword arguments
lenstronomy.ImSim.tracer_model module¶
- class TracerModelSource(data_class, psf_class=None, lens_model_class=None, source_model_class=None, lens_light_model_class=None, point_source_class=None, extinction_class=None, tracer_source_class=None, kwargs_numerics=None, likelihood_mask=None, psf_error_map_bool_list=None, kwargs_pixelbased=None, tracer_partition=None, tracer_type='LINEAR')[source]¶
Bases:
ImageModelTracer model class, inherits ImageModel.
- __init__(data_class, psf_class=None, lens_model_class=None, source_model_class=None, lens_light_model_class=None, point_source_class=None, extinction_class=None, tracer_source_class=None, kwargs_numerics=None, likelihood_mask=None, psf_error_map_bool_list=None, kwargs_pixelbased=None, tracer_partition=None, tracer_type='LINEAR')[source]¶
- Parameters:
data_class – ImageData() instance
psf_class – PSF() instance
lens_model_class – LensModel() instance
source_model_class – LightModel() instance
lens_light_model_class – LightModel() instance
point_source_class – PointSource() instance
tracer_source_class – LightModel() instance describing the tracers of the source
kwargs_numerics – keyword arguments passed to the Numerics module
likelihood_mask – 2d boolean array of pixels to be counted in the likelihood calculation/linear optimization
psf_error_map_bool_list – list of boolean of length of point source models. Indicates whether PSF error map is used for the point source model stated as the index.
kwargs_pixelbased – keyword arguments with various settings related to the pixel-based solver (see SLITronomy documentation) being applied to the point sources.
tracer_partition (str) – in case of tracer models for specific sub-parts of the surface brightness model [[list of light profiles, list of tracer profiles], [list of light profiles, list of tracer profiles], […], …]
tracer_type – LINEAR or LOG. If the tracer is in log units, it is converted to linear units, summed, and then converted back to log units.
- tracer_model(kwargs_tracer_source, kwargs_lens, kwargs_source, kwargs_extinction=None, kwargs_special=None, de_lensed=False)[source]¶
Tracer model as a convolved surface brightness weighted quantity conv(tracer * surface brightness) / conv(surface brightness)
- Parameters:
kwargs_tracer_source
kwargs_lens
kwargs_source
- Returns:
model predicted observed tracer component
- likelihood_data_given_model(kwargs_tracer_source, kwargs_lens, kwargs_source, kwargs_extinction=None, kwargs_special=None)[source]¶
Computes the likelihood of the data given a model This is specified with the non-linear parameters and a linear inversion and prior marginalisation.
- Parameters:
kwargs_lens – list of keyword arguments corresponding to the superposition of different lens profiles
kwargs_source – list of keyword arguments corresponding to the superposition of different source light profiles
kwargs_lens_light – list of keyword arguments corresponding to different lens light surface brightness profiles
kwargs_ps – keyword arguments corresponding to “other” parameters, such as external shear and point source image positions
kwargs_extinction – list of keyword arguments for extinction model
kwargs_special – list of special keyword arguments
source_marg – unused param; kept to match ImageLinearFit.likelihood_data_given_model API
linear_prior – unused param
check_positive_flux – unused param
- Returns:
log likelihood (natural logarithm)
- property num_data_evaluate¶
Number of data points to be used in the linear solver :return: