lenstronomy.LensModel.Solver package — lenstronomy 1.9.1 documentation

# lenstronomy.LensModel.Solver package

## Submodules

## lenstronomy.LensModel.Solver.lens_equation_solver module

class `lenstronomy.LensModel.Solver.lens_equation_solver.` `LensEquationSolver`(lensModel)

  Bases: `object`

  class to solve for image positions given lens model and source position

  `candidate_solutions`(sourcePos_x, sourcePos_y, kwargs_lens, min_distance=0.1, search_window=10, verbose=False, x_center=0, y_center=0)

    finds pixels in the image plane possibly hosting a solution of the lens equation, for the given source position and lens model

    Parameters: | sourcePos_x – source position in units of angle sourcePos_y – source position in units of angle kwargs_lens – lens model parameters as keyword arguments min_distance – minimum separation to consider for two images in units of angle search_window – window size to be considered by the solver. Will not find image position outside this window verbose – bool, if True, prints some useful information for the user x_center – float, center of the window to search for point sources y_center – float, center of the window to search for point sources
    Returns: | (approximate) angular position of (multiple) images ra_pos, dec_pos in units of angles, related ray-traced source displacements and pixel width
    Raises: | AttributeError, KeyError

  `findBrightImage`(sourcePos_x, sourcePos_y, kwargs_lens, numImages=4, min_distance=0.01, search_window=5, precision_limit=1e-10, num_iter_max=10, arrival_time_sort=True, x_center=0, y_center=0, num_random=0, non_linear=False, magnification_limit=None, initial_guess_cut=True, verbose=False)

    Parameters: | sourcePos_x – source position in units of angle sourcePos_y – source position in units of angle kwargs_lens – lens model parameters as keyword arguments min_distance – minimum separation to consider for two images in units of angle search_window – window size to be considered by the solver. Will not find image position outside this window precision_limit – required precision in the lens equation solver (in units of angle in the source plane). num_iter_max – maximum iteration of lens-source mapping conducted by solver to match the required precision arrival_time_sort – bool, if True, sorts image position in arrival time (first arrival photon first listed) initial_guess_cut – bool, if True, cuts initial local minima selected by the grid search based on distance criteria from the source position verbose – bool, if True, prints some useful information for the user x_center – float, center of the window to search for point sources y_center – float, center of the window to search for point sources num_random – int, number of random positions within the search window to be added to be starting positions for the gradient decent solver non_linear – bool, if True applies a non-linear solver not dependent on Hessian computation magnification_limit – None or float, if set will only return image positions that have an abs(magnification) larger than this number
    Returns: | (exact) angular position of (multiple) images ra_pos, dec_pos in units of angle

  `image_position_from_source`(sourcePos_x, sourcePos_y, kwargs_lens, min_distance=0.1, search_window=10, precision_limit=1e-10, num_iter_max=100, arrival_time_sort=True, initial_guess_cut=True, verbose=False, x_center=0, y_center=0, num_random=0, non_linear=False, magnification_limit=None)

    finds image position source position and lens model

    Parameters: | sourcePos_x – source position in units of angle sourcePos_y – source position in units of angle kwargs_lens – lens model parameters as keyword arguments min_distance – minimum separation to consider for two images in units of angle search_window – window size to be considered by the solver. Will not find image position outside this window precision_limit – required precision in the lens equation solver (in units of angle in the source plane). num_iter_max – maximum iteration of lens-source mapping conducted by solver to match the required precision arrival_time_sort – bool, if True, sorts image position in arrival time (first arrival photon first listed) initial_guess_cut – bool, if True, cuts initial local minima selected by the grid search based on distance criteria from the source position verbose – bool, if True, prints some useful information for the user x_center – float, center of the window to search for point sources y_center – float, center of the window to search for point sources num_random – int, number of random positions within the search window to be added to be starting positions for the gradient decent solver non_linear – bool, if True applies a non-linear solver not dependent on Hessian computation magnification_limit – None or float, if set will only return image positions that have an abs(magnification) larger than this number
    Returns: | (exact) angular position of (multiple) images ra_pos, dec_pos in units of angle
    Raises: | AttributeError, KeyError

  `image_position_stochastic`(source_x, source_y, kwargs_lens, search_window=10, precision_limit=1e-10, arrival_time_sort=True, x_center=0, y_center=0, num_random=1000)

    Solves the lens equation stochastic with the scipy minimization routine on the quadratic distance between the backwards ray-shooted proposed image position and the source position. Credits to Giulia Pagano

    Parameters: | source_x – source position source_y – source position kwargs_lens – lens model list of keyword arguments search_window – angular size of search window precision_limit – limit required on the precision in the source plane arrival_time_sort – bool, if True sorts according to arrival time x_center – center of search window y_center – center of search window num_random – number of random starting points of the non-linear solver in the search window
    Returns: | x_image, y_image

  `sort_arrival_times`(x_mins, y_mins, kwargs_lens)

    sort arrival times (fermat potential) of image positions in increasing order of light travel time

    Parameters: | x_mins – ra position of images y_mins – dec position of images kwargs_lens – keyword arguments of lens model
    Returns: | sorted lists of x_mins and y_mins

## lenstronomy.LensModel.Solver.solver module

class `lenstronomy.LensModel.Solver.solver.` `Solver`(solver_type, lensModel, num_images)

  Bases: `object`

  joint solve class to manage with type of solver to be executed and checks whether the requirements are fulfilled.

  `add_fixed_lens`(kwargs_fixed_lens, kwargs_lens_init)

    returns kwargs that are kept fixed during run, depending on options

    Parameters: | kwargs_fixed_lens – keyword argument list of fixed parameters (indicated by fitting argument of the user) kwargs_lens_init – Initial values of the full lens model keyword arguments
    Returns: | updated kwargs_fixed_lens, added fixed parameters being added (and replaced later on) by the non-linear solver.

  `check_solver`(image_x, image_y, kwargs_lens)

    returns the precision of the solver to match the image position

    Parameters: | kwargs_lens – full lens model (including solved parameters) image_x – point source in image image_y – point source in image
    Returns: | precision of Euclidean distances between the different rays arriving at the image positions

  `constraint_lensmodel`(x_pos, y_pos, kwargs_list, xtol=1.49012e-12)

    Parameters: | x_pos – y_pos – kwargs_list –
    Returns: |

  `update_solver`(kwargs_lens, x_pos, y_pos)

    Parameters: | kwargs_lens – x_pos – y_pos –
    Returns: |

## lenstronomy.LensModel.Solver.solver2point module

class `lenstronomy.LensModel.Solver.solver2point.` `Solver2Point`(lensModel, solver_type='CENTER', decoupling=True)

  Bases: `object`

  class to solve a constraint lens model with two point source positions

  options are: ‘CENTER’: solves for ‘center_x’, ‘center_y’ parameters of the first lens model ‘ELLIPSE’: solves for ‘e1’, ‘e2’ of the first lens (can also be shear) ‘SHAPELETS’: solves for shapelet coefficients c01, c10 ‘THETA_E_PHI: solves for Einstein radius of first lens model and shear angle of second model

  `add_fixed_lens`(kwargs_fixed_lens_list, kwargs_lens_init)

    Parameters: | kwargs_fixed_lens_list – kwargs_lens_init –
    Returns: |

  `constraint_lensmodel`(x_pos, y_pos, kwargs_list, xtol=1.49012e-12)

    constrains lens model parameters by demanding the solution to match the image positions to a single source position

    Parameters: | x_pos – list of image positions (x-axis) y_pos – list of image position (y-axis) kwargs_list – list of lens model kwargs xtol – tolerance level of solution when to stop the non-linear solver
    Returns: | updated lens model that satisfies the lens equation for the point sources

  `solve`(x_pos, y_pos, init, kwargs_list, a, xtol=1.49012e-12)

## lenstronomy.LensModel.Solver.solver4point module

class `lenstronomy.LensModel.Solver.solver4point.` `Solver4Point`(lensModel, solver_type='PROFILE')

  Bases: `object`

  class to make the constraints for the solver

  `add_fixed_lens`(kwargs_fixed_lens_list, kwargs_lens_init)

    Parameters: | kwargs_fixed_lens_list – kwargs_lens_init –
    Returns: |

  `constraint_lensmodel`(x_pos, y_pos, kwargs_list, xtol=1.49012e-12)

    Parameters: | x_pos – list of image positions (x-axis) y_pos – list of image position (y-axis) init – initial parameters kwargs_list – list of lens model kwargs
    Returns: | updated lens model that satisfies the lens equation for the point sources

  `solve`(x_pos, y_pos, init, kwargs_list, a, xtol=1.49012e-10)

## Module contents