lenstronomy.PointSource package¶
Subpackages¶
Submodules¶
lenstronomy.PointSource.point_source module¶
- class lenstronomy.PointSource.point_source.PointSource(point_source_type_list, lensModel=None, fixed_magnification_list=None, additional_images_list=None, flux_from_point_source_list=None, magnification_limit=None, save_cache=False, kwargs_lens_eqn_solver=None)[source]¶
Bases:
object
- check_image_positions(kwargs_ps, kwargs_lens, tolerance=0.001)[source]¶
checks whether the point sources in kwargs_ps satisfy the lens equation with a tolerance (computed by ray-tracing in the source plane)
- Parameters
kwargs_ps – point source keyword argument list
kwargs_lens – lens model keyword argument list
tolerance – Eucledian distance between the source positions ray-traced backwards to be tolerated
- Returns
bool: True, if requirement on tolerance is fulfilled, False if not.
- classmethod check_positive_flux(kwargs_ps)[source]¶
check whether inferred linear parameters are positive
- Parameters
kwargs_ps – point source keyword argument list
- Returns
bool, True, if all ‘point_amp’ parameters are positive semi-definite
- delete_lens_model_cache()[source]¶
deletes the variables saved for a specific lens model
- Returns
None
- image_amplitude(kwargs_ps, kwargs_lens, k=None)[source]¶
returns the image amplitudes
- Parameters
kwargs_ps – point source keyword argument list
kwargs_lens – lens model keyword argument list
k – None, int or list of int’s to select a subset of the point source models in the return
- Returns
list of image amplitudes per model component
- image_position(kwargs_ps, kwargs_lens, k=None, original_position=False)[source]¶
image positions as observed on the sky of the point sources
- Parameters
kwargs_ps – point source parameter keyword argument list
kwargs_lens – lens model keyword argument list
k – None, int or boolean list; only returns a subset of the model predictions
original_position – boolean (only applies to ‘LENSED_POSITION’ models), returns the image positions in the model parameters and does not re-compute images (which might be differently ordered) in case of the lens equation solver
- Returns
list of: list of image positions per point source model component
- linear_response_set(kwargs_ps, kwargs_lens=None, with_amp=False)[source]¶
- Parameters
kwargs_ps – point source keyword argument list
kwargs_lens – lens model keyword argument list
with_amp – bool, if True returns the image amplitude derived from kwargs_ps, otherwise the magnification of the lens model
- Returns
ra_pos, dec_pos, amp, n
- num_basis(kwargs_ps, kwargs_lens)[source]¶
number of basis functions for linear inversion
- Parameters
kwargs_ps – point source keyword argument list
kwargs_lens – lens model keyword argument list
- Returns
int
- point_source_list(kwargs_ps, kwargs_lens, k=None, with_amp=True)[source]¶
returns the coordinates and amplitudes of all point sources in a single array
- Parameters
kwargs_ps – point source keyword argument list
kwargs_lens – lens model keyword argument list
k – None, int or list of int’s to select a subset of the point source models in the return
with_amp – bool, if False, ignores the amplitude parameters in the return and instead provides ones for each point source image
- Returns
ra_array, dec_array, amp_array
- set_amplitudes(amp_list, kwargs_ps)[source]¶
translates the amplitude parameters into the convention of the keyword argument list currently only used in SimAPI to transform magnitudes to amplitudes in the lenstronomy conventions
- Parameters
amp_list – list of model amplitudes for each point source model
kwargs_ps – list of point source keywords
- Returns
overwrites kwargs_ps with new amplitudes
- set_save_cache(bool)[source]¶
set the save cache boolean to new value
- Parameters
bool – bool, if True, saves (or uses a previously saved) values
- Returns
updated class and sub-class instances to either save or not save the point source information in cache
- source_amplitude(kwargs_ps, kwargs_lens)[source]¶
intrinsic (unlensed) point source amplitudes
- Parameters
kwargs_ps – point source keyword argument list
kwargs_lens – lens model keyword argument list
- Returns
list of intrinsic (unlensed) point source amplitudes
- source_position(kwargs_ps, kwargs_lens)[source]¶
intrinsic source positions of the point sources
- Parameters
kwargs_ps – keyword argument list of point source models
kwargs_lens – keyword argument list of lens models
- Returns
list of source positions for each point source model
- update_lens_model(lens_model_class)[source]¶
- Parameters
lens_model_class – instance of LensModel class
- Returns
update instance of lens model class
- update_linear(param, i, kwargs_ps, kwargs_lens)[source]¶
- Parameters
param – list of floats corresponding ot the parameters being sampled
i – index of the first parameter relevant for this class
kwargs_ps – point source keyword argument list
kwargs_lens – lens model keyword argument list
- Returns
kwargs_ps with updated linear parameters, index of the next parameter relevant for another class
- update_search_window(search_window, x_center, y_center, min_distance=None, only_from_unspecified=False)[source]¶
update the search area for the lens equation solver
- Parameters
search_window – search_window: window size of the image position search with the lens equation solver.
x_center – center of search window
y_center – center of search window
min_distance – minimum search distance
only_from_unspecified – bool, if True, only sets keywords that previously have not been set
- Returns
updated self instances
lenstronomy.PointSource.point_source_cached module¶
- class lenstronomy.PointSource.point_source_cached.PointSourceCached(point_source_model, save_cache=False)[source]¶
Bases:
object
This class is the same as PointSource() except that it saves image and source positions in cache. This speeds-up repeated calls for the same source and lens model and avoids duplicating the lens equation solving. Attention: cache needs to be deleted before calling functions with different lens and point source parameters.
- image_amplitude(kwargs_ps, kwargs_lens=None, magnification_limit=None, kwargs_lens_eqn_solver=None)[source]¶
image brightness amplitudes
- Parameters
kwargs_ps – keyword arguments of the point source model
kwargs_lens – keyword argument list of the lens model(s), only used when requiring the lens equation solver
magnification_limit – float >0 or None, if float is set and additional images are computed, only those images will be computed that exceed the lensing magnification (absolute value) limit
kwargs_lens_eqn_solver – keyword arguments specifying the numerical settings for the lens equation solver see LensEquationSolver() class for details
- Returns
array of image amplitudes
- image_position(kwargs_ps, kwargs_lens=None, magnification_limit=None, kwargs_lens_eqn_solver=None)[source]¶
on-sky image positions
- Parameters
kwargs_ps – keyword arguments of the point source model
kwargs_lens – keyword argument list of the lens model(s), only used when requiring the lens equation solver
magnification_limit – float >0 or None, if float is set and additional images are computed, only those images will be computed that exceed the lensing magnification (absolute value) limit
kwargs_lens_eqn_solver – keyword arguments specifying the numerical settings for the lens equation solver see LensEquationSolver() class for details
- Returns
image positions in x, y as arrays
- source_amplitude(kwargs_ps, kwargs_lens=None)[source]¶
intrinsic brightness amplitude of point source
- Parameters
kwargs_ps – keyword arguments of the point source model
kwargs_lens – keyword argument list of the lens model(s), only used when positions are defined in image plane and have to be ray-traced back
- Returns
brightness amplitude (as numpy array)
lenstronomy.PointSource.point_source_param module¶
- class lenstronomy.PointSource.point_source_param.PointSourceParam(model_list, kwargs_fixed, num_point_source_list=None, linear_solver=True, fixed_magnification_list=None, kwargs_lower=None, kwargs_upper=None)[source]¶
Bases:
object
- add_fix_linear(kwargs_fixed)[source]¶
updates fixed keyword argument list with linear parameters
- Parameters
kwargs_fixed – list of keyword arguments held fixed during sampling
- Returns
updated keyword argument list