lenstronomy.LightModel package

Subpackages

Submodules

lenstronomy.LightModel.light_model module

class LightModel(light_model_list, deflection_scaling_list=None, source_redshift_list=None, profile_kwargs_list=None)[source]

Bases: LinearBasis

Class to handle extended surface brightness profiles (for e.g. source and lens light)

all profiles come with a surface_brightness parameterization (in units per square angle and independent of the pixel scale). The parameter ‘amp’ is the linear scaling parameter of surface brightness. Some functional forms come with a total_flux() definition that provide the integral of the surface brightness for a given set of parameters.

The SimulationAPI module allows to use astronomical magnitudes to be used and translated into the surface brightness conventions of this module given a magnitude zero point.

__init__(light_model_list, deflection_scaling_list=None, source_redshift_list=None, profile_kwargs_list=None)[source]
Parameters:
  • light_model_list – list of light models

  • deflection_scaling_list – list of floats indicating a relative scaling of the deflection angle from the reduced angles in the lens model definition (optional, only possible in single lens plane with multiple source planes)

  • source_redshift_list – list of redshifts for the different light models (optional and only used in multi-plane lensing in conjunction with a cosmology model)

  • profile_kwargs_list – list of dicts, keyword arguments used to initialize light model profile classes in the same order of the light_model_list. If any of the profile_kwargs are None, then that profile will be initialized using default settings.

lenstronomy.LightModel.light_model_base module

class LightModelBase(light_model_list, profile_kwargs_list=None)[source]

Bases: object

Class to handle source and lens light models.

__init__(light_model_list, profile_kwargs_list=None)[source]
Parameters:
  • light_model_list – list of light models

  • profile_kwargs_list – list of dicts, keyword arguments used to initialize light model profile classes in the same order of the light_model_list. If any of the profile_kwargs are None, then that profile will be initialized using default settings.

surface_brightness(x, y, kwargs_list, k=None)[source]
Parameters:
  • x (set or single 1d numpy array) – coordinate in units of arcsec relative to the center of the image

  • y (set or single 1d numpy array) – coordinate in units of arcsec relative to the center of the image

  • kwargs_list – keyword argument list of light profile

  • k – integer or list of integers for selecting subsets of light profiles

light_3d(r, kwargs_list, k=None)[source]

Computes 3d density at radius r (3D radius) such that integrated in projection in units of angle results in the projected surface brightness.

Parameters:
  • r – 3d radius units of arcsec relative to the center of the light profile

  • kwargs_list – keyword argument list of light profile

  • k – integer or list of integers for selecting subsets of light profiles.

Returns:

flux density

total_flux(kwargs_list, norm=False, k=None)[source]

Computes the total flux of each individual light profile. This allows to estimate the total flux as well as lenstronomy amp to magnitude conversions. Not all models are supported. The units are linked to the data to be modelled with associated noise properties (default is count/s).

Parameters:
  • kwargs_list – list of keyword arguments corresponding to the light profiles. The ‘amp’ parameter can be missing.

  • norm – bool, if True, computes the flux for amp=1

  • k – int, if set, only evaluates the specific light model

Returns:

list of (total) flux values attributed to each profile

property param_name_list

Returns the list of all parameter names.

Returns:

list of lists of strings (for each light model separately)

property param_name_list_latex

Returns the list of all parameter names in LateX style.

Returns:

list of lists of strings (for each light model separately)

check_parameters(kwargs_list)[source]

Checks whether the parameter list is consistent with the parameters required by the light model.

Parameters:

kwargs_list – keyword argument list as parameterised models

Returns:

None or raise ValueError with error message of what parameter is not supported.

delete_interpol_caches()[source]

Call the delete_cache method of INTERPOL profiles.

lenstronomy.LightModel.light_param module

class LightParam(light_model_list, kwargs_fixed, kwargs_lower=None, kwargs_upper=None, param_type='light', linear_solver=True, profile_kwargs_list=None)[source]

Bases: object

Class manages the parameters corresponding to the LightModel() module.

Also manages linear parameter handling.

__init__(light_model_list, kwargs_fixed, kwargs_lower=None, kwargs_upper=None, param_type='light', linear_solver=True, profile_kwargs_list=None)[source]
Parameters:
  • light_model_list – list of light models

  • kwargs_fixed – list of keyword arguments corresponding to parameters held fixed during sampling

  • kwargs_lower – list of keyword arguments indicating hard lower limit of the parameter space

  • kwargs_upper – list of keyword arguments indicating hard upper limit of the parameter space

  • param_type – string (optional), adding specifications in the output strings (such as lens light or source light)

  • linear_solver – bool, if True fixes the linear amplitude parameters ‘amp’ (avoid sampling) such that they get overwritten by the linear solver solution.

  • profile_kwargs_list – list of dicts, keyword arguments used to initialize light model profile classes in the same order of the light_model_list. If any of the profile_kwargs are None, then that profile will be initialized using default settings.

property param_name_list
get_params(args, i)[source]
Parameters:
  • args – list of floats corresponding ot the arguments being sampled

  • i – int, index of the first argument that is managed/read-out by this class

Returns:

keyword argument list of the light profile, index after reading out the arguments corresponding to this class

set_params(kwargs_list)[source]
Parameters:

kwargs_list – list of keyword arguments of the light profile (free parameter as well as optionally the fixed ones)

Returns:

list of floats corresponding to the free parameters

num_param(latex_style=False)[source]
Parameters:

latex_style – boolena; if True, returns latex strings for plotting

Returns:

int, list of strings with param names

num_param_linear()[source]
Returns:

number of linear basis set coefficients

lenstronomy.LightModel.linear_basis module

class LinearBasis(**kwargs)[source]

Bases: LightModelBase

Class to handle source and lens light models.

__init__(**kwargs)[source]
Parameters:

kwargs – keyword arguments for LightModelBase class

functions_split(x, y, kwargs_list, k=None)[source]

Split model in different components.

Parameters:
  • x – coordinate in units of arcsec relative to the center of the image

  • y – coordinate in units of arcsec relative to the center of the image

  • kwargs_list – keyword argument list of light profile

  • k – integer or list of integers for selecting subsets of light profiles

num_param_linear(kwargs_list, list_return=False)[source]
Parameters:
  • kwargs_list – list of keyword arguments of the light profiles

  • list_return – bool, if True returns list of individual number of parameters

Returns:

number of linear basis set coefficients

num_param_linear_list(kwargs_list)[source]

Returns the list (in order of the light profiles) of the number of linear components per model.

Parameters:

kwargs_list – list of keyword arguments of the light profiles

Returns:

number of linear basis set coefficients

update_linear(param, i, kwargs_list)[source]
Parameters:
  • param – array of linear amplitude coefficients in the order of the linear minimization of the ImSim module

  • i – index of first coefficient to start reading out the linear parameters associated with the model components of this class

  • kwargs_list – list of keyword arguments of the model components

Returns:

kwargs list with over-written or added ‘amp’ parameters according to the coefficients in param

add_fixed_linear(kwargs_fixed_list)[source]
Parameters:

kwargs_fixed_list – list of fixed keyword arguments

Returns:

updated kwargs_fixed_list with additional linear parameters being fixed.

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_positive_flux_profile(kwargs_list)[source]

Check whether linear amplitude parameter are non-negative for specified list of lens models that have a physical amplitude interpretation.

Parameters:

kwargs_list – light model parameter keyword argument list

Returns:

bool, if True, no specified model has negative flux

Module contents