jaxtronomy.PointSource package

Subpackages

Submodules

jaxtronomy.PointSource.point_source module

class PointSource(point_source_type_list, lens_model=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, index_lens_model_list=None, point_source_frame_list=None, redshift_list=None)[source]

Bases: object

__init__(point_source_type_list, lens_model=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, index_lens_model_list=None, point_source_frame_list=None, redshift_list=None)[source]
Parameters:
  • point_source_type_list – list of point source types

  • lens_model – instance of the LensModel() class

  • fixed_magnification_list – list of booleans (same length as point_source_type_list). If True, magnification ratio of point sources is fixed to the one given by the lens model. This option then requires to provide a ‘source_amp’ amplitude of the source brightness instead of ‘point_amp’ the list of image brightnesses.

  • additional_images_list – list of booleans (same length as point_source_type_list). If True, search for additional images of the same source is conducted.

  • flux_from_point_source_list – list of booleans (optional), if set, will only return image positions (for imaging modeling) for the subset of the point source lists that =True. This option enables to model imaging data with transient point sources, when the point source positions are measured and present at a different time than the imaging data, or when the image position is not known (such as for lensed GW)

  • 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

  • save_cache – bool, saves image positions and only if delete_cache is executed, a new solution of the lens equation is conducted with the lens model parameters provided. This can increase the speed as multiple times the image positions are requested for the same lens model. Attention in usage!

  • kwargs_lens_eqn_solver – keyword arguments specifying the numerical settings for the lens equation solver see LensEquationSolver() class for details, such as: min_distance=0.01, search_window=5, precision_limit=10**(-10), num_iter_max=100

  • index_lens_model_list – list (length of different patches/bands) of integer lists, evaluating a subset of the lens models per individual bands. e.g., [[0], [2, 3], [1]] assigns the 0th lens model to the 0th band, the 2nd and 3rd lens models to the 1st band, and the 1st lens model to the 2nd band. If this keyword is set, the image positions need to have a specified band/frame assigned to it

  • point_source_frame_list – list of list of ints, assigns each model in point_source_type_list a frame list. Only relevent for LENSED_POSITION. e.g. if point_source_type_list = [“UNLENSED”, “LENSED_POSITION”, “LENSED_POSITION”] with point_source_frame_list = [None, [0, 1, 2], [1, 2, 0, 1]], then the first LENSED_POSITION will have a frame list of [0, 1, 2] and the second LENSED_POSITION will have a frame list of [1, 2, 0, 1]. See docstring for point_source_frame_list in PSBase for further details.

  • redshift_list – None or list of redshifts (only required for multiple source redshifts)

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

update_lens_model(lens_model_class)[source]
Parameters:

lens_model_class – instance of LensModel class

Returns:

update instance of lens model class

k_list(k)[source]
Parameters:

k – index of point source model

Returns:

list of lengths of images with corresponding lens models in the frame (or None if not multi-frame)

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:

array of source positions for each point source model

image_position(kwargs_ps, kwargs_lens, k=None, original_position=False, additional_images=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 or int; 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

  • additional_images (bool) – if True, solves the lens equation for additional images

Returns:

list of arrays of image positions per point source model component

point_source_list(kwargs_ps, kwargs_lens, k=None, with_amp=True)[source]

Returns the image coordinates and image 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 or int; selects 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

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

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 or int, selects a subset of the point source models in the return

Returns:

list of image amplitudes per model component

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

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 (list of arrays), dec_pos (list of arrays), amp (list of arrays), n (int)

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

linear_param_from_kwargs(kwargs_list)[source]

Inverse function of update_linear() returning the linear amplitude list for the keyword argument list.

Parameters:

kwargs_list (list of keyword arguments) – model parameters including the linear amplitude parameters

Returns:

list of linear amplitude parameters

Return type:

list

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 to the source plane)

Parameters:
  • kwargs_ps – point source keyword argument list

  • kwargs_lens – lens model keyword argument list

  • tolerance – Euclidian distance between the source positions ray-traced backwards to be tolerated

Returns:

bool: True, if requirement on tolerance is fulfilled, False if not.

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. This list should include all of the point source models even if flux_from_point_source is False for any of them. In that case, the amplitudes will not be changed for those models.

  • kwargs_ps – list of point source keywords

Returns:

overwrites kwargs_ps with new amplitudes

static 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

Module contents