lenstronomy.LensModel.Profiles package

Submodules

lenstronomy.LensModel.Profiles.arc_perturbations module

class ArcPerturbations[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Uses radial and tangential fourier modes within a specific range in both directions to perturb a lensing potential.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, coeff, d_r, d_phi, center_x, center_y)[source]
Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • coeff – float, amplitude of basis
  • d_r – period of radial sinusoidal in units of angle
  • d_phi – period of tangential sinusoidal in radian
  • center_x – center of rotation for tangential basis
  • center_y – center of rotation for tangential basis
Returns:

f_x, f_y

function(x, y, coeff, d_r, d_phi, center_x, center_y)[source]
Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • coeff – float, amplitude of basis
  • d_r – period of radial sinusoidal in units of angle
  • d_phi – period of tangential sinusoidal in radian
  • center_x – center of rotation for tangential basis
  • center_y – center of rotation for tangential basis
Returns:

hessian(x, y, coeff, d_r, d_phi, center_x, center_y)[source]
Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • coeff – float, amplitude of basis
  • d_r – period of radial sinusoidal in units of angle
  • d_phi – period of tangential sinusoidal in radian
  • center_x – center of rotation for tangential basis
  • center_y – center of rotation for tangential basis
Returns:

f_xx, f_yy, f_xy

lenstronomy.LensModel.Profiles.base_profile module

class LensProfileBase(*args, **kwargs)[source]

Bases: object

This class acts as the base class of all lens model functions and indicates raise statements and default outputs if these functions are not defined in the specific lens model class.

__init__(*args, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

density_lens(*args, **kwargs)[source]

Computes the density at 3d radius r given lens model parameterization. The integral in the LOS projection of this quantity results in the convergence quantity. (optional definition)

\[\kappa(x, y) = \int_{-\infty}^{\infty} \rho(x, y, z) dz\]
Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
derivatives(*args, **kwargs)[source]

Deflection angles.

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
function(*args, **kwargs)[source]

Lensing potential (only needed for specific calculations, such as time delays)

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
hessian(*args, **kwargs)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
mass_2d_lens(*args, **kwargs)[source]

Two-dimensional enclosed mass at radius r (optional definition)

\[M_{2d}(R) = \int_{0}^{R} \rho_{2d}(r) 2\pi r dr\]

with \(\rho_{2d}(r)\) is the density_2d_lens() definition

The mass definition is such that:

\[\alpha = mass_2d / r / \pi\]

with alpha is the deflection angle

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
mass_3d_lens(*args, **kwargs)[source]

Mass enclosed a 3d sphere or radius r given a lens parameterization with angular units The input parameter are identical as for the derivatives definition. (optional definition)

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
set_dynamic()[source]
Returns:no return, deletes pre-computed variables for certain lens models
set_static(**kwargs)[source]

Pre-computes certain computations that do only relate to the lens model parameters and not to the specific position where to evaluate the lens model.

Parameters:kwargs – lens model parameters
Returns:no return, for certain lens model some private self variables are initiated

lenstronomy.LensModel.Profiles.chameleon module

class Chameleon(static=False)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class of the Chameleon model (See Suyu+2014) an elliptical truncated double isothermal profile.

__init__(static=False)[source]

Initialize self. See help(type(self)) for accurate signature.

density_lens(r, alpha_1, w_c, w_t, e1=0, e2=0, center_x=0, center_y=0)[source]

Spherical average density as a function of 3d radius.

Parameters:
  • r – 3d radius
  • alpha_1 – deflection angle at 1 (arcseconds) from the center
  • w_c – see Suyu+2014
  • w_t – see Suyu+2014
  • e1 – ellipticity parameter
  • e2 – ellipticity parameter
  • center_x – ra center
  • center_y – dec center
Returns:

matter density at 3d radius r

derivatives(x, y, alpha_1, w_c, w_t, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – ra-coordinate
  • y – dec-coordinate
  • alpha_1 – deflection angle at 1 (arcseconds) from the center
  • w_c – see Suyu+2014
  • w_t – see Suyu+2014
  • e1 – ellipticity parameter
  • e2 – ellipticity parameter
  • center_x – ra center
  • center_y – dec center
Returns:

deflection angles (RA, DEC)

function(x, y, alpha_1, w_c, w_t, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – ra-coordinate
  • y – dec-coordinate
  • alpha_1 – deflection angle at 1 (arcseconds) from the center
  • w_c – see Suyu+2014
  • w_t – see Suyu+2014
  • e1 – ellipticity parameter
  • e2 – ellipticity parameter
  • center_x – ra center
  • center_y – dec center
Returns:

lensing potential

hessian(x, y, alpha_1, w_c, w_t, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – ra-coordinate
  • y – dec-coordinate
  • alpha_1 – deflection angle at 1 (arcseconds) from the center
  • w_c – see Suyu+2014
  • w_t – see Suyu+2014
  • e1 – ellipticity parameter
  • e2 – ellipticity parameter
  • center_x – ra center
  • center_y – dec center
Returns:

second derivatives of the lensing potential (Hessian: f_xx, f_xy, f_yx, f_yy)

lower_limit_default = {'alpha_1': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.8, 'e2': -0.8, 'w_c': 0, 'w_t': 0}
mass_3d_lens(r, alpha_1, w_c, w_t, e1=0, e2=0, center_x=0, center_y=0)[source]

Mass enclosed 3d radius.

Parameters:
  • r – 3d radius
  • alpha_1 – deflection angle at 1 (arcseconds) from the center
  • w_c – see Suyu+2014
  • w_t – see Suyu+2014
  • e1 – ellipticity parameter
  • e2 – ellipticity parameter
  • center_x – ra center
  • center_y – dec center
Returns:

mass enclosed 3d radius r

param_convert(alpha_1, w_c, w_t, e1, e2)[source]

Convert the parameter alpha_1 (deflection angle one arcsecond from the center) into the “Einstein radius” scale parameter of the two NIE profiles.

Parameters:
  • alpha_1 – deflection angle at 1 (arcseconds) from the center
  • w_c – see Suyu+2014
  • w_t – see Suyu+2014
  • e1 – eccentricity modulus
  • e2 – eccentricity modulus
Returns:

param_names = ['alpha_1', 'w_c', 'w_t', 'e1', 'e2', 'center_x', 'center_y']
set_dynamic()[source]
Returns:
set_static(alpha_1, w_c, w_t, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • alpha_1
  • w_c
  • w_t
  • e1
  • e2
  • center_x
  • center_y
Returns:

upper_limit_default = {'alpha_1': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.8, 'e2': 0.8, 'w_c': 100, 'w_t': 100}
class DoubleChameleon[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class of the Chameleon model (See Suyu+2014) an elliptical truncated double isothermal profile.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

density_lens(r, alpha_1, ratio, w_c1, w_t1, e11, e21, w_c2, w_t2, e12, e22, center_x=0, center_y=0)[source]
Parameters:
  • r – 3d radius
  • alpha_1 – deflection angle at 1 (arcseconds) from the center
  • ratio – ratio of deflection amplitude at radius = 1 of the first to second Chameleon profile
  • w_c1 – Suyu+2014 for first profile
  • w_t1 – Suyu+2014 for first profile
  • e11 – ellipticity parameter for first profile
  • e21 – ellipticity parameter for first profile
  • w_c2 – Suyu+2014 for second profile
  • w_t2 – Suyu+2014 for second profile
  • e12 – ellipticity parameter for second profile
  • e22 – ellipticity parameter for second profile
  • center_x – ra center
  • center_y – dec center
Returns:

3d density at radius r

derivatives(x, y, alpha_1, ratio, w_c1, w_t1, e11, e21, w_c2, w_t2, e12, e22, center_x=0, center_y=0)[source]
Parameters:
  • x – ra-coordinate
  • y – dec-coordinate
  • alpha_1 – deflection angle at 1 (arcseconds) from the center
  • ratio – ratio of deflection amplitude at radius = 1 of the first to second Chameleon profile
  • w_c1 – Suyu+2014 for first profile
  • w_t1 – Suyu+2014 for first profile
  • e11 – ellipticity parameter for first profile
  • e21 – ellipticity parameter for first profile
  • w_c2 – Suyu+2014 for second profile
  • w_t2 – Suyu+2014 for second profile
  • e12 – ellipticity parameter for second profile
  • e22 – ellipticity parameter for second profile^V
  • center_x – ra center
  • center_y – dec center
Returns:

deflection angles (RA, DEC)

function(x, y, alpha_1, ratio, w_c1, w_t1, e11, e21, w_c2, w_t2, e12, e22, center_x=0, center_y=0)[source]
Parameters:
  • x – ra-coordinate
  • y – dec-coordinate
  • alpha_1 – deflection angle at 1 (arcseconds) from the center
  • ratio – ratio of deflection amplitude at radius = 1 of the first to second Chameleon profile
  • w_c1 – Suyu+2014 for first profile
  • w_t1 – Suyu+2014 for first profile
  • e11 – ellipticity parameter for first profile
  • e21 – ellipticity parameter for first profile
  • w_c2 – Suyu+2014 for second profile
  • w_t2 – Suyu+2014 for second profile
  • e12 – ellipticity parameter for second profile
  • e22 – ellipticity parameter for second profile
  • center_x – ra center
  • center_y – dec center
Returns:

lensing potential

hessian(x, y, alpha_1, ratio, w_c1, w_t1, e11, e21, w_c2, w_t2, e12, e22, center_x=0, center_y=0)[source]
Parameters:
  • x – ra-coordinate
  • y – dec-coordinate
  • alpha_1 – deflection angle at 1 (arcseconds) from the center
  • ratio – ratio of deflection amplitude at radius = 1 of the first to second Chameleon profile
  • w_c1 – Suyu+2014 for first profile
  • w_t1 – Suyu+2014 for first profile
  • e11 – ellipticity parameter for first profile
  • e21 – ellipticity parameter for first profile
  • w_c2 – Suyu+2014 for second profile
  • w_t2 – Suyu+2014 for second profile
  • e12 – ellipticity parameter for second profile
  • e22 – ellipticity parameter for second profile
  • center_x – ra center
  • center_y – dec center
Returns:

second derivatives of the lensing potential (Hessian: f_xx, f_yy, f_xy)

lower_limit_default = {'alpha_1': 0, 'center_x': -100, 'center_y': -100, 'e11': -0.8, 'e12': -0.8, 'e21': -0.8, 'e22': -0.8, 'ratio': 0, 'w_c1': 0, 'w_c2': 0, 'w_t1': 0, 'w_t2': 0}
mass_3d_lens(r, alpha_1, ratio, w_c1, w_t1, e11, e21, w_c2, w_t2, e12, e22, center_x=0, center_y=0)[source]
Parameters:
  • r – 3d radius
  • alpha_1 – deflection angle at 1 (arcseconds) from the center
  • ratio – ratio of deflection amplitude at radius = 1 of the first to second Chameleon profile
  • w_c1 – Suyu+2014 for first profile
  • w_t1 – Suyu+2014 for first profile
  • e11 – ellipticity parameter for first profile
  • e21 – ellipticity parameter for first profile
  • w_c2 – Suyu+2014 for second profile
  • w_t2 – Suyu+2014 for second profile
  • e12 – ellipticity parameter for second profile
  • e22 – ellipticity parameter for second profile
  • center_x – ra center
  • center_y – dec center
Returns:

mass enclosed 3d radius

param_names = ['alpha_1', 'ratio', 'w_c1', 'w_t1', 'e11', 'e21', 'w_c2', 'w_t2', 'e12', 'e22', 'center_x', 'center_y']
set_dynamic()[source]
Returns:no return, deletes pre-computed variables for certain lens models
set_static(alpha_1, ratio, w_c1, w_t1, e11, e21, w_c2, w_t2, e12, e22, center_x=0, center_y=0)[source]

Pre-computes certain computations that do only relate to the lens model parameters and not to the specific position where to evaluate the lens model.

Parameters:kwargs – lens model parameters
Returns:no return, for certain lens model some private self variables are initiated
upper_limit_default = {'alpha_1': 100, 'center_x': 100, 'center_y': 100, 'e11': 0.8, 'e12': 0.8, 'e21': 0.8, 'e22': 0.8, 'ratio': 100, 'w_c1': 100, 'w_c2': 100, 'w_t1': 100, 'w_t2': 100}
class TripleChameleon[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class of the Chameleon model (See Suyu+2014) an elliptical truncated double isothermal profile.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

density_lens(r, alpha_1, ratio12, ratio13, w_c1, w_t1, e11, e21, w_c2, w_t2, e12, e22, w_c3, w_t3, e13, e23, center_x=0, center_y=0)[source]
Parameters:
  • r – 3d radius
  • alpha_1
  • ratio12 – ratio of first to second amplitude
  • ratio13 – ratio of first to third amplitude
  • w_c1
  • w_t1
  • e11
  • e21
  • w_c2
  • w_t2
  • e12
  • e22
  • center_x
  • center_y
Returns:

density at radius r (spherical average)

derivatives(x, y, alpha_1, ratio12, ratio13, w_c1, w_t1, e11, e21, w_c2, w_t2, e12, e22, w_c3, w_t3, e13, e23, center_x=0, center_y=0)[source]
Parameters:
  • alpha_1
  • ratio12 – ratio of first to second amplitude
  • ratio13 – ratio of first to third amplidute
  • w_c1
  • w_t1
  • e11
  • e21
  • w_c2
  • w_t2
  • e12
  • e22
  • center_x
  • center_y
Returns:

function(x, y, alpha_1, ratio12, ratio13, w_c1, w_t1, e11, e21, w_c2, w_t2, e12, e22, w_c3, w_t3, e13, e23, center_x=0, center_y=0)[source]
Parameters:
  • alpha_1
  • ratio12 – ratio of first to second amplitude
  • ratio13 – ratio of first to third amplitude
  • w_c1
  • w_t1
  • e11
  • e21
  • w_c2
  • w_t2
  • e12
  • e22
  • center_x
  • center_y
Returns:

hessian(x, y, alpha_1, ratio12, ratio13, w_c1, w_t1, e11, e21, w_c2, w_t2, e12, e22, w_c3, w_t3, e13, e23, center_x=0, center_y=0)[source]
Parameters:
  • alpha_1
  • ratio12 – ratio of first to second amplitude
  • ratio13 – ratio of first to third amplidute
  • w_c1
  • w_t1
  • e11
  • e21
  • w_c2
  • w_t2
  • e12
  • e22
  • center_x
  • center_y
Returns:

lower_limit_default = {'alpha_1': 0, 'center_x': -100, 'center_y': -100, 'e11': -0.8, 'e12': -0.8, 'e13': -0.8, 'e21': -0.8, 'e22': -0.8, 'e23': -0.8, 'ratio12': 0, 'ratio13': 0, 'w_c1': 0, 'w_c2': 0, 'w_c3': 0, 'w_t1': 0, 'w_t2': 0, 'w_t3': 0}
mass_3d_lens(r, alpha_1, ratio12, ratio13, w_c1, w_t1, e11, e21, w_c2, w_t2, e12, e22, w_c3, w_t3, e13, e23, center_x=0, center_y=0)[source]
Parameters:
  • r – 3d radius
  • alpha_1
  • ratio12 – ratio of first to second amplitude
  • ratio13 – ratio of first to third amplitude
  • w_c1
  • w_t1
  • e11
  • e21
  • w_c2
  • w_t2
  • e12
  • e22
  • center_x
  • center_y
Returns:

mass enclosed 3d radius

param_names = ['alpha_1', 'ratio12', 'ratio13', 'w_c1', 'w_t1', 'e11', 'e21', 'w_c2', 'w_t2', 'e12', 'e22', 'w_c3', 'w_t3', 'e13', 'e23', 'center_x', 'center_y']
set_dynamic()[source]
Returns:no return, deletes pre-computed variables for certain lens models
set_static(alpha_1, ratio12, ratio13, w_c1, w_t1, e11, e21, w_c2, w_t2, e12, e22, w_c3, w_t3, e13, e23, center_x=0, center_y=0)[source]

Pre-computes certain computations that do only relate to the lens model parameters and not to the specific position where to evaluate the lens model.

Parameters:kwargs – lens model parameters
Returns:no return, for certain lens model some private self variables are initiated
upper_limit_default = {'alpha_1': 100, 'center_x': 100, 'center_y': 100, 'e11': 0.8, 'e12': 0.8, 'e13': 0.8, 'e21': 0.8, 'e22': 0.8, 'e23': 0.8, 'ratio12': 100, 'ratio13': 100, 'w_c1': 100, 'w_c2': 100, 'w_c3': 100, 'w_t1': 100, 'w_t2': 100, 'w_t3': 100}
class DoubleChameleonPointMass[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class of the Chameleon model (See Suyu+2014) an elliptical truncated double isothermal profile.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, alpha_1, ratio_pointmass, ratio_chameleon, w_c1, w_t1, e11, e21, w_c2, w_t2, e12, e22, center_x=0, center_y=0)[source]
Parameters:
  • x
  • y
  • alpha_1
  • ratio_pointmass – ratio of point source Einstein radius to combined Chameleon deflection angle at r=1
  • ratio_chameleon – ratio in deflection angles at r=1 for the two Chameleon profiles
  • w_c1 – Suyu+2014 for first profile
  • w_t1 – Suyu+2014 for first profile
  • e11 – ellipticity parameter for first profile
  • e21 – ellipticity parameter for first profile
  • w_c2 – Suyu+2014 for second profile
  • w_t2 – Suyu+2014 for second profile
  • e12 – ellipticity parameter for second profile
  • e22 – ellipticity parameter for second profile
  • center_x – ra center
  • center_y – dec center
Returns:

function(x, y, alpha_1, ratio_pointmass, ratio_chameleon, w_c1, w_t1, e11, e21, w_c2, w_t2, e12, e22, center_x=0, center_y=0)[source]

#TODO chose better parameterization for combining point mass and Chameleon profiles

Parameters:
  • x – ra-coordinate
  • y – dec-coordinate
  • alpha_1 – deflection angle at 1 (arcseconds) from the center
  • ratio_pointmass – ratio of point source Einstein radius to combined Chameleon deflection angle at r=1
  • ratio_chameleon – ratio in deflection angles at r=1 for the two Chameleon profiles
  • w_c1 – Suyu+2014 for first profile
  • w_t1 – Suyu+2014 for first profile
  • e11 – ellipticity parameter for first profile
  • e21 – ellipticity parameter for first profile
  • w_c2 – Suyu+2014 for second profile
  • w_t2 – Suyu+2014 for second profile
  • e12 – ellipticity parameter for second profile
  • e22 – ellipticity parameter for second profile
  • center_x – ra center
  • center_y – dec center
Returns:

lensing potential

hessian(x, y, alpha_1, ratio_pointmass, ratio_chameleon, w_c1, w_t1, e11, e21, w_c2, w_t2, e12, e22, center_x=0, center_y=0)[source]
Parameters:
  • x
  • y
  • alpha_1
  • ratio_pointmass – ratio of point source Einstein radius to combined Chameleon deflection angle at r=1
  • ratio_chameleon – ratio in deflection angles at r=1 for the two Chameleon profiles
  • w_c1 – Suyu+2014 for first profile
  • w_t1 – Suyu+2014 for first profile
  • e11 – ellipticity parameter for first profile
  • e21 – ellipticity parameter for first profile
  • w_c2 – Suyu+2014 for second profile
  • w_t2 – Suyu+2014 for second profile
  • e12 – ellipticity parameter for second profile
  • e22 – ellipticity parameter for second profile
  • center_x – ra center
  • center_y – dec center
Returns:

lower_limit_default = {'alpha_1': 0, 'center_x': -100, 'center_y': -100, 'e11': -0.8, 'e12': -0.8, 'e21': -0.8, 'e22': -0.8, 'ratio_chameleon': 0, 'ratio_pointmass': 0, 'w_c1': 0, 'w_c2': 0, 'w_t1': 0, 'w_t2': 0}
param_names = ['alpha_1', 'ratio_chameleon', 'ratio_pointmass', 'w_c1', 'w_t1', 'e11', 'e21', 'w_c2', 'w_t2', 'e12', 'e22', 'center_x', 'center_y']
upper_limit_default = {'alpha_1': 100, 'center_x': 100, 'center_y': 100, 'e11': 0.8, 'e12': 0.8, 'e21': 0.8, 'e22': 0.8, 'ratio_chameleon': 100, 'ratio_pointmass': 100, 'w_c1': 100, 'w_c2': 100, 'w_t1': 100, 'w_t2': 100}

lenstronomy.LensModel.Profiles.cnfw module

class CNFW[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

this class computes the lensing quantities of a cored NFW profile: rho = rho0 * (r + r_core)^-1 * (r + rs)^-2 alpha_Rs is the normalization equivalent to the deflection angle at rs in the absence of a core

__init__()[source]
alpha_r(R, Rs, rho0, r_core)[source]

Deflection angel of NFW profile along the radial direction.

Parameters:
  • R (float/numpy array) – radius of interest
  • Rs (float) – scale radius
Returns:

Epsilon(R) projected density at radius R

cnfwGamma(R, Rs, rho0, r_core, ax_x, ax_y)[source]

Shear gamma of NFW profile (times Sigma_crit) along the projection to coordinate ‘axis’.

Parameters:
  • R (float/numpy array) – radius of interest
  • Rs (float) – scale radius
  • rho0 (float) – density normalization (characteristic density)
Returns:

Epsilon(R) projected density at radius R

density(R, Rs, rho0, r_core)[source]

Three dimensional truncated NFW profile.

Parameters:
  • R (float/numpy array) – radius of interest
  • Rs (float) – scale radius
  • rho0 (float) – density normalization (central core density)
Returns:

rho(R) density

density_2d(x, y, Rs, rho0, r_core, center_x=0, center_y=0)[source]

Projected two dimenstional NFW profile (kappa*Sigma_crit)

Parameters:
  • x (float/numpy array) – radius of interest
  • Rs (float) – scale radius
  • rho0 (float) – density normalization (characteristic density)
Returns:

Epsilon(R) projected density at radius R

density_lens(R, Rs, alpha_Rs, r_core)[source]

Computes the density at 3d radius r given lens model parameterization.

The integral in the LOS projection of this quantity results in the convergence quantity.

derivatives(x, y, Rs, alpha_Rs, r_core, center_x=0, center_y=0)[source]

Deflection angles.

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
function(x, y, Rs, alpha_Rs, r_core, center_x=0, center_y=0)[source]
Parameters:
  • x – angular position
  • y – angular position
  • Rs – angular turn over point
  • alpha_Rs – deflection at Rs (in the absence of a core
  • r_core – core radius
  • center_x – center of halo
  • center_y – center of halo
Returns:

hessian(x, y, Rs, alpha_Rs, r_core, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy.

lower_limit_default = {'Rs': 0, 'alpha_Rs': 0, 'center_x': -100, 'center_y': -100, 'r_core': 0}
mass_2d(R, Rs, rho0, r_core)[source]

Analytic solution of the projection integral (convergence)

mass_3d(R, Rs, rho0, r_core)[source]

Mass enclosed a 3d sphere or radius r.

Parameters:
  • R
  • Rs
  • rho0
  • r_core
Returns:

mass_3d_lens(R, Rs, alpha_Rs, r_core)[source]

Mass enclosed a 3d sphere or radius r given a lens parameterization with angular units.

Returns:
model_name = 'CNFW'
param_names = ['Rs', 'alpha_Rs', 'r_core', 'center_x', 'center_y']
upper_limit_default = {'Rs': 100, 'alpha_Rs': 10, 'center_x': 100, 'center_y': 100, 'r_core': 100}

lenstronomy.LensModel.Profiles.cnfw_ellipse module

class CNFW_ELLIPSE[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains functions concerning the NFW profile.

relation are: R_200 = c * Rs

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

density_lens(R, Rs, alpha_Rs, r_core, e1=0, e2=0)[source]

Computes the density at 3d radius r given lens model parameterization.

The integral in the LOS projection of this quantity results in the convergence quantity.

derivatives(x, y, Rs, alpha_Rs, r_core, e1, e2, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function (integral of NFW)

function(x, y, Rs, alpha_Rs, r_core, e1, e2, center_x=0, center_y=0)[source]

Returns double integral of NFW profile.

hessian(x, y, Rs, alpha_Rs, r_core, e1, e2, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy.

lower_limit_default = {'Rs': 0, 'alpha_Rs': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'r_core': 0}
mass_3d_lens(R, Rs, alpha_Rs, r_core, e1=0, e2=0)[source]

Mass enclosed a 3d sphere or radius r given a lens parameterization with angular units.

Returns:
param_names = ['Rs', 'alpha_Rs', 'r_core', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'Rs': 100, 'alpha_Rs': 10, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'r_core': 100}

lenstronomy.LensModel.Profiles.const_mag module

class ConstMag(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class implements the macromodel potential of Diego et al.

<https://www.aanda.org/articles/aa/pdf/2019/07/aa35490-19.pdf>`_ Convergence and shear are computed according to Diego2018

derivatives(x, y, mu_r, mu_t, parity, phi_G, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coord (in angles)
  • y – y-coord (in angles)
  • mu_r – radial magnification
  • mu_t – tangential magnification
  • parity – parity of the side of the macromodel. Either +1 (positive parity) or -1 (negative parity)
  • phi_G – shear orientation angle (relative to the x-axis)
Returns:

deflection angle (in angles)

function(x, y, mu_r, mu_t, parity, phi_G, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coord (in angles)
  • y – y-coord (in angles)
  • mu_r – radial magnification
  • mu_t – tangential magnification
  • parity – parity side of the macromodel. Either +1 (positive parity) or -1 (negative parity)
  • phi_G – shear orientation angle (relative to the x-axis)
Returns:

lensing potential

hessian(x, y, mu_r, mu_t, parity, phi_G, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coord (in angles)
  • y – y-coord (in angles)
  • mu_r – radial magnification
  • mu_t – tangential magnification
  • parity – parity of the side of the macromodel. Either +1 (positive parity) or -1 (negative parity)
  • phi_G – shear orientation angle (relative to the x-axis)
Returns:

hessian matrix (in angles)

lower_limit_default = {'center_x': -100, 'center_y': -100, 'mu_r': 1, 'mu_t': 1000, 'parity': -1, 'phi_G': 0.0}
param_names = ['center_x', 'center_y', 'mu_r', 'mu_t', 'parity', 'phi_G']
upper_limit_default = {'center_x': 100, 'center_y': 100, 'mu_r': 1, 'mu_t': 1000, 'parity': 1, 'phi_G': 3.141592653589793}

lenstronomy.LensModel.Profiles.constant_shift module

class Shift(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Lens model with a constant shift of the deflection field.

derivatives(x, y, alpha_x, alpha_y)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • alpha_x – shift in x-direction (angle)
  • alpha_y – shift in y-direction (angle)
Returns:

deflection in x- and y-direction

function(x, y, alpha_x, alpha_y)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • alpha_x – shift in x-direction (angle)
  • alpha_y – shift in y-direction (angle)
Returns:

lensing potential

hessian(x, y, alpha_x, alpha_y)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • alpha_x – shift in x-direction (angle)
  • alpha_y – shift in y-direction (angle)
Returns:

hessian elements f_xx, f_xy, f_yx, f_yy

lower_limit_default = {'alpha_x': -1000, 'alpha_y': -1000}
param_names = ['alpha_x', 'alpha_y']
upper_limit_default = {'alpha_x': 1000, 'alpha_y': 1000}

lenstronomy.LensModel.Profiles.convergence module

class Convergence(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

A single mass sheet (external convergence)

derivatives(x, y, kappa, ra_0=0, dec_0=0)[source]

Deflection angle.

Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • kappa – (external) convergence
Returns:

deflection angles (first order derivatives)

function(x, y, kappa, ra_0=0, dec_0=0)[source]

Lensing potential.

Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • kappa – (external) convergence
Returns:

lensing potential

hessian(x, y, kappa, ra_0=0, dec_0=0)[source]

Hessian matrix.

Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • kappa – external convergence
  • ra_0 – zero point of polynomial expansion (no deflection added)
  • dec_0 – zero point of polynomial expansion (no deflection added)
Returns:

second order derivatives f_xx, f_xy, f_yx, f_yy

lower_limit_default = {'dec_0': -100, 'kappa': -10, 'ra_0': -100}
model_name = 'CONVERGENCE'
param_names = ['kappa', 'ra_0', 'dec_0']
upper_limit_default = {'dec_0': 100, 'kappa': 10, 'ra_0': 100}

lenstronomy.LensModel.Profiles.coreBurkert module

class CoreBurkert(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Lensing properties of a modified Burkert profile with variable core size normalized by rho0, the central core density.

cBurkGamma(R, Rs, rho0, r_core, ax_x, ax_y)[source]
Parameters:
  • R – projected distance
  • Rs – scale radius
  • rho0 – central core density
  • r_core – core radius
  • ax_x – x coordinate
  • ax_y – y coordinate
Returns:

cBurkPot(R, Rs, rho0, r_core)[source]
Parameters:
  • R – projected distance
  • Rs – scale radius
  • rho0 – central core density
  • r_core – core radius
coreBurkAlpha(R, Rs, rho0, r_core, ax_x, ax_y)[source]

Deflection angle.

Parameters:
  • R
  • Rs
  • rho0
  • r_core
  • ax_x
  • ax_y
Returns:

density(R, Rs, rho0, r_core)[source]

Three dimensional cored Burkert profile.

Parameters:
  • R (float/numpy array) – radius of interest
  • Rs (float) – scale radius
  • rho0 (float) – characteristic density
Returns:

rho(R) density

density_2d(x, y, Rs, rho0, r_core, center_x=0, center_y=0)[source]

Projected two dimenstional core Burkert profile (kappa*Sigma_crit)

Parameters:
  • x – x coordinate
  • y – y coordinate
  • Rs – scale radius
  • rho0 – central core density
  • r_core – core radius
derivatives(x, y, Rs, alpha_Rs, r_core, center_x=0, center_y=0)[source]

Deflection angles :param x: x coordinate :param y: y coordinate :param Rs: scale radius :param alpha_Rs: deflection angle at Rs :param r_core: core radius :param center_x:

Parameters:center_y
Returns:
function(x, y, Rs, alpha_Rs, r_core, center_x=0, center_y=0)[source]
Parameters:
  • x – angular position
  • y – angular position
  • Rs – angular turn over point
  • alpha_Rs – deflection angle at Rs
  • center_x – center of halo
  • center_y – center of halo
Returns:

hessian(x, y, Rs, alpha_Rs, r_core, center_x=0, center_y=0)[source]
Parameters:
  • x – x coordinate
  • y – y coordinate
  • Rs – scale radius
  • alpha_Rs – deflection angle at Rs
  • r_core – core radius
  • center_x
  • center_y
Returns:

lower_limit_default = {'Rs': 1, 'alpha_Rs': 0, 'center_x': -100, 'center_y': -100, 'r_core': 0.5}
mass_2d(R, Rs, rho0, r_core)[source]

Analytic solution of the projection integral (convergence)

Parameters:
  • R – projected distance
  • Rs – scale radius
  • rho0 – central core density
  • r_core – core radius
mass_3d(R, Rs, rho0, r_core)[source]
Parameters:
  • R – projected distance
  • Rs – scale radius
  • rho0 – central core density
  • r_core – core radius
param_names = ['Rs', 'alpha_Rs', 'r_core', 'center_x', 'center_y']
upper_limit_default = {'Rs': 100, 'alpha_Rs': 100, 'center_x': 100, 'center_y': 100, 'r_core': 50}

lenstronomy.LensModel.Profiles.cored_density module

class CoredDensity(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

class for a uniform cored density dropping steep in the outskirts This profile is e.g. featured in Blum et al. 2020 https://arxiv.org/abs/2001.07182v1

..math::
rho_c(r) = frac{2}{pi} Sigma_{c} R_c^3 left(R_c^2 + r^2 right)^{-2}

with the convergence profile as

..math::
kappa_c(theta) = left(1 + frac{theta^2}{theta_c^2} right)^{-3/2}.

An approximate mass-sheet degeneracy can then be written as

..math::
kappa_{lambda_c}(theta) = lambda_c kappa(theta) + (1-lambda_c) kappa_c(theta).
static alpha_r(r, sigma0, r_core)[source]

Radial deflection angle of the cored density profile.

Parameters:
  • r – radius (angular scale)
  • sigma0 – convergence in the core
  • r_core – core radius
Returns:

deflection angle

static d_alpha_dr(r, sigma0, r_core)[source]

Radial derivatives of the radial deflection angle.

Parameters:
  • r – radius (angular scale)
  • sigma0 – convergence in the core
  • r_core – core radius
Returns:

dalpha/dr

static density(r, sigma0, r_core)[source]

Rho(r) = 2/pi * Sigma_crit R_c**3 * (R_c**2 + r**2)**(-2)

Parameters:
  • r – radius (angular scale)
  • sigma0 – convergence in the core
  • r_core – core radius
Returns:

density at radius r

density_2d(x, y, sigma0, r_core, center_x=0, center_y=0)[source]

Projected density at projected radius r.

Parameters:
  • x – x-coordinate in angular units
  • y – y-coordinate in angular units
  • sigma0 – convergence in the core
  • r_core – core radius
  • center_x – center of the profile
  • center_y – center of the profile
Returns:

projected density

density_lens(r, sigma0, r_core)[source]

Computes the density at 3d radius r given lens model parameterization. The integral in the LOS projection of this quantity results in the convergence quantity.

Parameters:
  • r – radius (angular scale)
  • sigma0 – convergence in the core
  • r_core – core radius
Returns:

desnity at radius r

derivatives(x, y, sigma0, r_core, center_x=0, center_y=0)[source]

Deflection angle of cored density profile.

Parameters:
  • x – x-coordinate in angular units
  • y – y-coordinate in angular units
  • sigma0 – convergence in the core
  • r_core – core radius
  • center_x – center of the profile
  • center_y – center of the profile
Returns:

alpha_x, alpha_y at (x, y)

function(x, y, sigma0, r_core, center_x=0, center_y=0)[source]

Potential of cored density profile.

Parameters:
  • x – x-coordinate in angular units
  • y – y-coordinate in angular units
  • sigma0 – convergence in the core
  • r_core – core radius
  • center_x – center of the profile
  • center_y – center of the profile
Returns:

lensing potential at (x, y)

hessian(x, y, sigma0, r_core, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate in angular units
  • y – y-coordinate in angular units
  • sigma0 – convergence in the core
  • r_core – core radius
  • center_x – center of the profile
  • center_y – center of the profile
Returns:

Hessian df/dxdx, df/dxdy, df/dydx, df/dydy at position (x, y)

static kappa_r(r, sigma0, r_core)[source]

Convergence of the cored density profile. This routine is also for testing.

Parameters:
  • r – radius (angular scale)
  • sigma0 – convergence in the core
  • r_core – core radius
Returns:

convergence at r

lower_limit_default = {'center_x': -100, 'center_y': -100, 'r_core': 0, 'sigma0': -1}
mass_2d(r, sigma0, r_core)[source]

Mass enclosed in cylinder of radius r.

Parameters:
  • r – radius (angular scale)
  • sigma0 – convergence in the core
  • r_core – core radius
Returns:

mass enclosed in cylinder of radius r

static mass_3d(r, sigma0, r_core)[source]

Mass enclosed 3d radius.

Parameters:
  • r – radius (angular scale)
  • sigma0 – convergence in the core
  • r_core – core radius
Returns:

mass enclosed 3d radius

mass_3d_lens(r, sigma0, r_core)[source]

Mass enclosed a 3d sphere or radius r given a lens parameterization with angular units For this profile those are identical.

Parameters:
  • r – radius (angular scale)
  • sigma0 – convergence in the core
  • r_core – core radius
Returns:

mass enclosed 3d radius

param_names = ['sigma0', 'r_core', 'center_x', 'center_y']
upper_limit_default = {'center_x': 100, 'center_y': 100, 'r_core': 100, 'sigma0': 10}

lenstronomy.LensModel.Profiles.cored_density_2 module

class CoredDensity2(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class for a uniform cored density dropping steep in the outskirts credits for suggesting this profile goes to Kfir Blum.

\[\rho(r) = 2/\pi * \Sigma_{\rm crit} R_c^2 * (R_c^2 + r^2)^{-3/2}\]

This profile drops like an NFW profile as math:rho(r)^{-3}.

static alpha_r(r, sigma0, r_core)[source]

Radial deflection angle of the cored density profile.

Parameters:
  • r – radius (angular scale)
  • sigma0 – convergence in the core
  • r_core – core radius
Returns:

deflection angle

static d_alpha_dr(r, sigma0, r_core)[source]

Radial derivatives of the radial deflection angle.

Parameters:
  • r – radius (angular scale)
  • sigma0 – convergence in the core
  • r_core – core radius
Returns:

dalpha/dr

static density(r, sigma0, r_core)[source]

Rho(r) = 2/pi * Sigma_crit R_c**3 * (R_c**2 + r**2)**(-3/2)

Parameters:
  • r – radius (angular scale)
  • sigma0 – convergence in the core
  • r_core – core radius
Returns:

density at radius r

density_2d(x, y, sigma0, r_core, center_x=0, center_y=0)[source]

Projected density at projected radius r.

Parameters:
  • x – x-coordinate in angular units
  • y – y-coordinate in angular units
  • sigma0 – convergence in the core
  • r_core – core radius
  • center_x – center of the profile
  • center_y – center of the profile
Returns:

projected density

density_lens(r, sigma0, r_core)[source]

Computes the density at 3d radius r given lens model parameterization. The integral in the LOS projection of this quantity results in the convergence quantity.

Parameters:
  • r – radius (angular scale)
  • sigma0 – convergence in the core
  • r_core – core radius
Returns:

density at radius r

derivatives(x, y, sigma0, r_core, center_x=0, center_y=0)[source]

Deflection angle of cored density profile.

Parameters:
  • x – x-coordinate in angular units
  • y – y-coordinate in angular units
  • sigma0 – convergence in the core
  • r_core – core radius
  • center_x – center of the profile
  • center_y – center of the profile
Returns:

alpha_x, alpha_y at (x, y)

function(x, y, sigma0, r_core, center_x=0, center_y=0)[source]

Potential of cored density profile.

Parameters:
  • x – x-coordinate in angular units
  • y – y-coordinate in angular units
  • sigma0 – convergence in the core
  • r_core – core radius
  • center_x – center of the profile
  • center_y – center of the profile
Returns:

lensing potential at (x, y)

hessian(x, y, sigma0, r_core, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate in angular units
  • y – y-coordinate in angular units
  • sigma0 – convergence in the core
  • r_core – core radius
  • center_x – center of the profile
  • center_y – center of the profile
Returns:

Hessian df/dxdx, df/dxdy, df/dydx, df/dydy at position (x, y)

static kappa_r(r, sigma0, r_core)[source]

Convergence of the cored density profile. This routine is also for testing.

Parameters:
  • r – radius (angular scale)
  • sigma0 – convergence in the core
  • r_core – core radius
Returns:

convergence at r

lower_limit_default = {'center_x': -100, 'center_y': -100, 'r_core': 0, 'sigma0': -1}
static mass_2d(r, sigma0, r_core)[source]

Mass enclosed in cylinder of radius r.

Parameters:
  • r – radius (angular scale)
  • sigma0 – convergence in the core
  • r_core – core radius
Returns:

mass enclosed in cylinder of radius r

static mass_3d(r, sigma0, r_core)[source]

Mass enclosed 3d radius.

Parameters:
  • r – radius (angular scale)
  • sigma0 – convergence in the core
  • r_core – core radius
Returns:

mass enclosed 3d radius

mass_3d_lens(r, sigma0, r_core)[source]

Mass enclosed a 3d sphere or radius r given a lens parameterization with angular units For this profile those are identical.

Parameters:
  • r – radius (angular scale)
  • sigma0 – convergence in the core
  • r_core – core radius
Returns:

mass enclosed 3d radius

model_name = 'CORED_DENSITY_2'
param_names = ['sigma0', 'r_core', 'center_x', 'center_y']
upper_limit_default = {'center_x': 100, 'center_y': 100, 'r_core': 100, 'sigma0': 10}

lenstronomy.LensModel.Profiles.cored_density_exp module

class CoredDensityExp(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains functions concerning an exponential cored density profile, namely.

..math::
rho(r) = rho_0 exp(- (theta / theta_c)^2)
static alpha_radial(r, kappa_0, theta_c)[source]

Returns the radial part of the deflection angle :param r: angular position (normally in units of arc seconds) :param kappa_0: central convergence of profile :param theta_c: core radius (in arcsec) :return: radial deflection angle.

density(R, kappa_0, theta_c)[source]

Three dimensional density profile in angular units (rho0_physical = rho0_angular Sigma_crit / D_lens)

Parameters:
  • R – projected angular position (normally in units of arc seconds)
  • kappa_0 – central convergence of profile
  • theta_c – core radius (in arcsec)
Returns:

rho(R) density

density_2d(x, y, kappa_0, theta_c, center_x=0, center_y=0)[source]

Projected two dimensional ULDM profile (convergence * Sigma_crit), but given our units convention for rho0, it is basically the convergence.

Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • kappa_0 – central convergence of profile
  • theta_c – core radius (in arcsec)
Returns:

Epsilon(R) projected density at radius R

density_lens(r, kappa_0, theta_c)[source]

Computes the density at 3d radius r given lens model parameterization. The integral in the LOS projection of this quantity results in the convergence quantity.

Parameters:
  • r – angular position (normally in units of arc seconds)
  • kappa_0 – central convergence of profile
  • theta_c – core radius (in arcsec)
Returns:

density rho(r)

derivatives(x, y, kappa_0, theta_c, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function (lensing potential), which are the deflection angles.

Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • kappa_0 – central convergence of profile
  • theta_c – core radius (in arcsec)
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

deflection angle in x, deflection angle in y

function(x, y, kappa_0, theta_c, center_x=0, center_y=0)[source]
Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • kappa_0 – central convergence of profile
  • theta_c – core radius (in arcsec)
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

lensing potential (in arcsec^2)

hessian(x, y, kappa_0, theta_c, center_x=0, center_y=0)[source]
Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • kappa_0 – central convergence of profile
  • theta_c – core radius (in arcsec)
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2

static kappa_r(R, kappa_0, theta_c)[source]

Convergence of the cored density profile. This routine is also for testing.

Parameters:
  • R – radius (angular scale)
  • kappa_0 – convergence in the core
  • theta_c – core radius
Returns:

convergence at r

lower_limit_default = {'center_x': -100, 'center_y': -100, 'kappa_0': 0, 'theta_c': 0}
mass_2d(R, kappa_0, theta_c)[source]

Mass enclosed a 2d sphere of radius r returns.

\[M_{2D} = 2 \pi \int_0^r dr' r' \int dz \rho(\sqrt(r'^2 + z^2))\]
Parameters:
  • kappa_0 – central convergence of soliton
  • theta_c – core radius (in arcsec)
Returns:

M_2D (ULDM only)

static mass_3d(R, kappa_0, theta_c)[source]

Mass enclosed a 3d sphere or radius r :param kappa_0: central convergence of profile :param theta_c: core radius (in arcsec) :param R: radius in arcseconds :return: mass of soliton in angular units.

mass_3d_lens(r, kappa_0, theta_c)[source]

Mass enclosed a 3d sphere or radius r :param kappa_0: central convergence of profile :param theta_c: core radius (in arcsec) :return: mass.

param_names = ['kappa_0', 'theta_c', 'center_x', 'center_y']
static rhotilde(kappa_0, theta_c)[source]

Computes the central density in angular units :param kappa_0: central convergence of profile :param theta_c: core radius (in arcsec) :return: central density in 1/arcsec.

upper_limit_default = {'center_x': 100, 'center_y': 100, 'kappa_0': 10, 'theta_c': 100}

lenstronomy.LensModel.Profiles.cored_density_mst module

class CoredDensityMST(profile_type='CORED_DENSITY')[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Approximate mass-sheet transform of a density core.

This routine takes the parameters of the density core and subtracts a mass-sheet that approximates the cored profile in it’s center to counter-act (in approximation) this model. This allows for better sampling of the mass-sheet transformed quantities that do not have strong covariances. The subtraction of the mass-sheet is done such that the sampler returns the real central convergence of the original model (but be careful, the output of quantities like the Einstein angle of the main deflector are still the not-scaled one). Attention!!! The interpretation of the result is that the mass sheet as ‘CONVERGENCE’ that is present needs to be subtracted in post- processing.

__init__(profile_type='CORED_DENSITY')[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, lambda_approx, r_core, center_x=0, center_y=0)[source]

Deflection angles of approximate mass-sheet correction.

Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • lambda_approx – approximate mass sheet transform
  • r_core – core radius of the cored density profile
  • center_x – x-center of the profile
  • center_y – y-center of the profile
Returns:

alpha_x, alpha_y

function(x, y, lambda_approx, r_core, center_x=0, center_y=0)[source]

Lensing potential of approximate mass-sheet correction.

Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • lambda_approx – approximate mass sheet transform
  • r_core – core radius of the cored density profile
  • center_x – x-center of the profile
  • center_y – y-center of the profile
Returns:

lensing potential correction

hessian(x, y, lambda_approx, r_core, center_x=0, center_y=0)[source]

Hessian terms of approximate mass-sheet correction.

Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • lambda_approx – approximate mass sheet transform
  • r_core – core radius of the cored density profile
  • center_x – x-center of the profile
  • center_y – y-center of the profile
Returns:

df/dxx, df/dxy, df/dyx, df/dyy

lower_limit_default = {'center_x': -100, 'center_y': -100, 'lambda_approx': -1, 'r_core': 0}
param_names = ['lambda_approx', 'r_core', 'center_x', 'center_y']
upper_limit_default = {'center_x': 100, 'center_y': 100, 'lambda_approx': 10, 'r_core': 100}

lenstronomy.LensModel.Profiles.cored_steep_ellipsoid module

class CSE(axis='product_avg')[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Cored steep ellipsoid (CSE) :param axis: ‘major’ or ‘product_avg’ ; whether to evaluate corresponding to r= major axis or r= sqrt(ab) source: Keeton and Kochanek (1998) Oguri 2021: https://arxiv.org/pdf/2106.11464.pdf

\[\kappa(u;s) = \frac{A}{2(s^2 + \xi^2)^{3/2}}\]

with

\[\xi(x, y) = \sqrt{x^2 + \frac{y^2}{q^2}}\]
__init__(axis='product_avg')[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, a, s, e1, e2, center_x, center_y)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • a – lensing strength
  • s – core radius
  • e1 – eccentricity
  • e2 – eccentricity
  • center_x – center of profile
  • center_y – center of profile
Returns:

deflection in x- and y-direction

function(x, y, a, s, e1, e2, center_x, center_y)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • a – lensing strength
  • s – core radius
  • e1 – eccentricity
  • e2 – eccentricity
  • center_x – center of profile
  • center_y – center of profile
Returns:

lensing potential

hessian(x, y, a, s, e1, e2, center_x, center_y)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • a – lensing strength
  • s – core radius
  • e1 – eccentricity
  • e2 – eccentricity
  • center_x – center of profile
  • center_y – center of profile
Returns:

hessian elements f_xx, f_xy, f_yx, f_yy

lower_limit_default = {'A': -1000, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 's': 0}
param_names = ['A', 's', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'A': 1000, 'center_x': -100, 'center_y': -100, 'e1': 0.5, 'e2': 0.5, 's': 10000}
class CSEMajorAxis(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Cored steep ellipsoid (CSE) along the major axis source: Keeton and Kochanek (1998) Oguri 2021: https://arxiv.org/pdf/2106.11464.pdf

\[\kappa(u;s) = \frac{A}{2(s^2 + \xi^2)^{3/2}}\]

with

\[\xi(x, y) = \sqrt{x^2 + \frac{y^2}{q^2}}\]
derivatives(x, y, a, s, q)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • a – lensing strength
  • s – core radius
  • q – axis ratio
Returns:

deflection in x- and y-direction

function(x, y, a, s, q)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • a – lensing strength
  • s – core radius
  • q – axis ratio
Returns:

lensing potential

hessian(x, y, a, s, q)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • a – lensing strength
  • s – core radius
  • q – axis ratio
Returns:

hessian elements f_xx, f_xy, f_yx, f_yy

lower_limit_default = {'A': -1000, 'center_x': -100, 'center_y': -100, 'q': 0.001, 's': 0}
param_names = ['A', 's', 'q', 'center_x', 'center_y']
upper_limit_default = {'A': 1000, 'center_x': -100, 'center_y': -100, 'e2': 0.5, 'q': 0.99999, 's': 10000}
class CSEMajorAxisSet[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

A set of CSE profiles along a joint center and axis.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, a_list, s_list, q)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • a_list – list of lensing strength
  • s_list – list of core radius
  • q – axis ratio
Returns:

deflection in x- and y-direction

function(x, y, a_list, s_list, q)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • a_list – list of lensing strength
  • s_list – list of core radius
  • q – axis ratio
Returns:

lensing potential

hessian(x, y, a_list, s_list, q)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • a_list – list of lensing strength
  • s_list – list of core radius
  • q – axis ratio
Returns:

hessian elements f_xx, f_xy, f_yx, f_yy

class CSEProductAvg[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Cored steep ellipsoid (CSE) evaluated at the product-averaged radius sqrt(ab), such that mass is not changed when increasing ellipticity.

Same as CSEMajorAxis but evaluated at r=sqrt(q)*r_original

Keeton and Kochanek (1998) Oguri 2021: https://arxiv.org/pdf/2106.11464.pdf

\[\kappa(u;s) = \frac{A}{2(s^2 + \xi^2)^{3/2}}\]

with

\[\xi(x, y) = \sqrt{qx^2 + \frac{y^2}{q}}\]
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, a, s, q)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • a – lensing strength
  • s – core radius
  • q – axis ratio
Returns:

deflection in x- and y-direction

function(x, y, a, s, q)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • a – lensing strength
  • s – core radius
  • q – axis ratio
Returns:

lensing potential

hessian(x, y, a, s, q)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • a – lensing strength
  • s – core radius
  • q – axis ratio
Returns:

hessian elements f_xx, f_xy, f_yx, f_yy

lower_limit_default = {'A': -1000, 'center_x': -100, 'center_y': -100, 'q': 0.001, 's': 0}
param_names = ['A', 's', 'q', 'center_x', 'center_y']
upper_limit_default = {'A': 1000, 'center_x': -100, 'center_y': -100, 'e2': 0.5, 'q': 0.99999, 's': 10000}
class CSEProductAvgSet[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

A set of CSE profiles along a joint center and axis.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, a_list, s_list, q)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • a_list – list of lensing strength
  • s_list – list of core radius
  • q – axis ratio
Returns:

deflection in x- and y-direction

function(x, y, a_list, s_list, q)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • a_list – list of lensing strength
  • s_list – list of core radius
  • q – axis ratio
Returns:

lensing potential

hessian(x, y, a_list, s_list, q)[source]
Parameters:
  • x – coordinate in image plane (angle)
  • y – coordinate in image plane (angle)
  • a_list – list of lensing strength
  • s_list – list of core radius
  • q – axis ratio
Returns:

hessian elements f_xx, f_xy, f_yx, f_yy

lenstronomy.LensModel.Profiles.curved_arc_const module

class CurvedArcConstMST[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Lens model that describes a section of a highly magnified deflector region. The parameterization is chosen to describe local observables efficient.

Observables are: - curvature radius (basically bending relative to the center of the profile) - radial stretch (plus sign) thickness of arc with parity (more generalized than the power-law slope) - tangential stretch (plus sign). Infinity means at critical curve - direction of curvature - position of arc

Requirements: - Should work with other perturbative models without breaking its meaning (say when adding additional shear terms) - Must best reflect the observables in lensing - minimal covariances between the parameters, intuitive parameterization.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, tangential_stretch, radial_stretch, curvature, direction, center_x, center_y)[source]
Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

function(x, y, tangential_stretch, radial_stretch, curvature, direction, center_x, center_y)[source]

ATTENTION: there may not be a global lensing potential!

Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

hessian(x, y, tangential_stretch, radial_stretch, curvature, direction, center_x, center_y)[source]
Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

lower_limit_default = {'center_x': -100, 'center_y': -100, 'curvature': 1e-06, 'direction': -3.141592653589793, 'radial_stretch': -5, 'tangential_stretch': -100}
param_names = ['tangential_stretch', 'radial_stretch', 'curvature', 'direction', 'center_x', 'center_y']
upper_limit_default = {'center_x': 100, 'center_y': 100, 'curvature': 100, 'direction': 3.141592653589793, 'radial_stretch': 5, 'tangential_stretch': 100}
class CurvedArcConst(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Curved arc lensing with orientation of curvature perpendicular to the x-axis with unity radial stretch.

derivatives(x, y, tangential_stretch, curvature, direction, center_x, center_y)[source]
Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

function(x, y, tangential_stretch, curvature, direction, center_x, center_y)[source]

ATTENTION: there may not be a global lensing potential!

Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

hessian(x, y, tangential_stretch, curvature, direction, center_x, center_y)[source]
Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

lower_limit_default = {'center_x': -100, 'center_y': -100, 'curvature': 1e-06, 'direction': -3.141592653589793, 'tangential_stretch': -100}
param_names = ['tangential_stretch', 'curvature', 'direction', 'center_x', 'center_y']
upper_limit_default = {'center_x': 100, 'center_y': 100, 'curvature': 100, 'direction': 3.141592653589793, 'tangential_stretch': 100}

lenstronomy.LensModel.Profiles.curved_arc_sis_mst module

class CurvedArcSISMST[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Lens model that describes a section of a highly magnified deflector region. The parameterization is chosen to describe local observables efficient.

Observables are: - curvature radius (basically bending relative to the center of the profile) - radial stretch (plus sign) thickness of arc with parity (more generalized than the power-law slope) - tangential stretch (plus sign). Infinity means at critical curve - direction of curvature - position of arc

Requirements: - Should work with other perturbative models without breaking its meaning (say when adding additional shear terms) - Must best reflect the observables in lensing - minimal covariances between the parameters, intuitive parameterization.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, tangential_stretch, radial_stretch, curvature, direction, center_x, center_y)[source]
Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

function(x, y, tangential_stretch, radial_stretch, curvature, direction, center_x, center_y)[source]

ATTENTION: there may not be a global lensing potential!

Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

hessian(x, y, tangential_stretch, radial_stretch, curvature, direction, center_x, center_y)[source]
Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

lower_limit_default = {'center_x': -100, 'center_y': -100, 'curvature': 1e-06, 'direction': -3.141592653589793, 'radial_stretch': -5, 'tangential_stretch': -100}
param_names = ['tangential_stretch', 'radial_stretch', 'curvature', 'direction', 'center_x', 'center_y']
static sis_mst2stretch(theta_E, kappa_ext, center_x_sis, center_y_sis, center_x, center_y)[source]

Turn Singular power-law lens model into stretch parameterization at position (center_x, center_y) This is the inverse function of stretch2spp()

Parameters:
  • theta_E – Einstein radius of SIS profile
  • kappa_ext – external convergence (MST factor 1 - kappa_ext)
  • center_x_sis – center of SPP model
  • center_y_sis – center of SPP model
  • center_x – center of curved model definition
  • center_y – center of curved model definition
Returns:

tangential_stretch, radial_stretch, curvature, direction

Returns:

static stretch2sis_mst(tangential_stretch, radial_stretch, curvature, direction, center_x, center_y)[source]
Parameters:
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

parameters in terms of a spherical SIS + MST resulting in the same observables

upper_limit_default = {'center_x': 100, 'center_y': 100, 'curvature': 100, 'direction': 3.141592653589793, 'radial_stretch': 5, 'tangential_stretch': 100}

lenstronomy.LensModel.Profiles.curved_arc_spp module

class CurvedArcSPP[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Lens model that describes a section of a highly magnified deflector region. The parameterization is chosen to describe local observables efficient.

Observables are: - curvature radius (basically bending relative to the center of the profile) - radial stretch (plus sign) thickness of arc with parity (more generalized than the power-law slope) - tangential stretch (plus sign). Infinity means at critical curve - direction of curvature - position of arc

Requirements: - Should work with other perturbative models without breaking its meaning (say when adding additional shear terms) - Must best reflect the observables in lensing - minimal covariances between the parameters, intuitive parameterization.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, tangential_stretch, radial_stretch, curvature, direction, center_x, center_y)[source]
Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

function(x, y, tangential_stretch, radial_stretch, curvature, direction, center_x, center_y)[source]

ATTENTION: there may not be a global lensing potential!

Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

hessian(x, y, tangential_stretch, radial_stretch, curvature, direction, center_x, center_y)[source]
Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

lower_limit_default = {'center_x': -100, 'center_y': -100, 'curvature': 1e-06, 'direction': -3.141592653589793, 'radial_stretch': -5, 'tangential_stretch': -100}
param_names = ['tangential_stretch', 'radial_stretch', 'curvature', 'direction', 'center_x', 'center_y']
static spp2stretch(theta_E, gamma, center_x_spp, center_y_spp, center_x, center_y)[source]

Turn Singular power-law lens model into stretch parameterization at position (center_x, center_y) This is the inverse function of stretch2spp()

Parameters:
  • theta_E – Einstein radius of SPP model
  • gamma – power-law slope
  • center_x_spp – center of SPP model
  • center_y_spp – center of SPP model
  • center_x – center of curved model definition
  • center_y – center of curved model definition
Returns:

tangential_stretch, radial_stretch, curvature, direction

static stretch2spp(tangential_stretch, radial_stretch, curvature, direction, center_x, center_y)[source]
Parameters:
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

parameters in terms of a spherical power-law profile resulting in the same observables

upper_limit_default = {'center_x': 100, 'center_y': 100, 'curvature': 100, 'direction': 3.141592653589793, 'radial_stretch': 5, 'tangential_stretch': 100}
center_deflector(curvature, direction, center_x, center_y)[source]
Parameters:
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

center_spp_x, center_spp_y

lenstronomy.LensModel.Profiles.curved_arc_spt module

class CurvedArcSPT[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Curved arc model based on SIS+MST with an additional non-linear shear distortions applied on the source coordinates around the center.

This profile is effectively a Source Position Transform of a curved arc and a shear distortion.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, tangential_stretch, radial_stretch, curvature, direction, gamma1, gamma2, center_x, center_y)[source]
Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • gamma1 – non-linear reduced shear distortion in the source plane
  • gamma2 – non-linear reduced shear distortion in the source plane
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

function(x, y, tangential_stretch, radial_stretch, curvature, direction, gamma1, gamma2, center_x, center_y)[source]

ATTENTION: there may not be a global lensing potential!

Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • gamma1 – non-linear reduced shear distortion in the source plane
  • gamma2 – non-linear reduced shear distortion in the source plane
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

hessian(x, y, tangential_stretch, radial_stretch, curvature, direction, gamma1, gamma2, center_x, center_y)[source]
Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • gamma1 – non-linear reduced shear distortion in the source plane
  • gamma2 – non-linear reduced shear distortion in the source plane
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

lower_limit_default = {'center_x': -100, 'center_y': -100, 'curvature': 1e-06, 'direction': -3.141592653589793, 'gamma1': -0.5, 'gamma2': -0.5, 'radial_stretch': -5, 'tangential_stretch': -100}
param_names = ['tangential_stretch', 'radial_stretch', 'curvature', 'direction', 'gamma1', 'gamma2', 'center_x', 'center_y']
upper_limit_default = {'center_x': 100, 'center_y': 100, 'curvature': 100, 'direction': 3.141592653589793, 'gamma1': 0.5, 'gamma2': 0.5, 'radial_stretch': 5, 'tangential_stretch': 100}

lenstronomy.LensModel.Profiles.curved_arc_tan_diff module

class CurvedArcTanDiff[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Curved arc model with an additional non-zero tangential stretch differential in tangential direction component.

Observables are: - curvature radius (basically bending relative to the center of the profile) - radial stretch (plus sign) thickness of arc with parity (more generalized than the power-law slope) - tangential stretch (plus sign). Infinity means at critical curve - direction of curvature - position of arc

Requirements: - Should work with other perturbative models without breaking its meaning (say when adding additional shear terms) - Must best reflect the observables in lensing - minimal covariances between the parameters, intuitive parameterization.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, tangential_stretch, radial_stretch, curvature, dtan_dtan, direction, center_x, center_y)[source]
Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • dtan_dtan – d(tangential_stretch) / d(tangential direction) / tangential stretch
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

function(x, y, tangential_stretch, radial_stretch, curvature, dtan_dtan, direction, center_x, center_y)[source]

ATTENTION: there may not be a global lensing potential!

Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • dtan_dtan – d(tangential_stretch) / d(tangential direction) / tangential stretch
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

hessian(x, y, tangential_stretch, radial_stretch, curvature, dtan_dtan, direction, center_x, center_y)[source]
Parameters:
  • x
  • y
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • direction – float, angle in radian
  • dtan_dtan – d(tangential_stretch) / d(tangential direction) / tangential stretch
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

lower_limit_default = {'center_x': -100, 'center_y': -100, 'curvature': 1e-06, 'direction': -3.141592653589793, 'dtan_dtan': -10, 'radial_stretch': -5, 'tangential_stretch': -100}
param_names = ['tangential_stretch', 'radial_stretch', 'curvature', 'dtan_dtan', 'direction', 'center_x', 'center_y']
static stretch2sie_mst(tangential_stretch, radial_stretch, curvature, dtan_dtan, direction, center_x, center_y)[source]
Parameters:
  • tangential_stretch – float, stretch of intrinsic source in tangential direction
  • radial_stretch – float, stretch of intrinsic source in radial direction
  • curvature – 1/curvature radius
  • dtan_dtan – d(tangential_stretch) / d(tangential direction) / tangential stretch
  • direction – float, angle in radian
  • center_x – center of source in image plane
  • center_y – center of source in image plane
Returns:

parameters in terms of a spherical SIS + MST resulting in the same observables

upper_limit_default = {'center_x': 100, 'center_y': 100, 'curvature': 100, 'direction': 3.141592653589793, 'dtan_dtan': 10, 'radial_stretch': 5, 'tangential_stretch': 100}

lenstronomy.LensModel.Profiles.dipole module

class Dipole(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class for dipole response of two massive bodies (experimental)

derivatives(x, y, com_x, com_y, phi_dipole, coupling)[source]

Deflection angles.

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
function(x, y, com_x, com_y, phi_dipole, coupling)[source]

Lensing potential (only needed for specific calculations, such as time delays)

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
hessian(x, y, com_x, com_y, phi_dipole, coupling)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
lower_limit_default = {'com_x': -100, 'com_y': -100, 'coupling': -10, 'phi_dipole': -10}
param_names = ['com_x', 'com_y', 'phi_dipole', 'coupling']
upper_limit_default = {'com_x': 100, 'com_y': 100, 'coupling': 10, 'phi_dipole': 10}
class DipoleUtil[source]

Bases: object

Pre-calculation of dipole properties.

static angle(center1_x, center1_y, center2_x, center2_y)[source]

Compute the rotation angle of the dipole :return:

static com(center1_x, center1_y, center2_x, center2_y, Fm)[source]
Returns:center of mass
static mass_ratio(theta_E, theta_E_sub)[source]

Computes mass ration of the two clumps with given Einstein radius and power law slope (clump1/sub-clump) :param theta_E:

Parameters:theta_E_sub
Returns:

lenstronomy.LensModel.Profiles.elliptical_density_slice module

class ElliSLICE(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class computes the lensing quantities for an elliptical slice of constant density. Based on Schramm 1994 https://ui.adsabs.harvard.edu/abs/1994A%26A…284…44S/abstract

Computes the lensing quantities of an elliptical slice with semi major axis ‘a’ and semi minor axis ‘b’, centered on ‘center_x’ and ‘center_y’, oriented with an angle ‘psi’ in radian, and with constant surface mass density ‘sigma_0’. In other words, this lens model is characterized by the surface mass density :

..math::
kappa(x,y) = left{
begin{array}{ll}
sigma_0 & mbox{if } frac{x_{rot}^2}{a^2} + frac{y_{rot}^2}{b^2} leq 1 0 & mbox{else}

end{array}

right}.

with

..math::
x_{rot} = x_c cos psi + y_c sin psi y_{rot} = - x_c sin psi + y_c cos psi x_c = x - center_x y_c = y - center_y
alpha_ext(x, y, kwargs_slice)[source]

Deflection angle for (x,y) outside the elliptical slice.

Parameters:kwargs_slice – dict, dictionary with the slice definition (a,b,psi,sigma_0)
alpha_in(x, y, kwargs_slice)[source]

Deflection angle for (x,y) inside the elliptical slice.

Parameters:kwargs_slice – dict, dictionary with the slice definition (a,b,psi,sigma_0)
derivatives(x, y, a, b, psi, sigma_0, center_x=0.0, center_y=0.0)[source]

Lensing deflection angle.

Parameters:
  • a – float, semi-major axis, must be positive
  • b – float, semi-minor axis, must be positive
  • psi – float, orientation in radian
  • sigma_0 – float, surface mass density, must be positive
  • center_x – float, center on the x axis
  • center_y – float, center on the y axis
function(x, y, a, b, psi, sigma_0, center_x=0.0, center_y=0.0)[source]

Lensing potential.

Parameters:
  • a – float, semi-major axis, must be positive
  • b – float, semi-minor axis, must be positive
  • psi – float, orientation in radian
  • sigma_0 – float, surface mass density, must be positive
  • center_x – float, center on the x axis
  • center_y – float, center on the y axis
hessian(x, y, a, b, psi, sigma_0, center_x=0.0, center_y=0.0)[source]

Lensing second derivatives.

Parameters:
  • a – float, semi-major axis, must be positive
  • b – float, semi-minor axis, must be positive
  • psi – float, orientation in radian
  • sigma_0 – float, surface mass density, must be positive
  • center_x – float, center on the x axis
  • center_y – float, center on the y axis
lower_limit_default = {'a': 0.0, 'b': 0.0, 'center_x': -100.0, 'center_y': -100.0, 'psi': -1.5707963267948966}
param_names = ['a', 'b', 'psi', 'sigma_0', 'center_x', 'center_y']
pot_ext(x, y, kwargs_slice)[source]

Lensing potential for (x,y) outside the elliptical slice.

Parameters:kwargs_slice – dict, dictionary with the slice definition (a,b,psi,sigma_0)
static pot_in(x, y, kwargs_slice)[source]

Lensing potential for (x,y) inside the elliptical slice.

Parameters:kwargs_slice – dict, dictionary with the slice definition (a,b,psi,sigma_0)
static sign(z)[source]

Sign function.

Parameters:z – complex
upper_limit_default = {'a': 100.0, 'b': 100.0, 'center_x': 100.0, 'center_y': 100.0, 'psi': 1.5707963267948966}

lenstronomy.LensModel.Profiles.epl module

class EPL[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Elliptical Power Law mass profile.

\[\kappa(x, y) = \frac{3-\gamma}{2} \left(\frac{\theta_{E}}{\sqrt{q x^2 + y^2/q}} \right)^{\gamma-1}\]

with \(\theta_{E}\) is the (circularized) Einstein radius, \(\gamma\) is the negative power-law slope of the 3D mass distributions, \(q\) is the minor/major axis ratio, and \(x\) and \(y\) are defined in a coordinate system aligned with the major and minor axis of the lens.

In terms of eccentricities, this profile is defined as

\[\kappa(r) = \frac{3-\gamma}{2} \left(\frac{\theta'_{E}}{r \sqrt{1 - e*\cos(2*\phi)}} \right)^{\gamma-1}\]

with \(\epsilon\) is the ellipticity defined as

\[\epsilon = \frac{1-q^2}{1+q^2}\]

And an Einstein radius \(\theta'_{\rm E}\) related to the definition used is

\[\left(\frac{\theta'_{\rm E}}{\theta_{\rm E}}\right)^{2} = \frac{2q}{1+q^2}.\]

The mathematical form of the calculation is presented by Tessore & Metcalf (2015), https://arxiv.org/abs/1507.01819. The current implementation is using hyperbolic functions. The paper presents an iterative calculation scheme, converging in few iterations to high precision and accuracy.

A (faster) implementation of the same model using numba is accessible as ‘EPL_NUMBA’ with the iterative calculation scheme. An alternative implementation of the same model using a fortran code FASTELL is implemented as ‘PEMD’ profile.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

density_lens(r, theta_E, gamma, e1=None, e2=None)[source]

Computes the density at 3d radius r given lens model parameterization. The integral in the LOS projection of this quantity results in the convergence quantity.

Parameters:
  • r – radius within the mass is computed
  • theta_E – Einstein radius
  • gamma – power-law slope
  • e1 – eccentricity component (not used)
  • e2 – eccentricity component (not used)
Returns:

mass enclosed a 3D radius r

derivatives(x, y, theta_E, gamma, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate in image plane
  • y – y-coordinate in image plane
  • theta_E – Einstein radius
  • gamma – power law slope
  • e1 – eccentricity component
  • e2 – eccentricity component
  • center_x – profile center
  • center_y – profile center
Returns:

alpha_x, alpha_y

function(x, y, theta_E, gamma, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate in image plane
  • y – y-coordinate in image plane
  • theta_E – Einstein radius
  • gamma – power law slope
  • e1 – eccentricity component
  • e2 – eccentricity component
  • center_x – profile center
  • center_y – profile center
Returns:

lensing potential

hessian(x, y, theta_E, gamma, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate in image plane
  • y – y-coordinate in image plane
  • theta_E – Einstein radius
  • gamma – power law slope
  • e1 – eccentricity component
  • e2 – eccentricity component
  • center_x – profile center
  • center_y – profile center
Returns:

f_xx, f_xy, f_yx, f_yy

lower_limit_default = {'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'gamma': 1.5, 'theta_E': 0}
mass_3d_lens(r, theta_E, gamma, e1=None, e2=None)[source]

Computes the spherical power-law mass enclosed (with SPP routine)

Parameters:
  • r – radius within the mass is computed
  • theta_E – Einstein radius
  • gamma – power-law slope
  • e1 – eccentricity component (not used)
  • e2 – eccentricity component (not used)
Returns:

mass enclosed a 3D radius r.

param_conv(theta_E, gamma, e1, e2)[source]

Converts parameters as defined in this class to the parameters used in the EPLMajorAxis() class.

Parameters:
  • theta_E – Einstein radius as defined in the profile class
  • gamma – negative power-law slope
  • e1 – eccentricity modulus
  • e2 – eccentricity modulus
Returns:

b, t, q, phi_G

param_names = ['theta_E', 'gamma', 'e1', 'e2', 'center_x', 'center_y']
set_dynamic()[source]
Returns:
set_static(theta_E, gamma, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • theta_E – Einstein radius
  • gamma – power law slope
  • e1 – eccentricity component
  • e2 – eccentricity component
  • center_x – profile center
  • center_y – profile center
Returns:

self variables set

upper_limit_default = {'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'gamma': 2.5, 'theta_E': 100}
class EPLMajorAxis[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains the function and the derivatives of the elliptical power law.

\[\kappa = (2-t)/2 * \left[\frac{b}{\sqrt{q^2 x^2 + y^2}}\right]^t\]

where with \(t = \gamma - 1\) (from EPL class) being the projected power-law slope of the convergence profile, critical radius b, axis ratio q.

Tessore & Metcalf (2015), https://arxiv.org/abs/1507.01819

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, b, t, q)[source]

Returns the deflection angles.

Parameters:
  • x – x-coordinate in image plane relative to center (major axis)
  • y – y-coordinate in image plane relative to center (minor axis)
  • b – critical radius
  • t – projected power-law slope
  • q – axis ratio
Returns:

f_x, f_y

function(x, y, b, t, q)[source]

Returns the lensing potential.

Parameters:
  • x – x-coordinate in image plane relative to center (major axis)
  • y – y-coordinate in image plane relative to center (minor axis)
  • b – critical radius
  • t – projected power-law slope
  • q – axis ratio
Returns:

lensing potential

hessian(x, y, b, t, q)[source]

Hessian matrix of the lensing potential.

Parameters:
  • x – x-coordinate in image plane relative to center (major axis)
  • y – y-coordinate in image plane relative to center (minor axis)
  • b – critical radius
  • t – projected power-law slope
  • q – axis ratio
Returns:

f_xx, f_yy, f_xy

param_names = ['b', 't', 'q', 'center_x', 'center_y']
class EPLQPhi[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class to model a EPL sampling over q and phi instead of e1 and e2.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

density_lens(r, theta_E, gamma, q=None, phi=None)[source]

Computes the density at 3d radius r given lens model parameterization. The integral in the LOS projection of this quantity results in the convergence quantity.

Parameters:
  • r – radius within the mass is computed
  • theta_E – Einstein radius
  • gamma – power-law slope
  • q – axis ratio (not used)
  • phi – position angle (not used)
Returns:

mass enclosed a 3D radius r

derivatives(x, y, theta_E, gamma, q, phi, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate in image plane
  • y – y-coordinate in image plane
  • theta_E – Einstein radius
  • gamma – power law slope
  • q – axis ratio
  • phi – position angle
  • center_x – profile center
  • center_y – profile center
Returns:

alpha_x, alpha_y

function(x, y, theta_E, gamma, q, phi, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate in image plane
  • y – y-coordinate in image plane
  • theta_E – Einstein radius
  • gamma – power law slope
  • q – axis ratio
  • phi – position angle
  • center_x – profile center
  • center_y – profile center
Returns:

lensing potential

hessian(x, y, theta_E, gamma, q, phi, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate in image plane
  • y – y-coordinate in image plane
  • theta_E – Einstein radius
  • gamma – power law slope
  • q – axis ratio
  • phi – position angle
  • center_x – profile center
  • center_y – profile center
Returns:

f_xx, f_xy, f_yx, f_yy

lower_limit_default = {'center_x': -100, 'center_y': -100, 'gamma': 1.5, 'phi': -3.141592653589793, 'q': 0, 'theta_E': 0}
mass_3d_lens(r, theta_E, gamma, q=None, phi=None)[source]

Computes the spherical power-law mass enclosed (with SPP routine).

Parameters:
  • r – radius within the mass is computed
  • theta_E – Einstein radius
  • gamma – power-law slope
  • q – axis ratio (not used)
  • phi – position angle (not used)
Returns:

mass enclosed a 3D radius r.

param_names = ['theta_E', 'gamma', 'q', 'phi', 'center_x', 'center_y']
upper_limit_default = {'center_x': 100, 'center_y': 100, 'gamma': 2.5, 'phi': 3.141592653589793, 'q': 1, 'theta_E': 100}

lenstronomy.LensModel.Profiles.epl_numba module

class EPL_numba[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

” Elliptical Power Law mass profile - computation accelerated with numba

\[\kappa(x, y) = \frac{3-\gamma}{2} \left(\frac{\theta_{E}}{\sqrt{q x^2 + y^2/q}} \right)^{\gamma-1}\]

with \(\theta_{E}\) is the (circularized) Einstein radius, \(\gamma\) is the negative power-law slope of the 3D mass distributions, \(q\) is the minor/major axis ratio, and \(x\) and \(y\) are defined in a coordinate system aligned with the major and minor axis of the lens.

In terms of eccentricities, this profile is defined as

\[\kappa(r) = \frac{3-\gamma}{2} \left(\frac{\theta'_{E}}{r \sqrt{1 − e*\cos(2*\phi)}} \right)^{\gamma-1}\]

with \(\epsilon\) is the ellipticity defined as

\[\epsilon = \frac{1-q^2}{1+q^2}\]

And an Einstein radius \(\theta'_{\rm E}\) related to the definition used is

\[\left(\frac{\theta'_{\rm E}}{\theta_{\rm E}}\right)^{2} = \frac{2q}{1+q^2}.\]

The mathematical form of the calculation is presented by Tessore & Metcalf (2015), https://arxiv.org/abs/1507.01819. The current implementation is using hyperbolic functions. The paper presents an iterative calculation scheme, converging in few iterations to high precision and accuracy.

A (slower) implementation of the same model using hyperbolic functions without the iterative calculation is accessible as ‘EPL’ not requiring numba.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y-coordinate (angle)
  • theta_E – Einstein radius (angle), pay attention to specific definition!
  • gamma – logarithmic slope of the power-law profile. gamma=2 corresponds to isothermal
  • e1 – eccentricity component
  • e2 – eccentricity component
  • center_x – x-position of lens center
  • center_y – y-position of lens center
Returns:

deflection angles alpha_x, alpha_y

function[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y-coordinate (angle)
  • theta_E – Einstein radius (angle), pay attention to specific definition!
  • gamma – logarithmic slope of the power-law profile. gamma=2 corresponds to isothermal
  • e1 – eccentricity component
  • e2 – eccentricity component
  • center_x – x-position of lens center
  • center_y – y-position of lens center
Returns:

lensing potential

hessian[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y-coordinate (angle)
  • theta_E – Einstein radius (angle), pay attention to specific definition!
  • gamma – logarithmic slope of the power-law profile. gamma=2 corresponds to isothermal
  • e1 – eccentricity component
  • e2 – eccentricity component
  • center_x – x-position of lens center
  • center_y – y-position of lens center
Returns:

Hessian components f_xx, f_yy, f_xy

lower_limit_default = {'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'gamma': 1.5, 'theta_E': 0}
param_names = ['theta_E', 'gamma', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'gamma': 2.5, 'theta_E': 100}

lenstronomy.LensModel.Profiles.flexion module

class Flexion(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class for flexion.

derivatives(x, y, g1, g2, g3, g4, ra_0=0, dec_0=0)[source]

Deflection angles.

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
function(x, y, g1, g2, g3, g4, ra_0=0, dec_0=0)[source]

Lensing potential (only needed for specific calculations, such as time delays)

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
hessian(x, y, g1, g2, g3, g4, ra_0=0, dec_0=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
lower_limit_default = {'dec_0': -100, 'g1': -0.1, 'g2': -0.1, 'g3': -0.1, 'g4': -0.1, 'ra_0': -100}
param_names = ['g1', 'g2', 'g3', 'g4', 'ra_0', 'dec_0']
upper_limit_default = {'dec_0': 100, 'g1': 0.1, 'g2': 0.1, 'g3': 0.1, 'g4': 0.1, 'ra_0': 100}

lenstronomy.LensModel.Profiles.flexionfg module

class Flexionfg[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Flexion consist of basis F flexion and G flexion (F1,F2,G1,G2), see formulas 2.54, 2.55 in Massimo Meneghetti 2017 - “Introduction to Gravitational Lensing”.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, F1, F2, G1, G2, ra_0=0, dec_0=0)[source]

Deflection angle.

Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • F1 – F1 flexion, derivative of kappa in x direction
  • F2 – F2 flexion, derivative of kappa in y direction
  • G1 – G1 flexion
  • G2 – G2 flexion
  • ra_0 – center x-coordinate
  • dec_0 – center x-coordinate
Returns:

deflection angle.

function(x, y, F1, F2, G1, G2, ra_0=0, dec_0=0)[source]

Lensing potential.

Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • F1 – F1 flexion, derivative of kappa in x direction
  • F2 – F2 flexion, derivative of kappa in y direction
  • G1 – G1 flexion
  • G2 – G2 flexion
  • ra_0 – center x-coordinate
  • dec_0 – center y-coordinate
Returns:

lensing potential

hessian(x, y, F1, F2, G1, G2, ra_0=0, dec_0=0)[source]

Hessian matrix.

Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • F1 – F1 flexion, derivative of kappa in x direction
  • F2 – F2 flexion, derivative of kappa in y direction
  • G1 – G1 flexion
  • G2 – G2 flexion
  • ra_0 – center x-coordinate
  • dec_0 – center y-coordinate
Returns:

second order derivatives f_xx, f_yy, f_xy

lower_limit_default = {'F1': -0.1, 'F2': -0.1, 'G1': -0.1, 'G2': -0.1, 'dec_0': -100, 'ra_0': -100}
param_names = ['F1', 'F2', 'G1', 'G2', 'ra_0', 'dec_0']
static transform_fg(F1, F2, G1, G2)[source]

Basis transform from (F1,F2,G1,G2) to (g1,g2,g3,g4).

Parameters:
  • F1 – F1 flexion, derivative of kappa in x direction
  • F2 – F2 flexion, derivative of kappa in y direction
  • G1 – G1 flexion
  • G2 – G2 flexion
Returns:

g1,g2,g3,g4 (phi_xxx, phi_xxy, phi_xyy, phi_yyy)

upper_limit_default = {'F1': 0.1, 'F2': 0.1, 'G1': 0.1, 'G2': 0.1, 'dec_0': 100, 'ra_0': 100}

lenstronomy.LensModel.Profiles.gauss_decomposition module

This module contains the class to compute lensing properties of any elliptical profile using Shajib (2019)’s Gauss decomposition.

class GaussianEllipseKappaSet(use_scipy_wofz=True, min_ellipticity=1e-05)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class computes the lensing properties of a set of concentric elliptical Gaussian convergences.

__init__(use_scipy_wofz=True, min_ellipticity=1e-05)[source]
Parameters:
  • use_scipy_wofz (bool) – To initiate class GaussianEllipseKappa. If True, Gaussian lensing will use scipy.special.wofz function. Set False for lower precision, but faster speed.
  • min_ellipticity (float) – To be passed to class GaussianEllipseKappa. Minimum ellipticity for Gaussian elliptical lensing calculation. For lower ellipticity than min_ellipticity the equations for the spherical case will be used.
density_2d(x, y, amp, sigma, e1, e2, center_x=0, center_y=0)[source]

Compute the density of a set of concentric elliptical Gaussian convergence profiles \(\sum A/(2\pi \sigma^2) \exp(-( x^2+y^2/q^2)/2\sigma^2)\).

Parameters:
  • x (float or numpy.array) – x coordinate
  • y (float or numpy.array) – y coordinate
  • amp (numpy.array with dtype=float) – Amplitude of Gaussian, convention: \(A/(2 \pi\sigma^2) \exp(-(x^2+y^2/q^2)/2\sigma^2)\)
  • sigma (numpy.array with dtype=float) – Standard deviation of Gaussian
  • e1 (float) – Ellipticity parameter 1
  • e2 (float) – Ellipticity parameter 2
  • center_x (float) – x coordinate of centroid
  • center_y (float) – y coordianate of centroid
Returns:

Density \(\kappa\) for elliptical Gaussian convergence

Return type:

float, or numpy.array with shape equal to x.shape

derivatives(x, y, amp, sigma, e1, e2, center_x=0, center_y=0)[source]

Compute the derivatives of function angles \(\partial f/\partial x\), \(\partial f/\partial y\) at \(x,\ y\) for a set of concentric elliptic Gaussian convergence profiles.

Parameters:
  • x (float or numpy.array) – x coordinate
  • y (float or numpy.array) – y coordinate
  • amp (numpy.array with dtype=float) – Amplitude of Gaussian, convention: \(A/(2 \pi\sigma^2) \exp(-(x^2+y^2/q^2)/2\sigma^2)\)
  • sigma (numpy.array with dtype=float) – Standard deviation of Gaussian
  • e1 (float) – Ellipticity parameter 1
  • e2 (float) – Ellipticity parameter 2
  • center_x (float) – x coordinate of centroid
  • center_y (float) – y coordianate of centroid
Returns:

Deflection angle \(\partial f/\partial x\), \(\partial f/\partial y\) for elliptical Gaussian convergence

Return type:

tuple (float, float) or (numpy.array, numpy.array) with each numpy array’s shape equal to x.shape

function(x, y, amp, sigma, e1, e2, center_x=0, center_y=0)[source]

Compute the potential function for a set of concentric elliptical Gaussian convergence profiles.

Parameters:
  • x (float or numpy.array) – x coordinate
  • y (float or numpy.array) – y coordinate
  • amp (numpy.array with dtype=float) – Amplitude of Gaussian, convention: \(A/(2 \pi\sigma^2) \exp(-(x^2+y^2/q^2)/2\sigma^2)\)
  • sigma (numpy.array with dtype=float) – Standard deviation of Gaussian
  • e1 (float) – Ellipticity parameter 1
  • e2 (float) – Ellipticity parameter 2
  • center_x (float) – x coordinate of centroid
  • center_y (float) – y coordianate of centroid
Returns:

Potential for elliptical Gaussian convergence

Return type:

float, or numpy.array with shape = x.shape

hessian(x, y, amp, sigma, e1, e2, center_x=0, center_y=0)[source]

Compute Hessian matrix of function \(\partial^2f/\partial x^2\), \(\partial^2 f/\partial y^2\), \(\partial^2 f/\partial x\partial y\) for a set of concentric elliptic Gaussian convergence profiles.

Parameters:
  • x (float or numpy.array) – x coordinate
  • y (float or numpy.array) – y coordinate
  • amp (numpy.array with dtype=float) – Amplitude of Gaussian, convention: \(A/(2 \pi\sigma^2) \exp(-(x^2+y^2/q^2)/2\sigma^2)\)
  • sigma (numpy.array with dtype=float) – Standard deviation of Gaussian
  • e1 (float) – Ellipticity parameter 1
  • e2 (float) – Ellipticity parameter 2
  • center_x (float) – x coordinate of centroid
  • center_y (float) – y coordianate of centroid
Returns:

Hessian \(\partial^2f/\partial x^2\), \(\partial^2/\partial x\partial y\), \(\partial^2/\partial y\partial x\), \(\partial^2 f/\partial y^2\) for elliptical Gaussian convergence.

Return type:

tuple (float, float, float) , or (numpy.array, numpy.array, numpy.array) with each numpy array’s shape equal to x.shape

lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'sigma': 0}
param_names = ['amp', 'sigma', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'amp': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'sigma': 100}
class GaussDecompositionAbstract(n_sigma=15, sigma_start_mult=0.02, sigma_end_mult=15.0, precision=10, use_scipy_wofz=True, min_ellipticity=1e-05)[source]

Bases: object

This abstract class sets up a template for computing lensing properties of an elliptical convergence through Shajib (2019)’s Gauss decomposition.

__init__(n_sigma=15, sigma_start_mult=0.02, sigma_end_mult=15.0, precision=10, use_scipy_wofz=True, min_ellipticity=1e-05)[source]

Set up settings for the Gaussian decomposition. For more details about the decomposition parameters, see Shajib (2019).

Parameters:
  • n_sigma (int) – Number of Gaussian components
  • sigma_start_mult (float) – Lower range of logarithmically spaced sigmas
  • sigma_end_mult (float) – Upper range of logarithmically spaced sigmas
  • precision (int) – Numerical precision of Gaussian decomposition
  • use_scipy_wofz (bool) – To be passed to class GaussianEllipseKappa. If True, Gaussian lensing will use scipy.special.wofz function. Set False for lower precision, but faster speed.
  • min_ellipticity (float) – To be passed to class GaussianEllipseKappa. Minimum ellipticity for Gaussian elliptical lensing calculation. For lower ellipticity than min_ellipticity the equations for the spherical case will be used.
density_2d(x, y, e1=0.0, e2=0.0, center_x=0.0, center_y=0.0, **kwargs)[source]

Compute the convergence profile for Gauss-decomposed elliptic Sersic profile.

Parameters:
  • x (float or numpy.array) – x coordinate
  • y (float or numpy.array) – y coordinate
  • e1 (float) – Ellipticity parameter 1
  • e2 (float) – Ellipticity parameter 2
  • center_x (float) – x coordinate of centroid
  • center_y (float) – y coordinate of centroid
  • kwargs – Keyword arguments that are defined by the child class that are particular for the convergence profile in the child class.
Returns:

Convergence profile

Return type:

type(x)

derivatives(x, y, e1=0.0, e2=0.0, center_x=0.0, center_y=0.0, **kwargs)[source]

Compute the derivatives of the deflection potential \(\partial f/\partial x\), \(\partial f/\partial y\) for a Gauss-decomposed elliptic convergence.

Parameters:
  • x (float or numpy.array) – x coordinate
  • y (float or numpy.array) – y coordinate
  • e1 (float) – Ellipticity parameter 1
  • e2 (float) – Ellipticity parameter 2
  • center_x (float) – x coordinate of centroid
  • center_y (float) – y coordinate of centroid
  • kwargs – Keyword arguments that are defined by the child class that are particular for the convergence profile
Returns:

Derivatives of deflection potential

Return type:

tuple (type(x), type(x))

function(x, y, e1=0.0, e2=0.0, center_x=0.0, center_y=0.0, **kwargs)[source]

Compute the deflection potential of a Gauss-decomposed elliptic convergence.

Parameters:
  • x (float) – x coordinate
  • y (float) – y coordinate
  • e1 (float) – Ellipticity parameter 1
  • e2 (float) – Ellipticity parameter 2
  • center_x (float) – x coordinate of centroid
  • center_y (float) – y coordinate of centroid
  • kwargs – Keyword arguments that are defined by the child class that are particular for the convergence profile
Returns:

Deflection potential

Return type:

float

gauss_decompose(**kwargs)[source]

Compute the amplitudes and sigmas of Gaussian components using the integral transform with Gaussian kernel from Shajib (2019). The returned values are in the convention of eq. (2.13).

Parameters:kwargs – Keyword arguments to send to func
Returns:Amplitudes and standard deviations of the Gaussian components
Return type:tuple (numpy.array, numpy.array)
get_kappa_1d(y, **kwargs)[source]

Abstract method to compute the spherical Sersic profile at y. The concrete method has to defined by the child class.

Parameters:
  • y (float or numpy.array) – y coordinate
  • kwargs – Keyword arguments that are defined by the child class that are particular for the convergence profile
get_scale(**kwargs)[source]

Abstract method to identify the keyword argument for the scale size among the profile parameters of the child class’ convergence profile.

Parameters:kwargs – Keyword arguments
Returns:Scale size
Return type:float
hessian(x, y, e1=0.0, e2=0.0, center_x=0.0, center_y=0.0, **kwargs)[source]

Compute the Hessian of the deflection potential \(\partial^2f/\partial x^2\), \(\partial^2 f/ \partial y^2\), \(\partial^2 f/\partial x\partial y\) of a Gauss-decomposed elliptic Sersic convergence.

Parameters:
  • x (float or numpy.array) – x coordinate
  • y (float or numpy.array) – y coordinate
  • e1 (float) – Ellipticity parameter 1
  • e2 (float) – Ellipticity parameter 2
  • center_x (float) – x coordinate of centroid
  • center_y (float) – y coordinate of centroid
  • kwargs – Keyword arguments that are defined by the child class that are particular for the convergence profile
Returns:

Hessian of deflection potential

Return type:

tuple (type(x), type(x), type(x))

class SersicEllipseGaussDec(n_sigma=15, sigma_start_mult=0.02, sigma_end_mult=15.0, precision=10, use_scipy_wofz=True, min_ellipticity=1e-05)[source]

Bases: lenstronomy.LensModel.Profiles.gauss_decomposition.GaussDecompositionAbstract

This class computes the lensing properties of an elliptical Sersic profile using the Shajib (2019)’s Gauss decomposition method.

get_kappa_1d(y, **kwargs)[source]

Compute the spherical Sersic profile at y.

Parameters:
  • y (float) – y coordinate
  • kwargs – Keyword arguments
Keyword Arguments:
 
  • n_sersic (float) – Sersic index
  • R_sersic (float) – Sersic scale radius
  • k_eff (float) – Sersic convergence at R_sersic
Returns:

Sersic function at y

Return type:

type(y)

get_scale(**kwargs)[source]

Identify the scale size from the keyword arguments.

Parameters:

kwargs – Keyword arguments

Keyword Arguments:
 
  • n_sersic (float) – Sersic index
  • R_sersic (float) – Sersic scale radius
  • k_eff (float) – Sersic convergence at R_sersic
Returns:

Sersic radius

Return type:

float

lower_limit_default = {'R_sersic': 0.0, 'center_x': -100.0, 'center_y': -100.0, 'e1': -0.5, 'e2': -0.5, 'k_eff': 0.0, 'n_sersic': 0.5}
param_names = ['k_eff', 'R_sersic', 'n_sersic', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'R_sersic': 100.0, 'center_x': 100.0, 'center_y': 100.0, 'e1': 0.5, 'e2': 0.5, 'k_eff': 100.0, 'n_sersic': 8.0}
class NFWEllipseGaussDec(n_sigma=15, sigma_start_mult=0.005, sigma_end_mult=50.0, precision=10, use_scipy_wofz=True, min_ellipticity=1e-05)[source]

Bases: lenstronomy.LensModel.Profiles.gauss_decomposition.GaussDecompositionAbstract

This class computes the lensing properties of an elliptical, projected NFW profile using Shajib (2019)’s Gauss decomposition method.

__init__(n_sigma=15, sigma_start_mult=0.005, sigma_end_mult=50.0, precision=10, use_scipy_wofz=True, min_ellipticity=1e-05)[source]

Set up settings for the Gaussian decomposition. For more details about the decomposition parameters, see Shajib (2019).

Parameters:
  • n_sigma (int) – Number of Gaussian components
  • sigma_start_mult (float) – Lower range of logarithmically spaced sigmas
  • sigma_end_mult (float) – Upper range of logarithmically spaced sigmas
  • precision (int) – Numerical precision of Gaussian decomposition
  • use_scipy_wofz (bool) – To be passed to class GaussianEllipseKappa. If True, Gaussian lensing will use scipy.special.wofz function. Set False for lower precision, but faster speed.
  • min_ellipticity (float) – To be passed to class GaussianEllipseKappa. Minimum ellipticity for Gaussian elliptical lensing calculation. For lower ellipticity than min_ellipticity the equations for the spherical case will be used.
get_kappa_1d(y, **kwargs)[source]

Compute the spherical projected NFW profile at y.

Parameters:
  • y (float) – y coordinate
  • kwargs – Keyword arguments
Keyword Arguments:
 
  • alpha_Rs (float) – Deflection angle at Rs
  • R_s (float) – NFW scale radius
Returns:

projected NFW profile at y

Return type:

type(y)

get_scale(**kwargs)[source]

Identify the scale size from the keyword arguments.

Parameters:

kwargs – Keyword arguments

Keyword Arguments:
 
  • alpha_Rs (float) – Deflection angle at Rs
  • R_s (float) – NFW scale radius
Returns:

NFW scale radius

Return type:

float

lower_limit_default = {'Rs': 0, 'alpha_Rs': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5}
param_names = ['Rs', 'alpha_Rs', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'Rs': 100, 'alpha_Rs': 10, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5}
class GaussDecompositionAbstract3D(n_sigma=15, sigma_start_mult=0.02, sigma_end_mult=15.0, precision=10, use_scipy_wofz=True, min_ellipticity=1e-05)[source]

Bases: lenstronomy.LensModel.Profiles.gauss_decomposition.GaussDecompositionAbstract

This abstract class sets up a template for computing lensing properties of a convergence from 3D spherical profile through Shajib (2019)’s Gauss decomposition.

gauss_decompose(**kwargs)[source]

Compute the amplitudes and sigmas of Gaussian components using the integral transform with Gaussian kernel from Shajib (2019). The returned values are in the convention of eq. (2.13).

Parameters:kwargs – Keyword arguments to send to func
Returns:Amplitudes and standard deviations of the Gaussian components
Return type:tuple (numpy.array, numpy.array)
class CTNFWGaussDec(n_sigma=15, sigma_start_mult=0.01, sigma_end_mult=20.0, precision=10, use_scipy_wofz=True)[source]

Bases: lenstronomy.LensModel.Profiles.gauss_decomposition.GaussDecompositionAbstract3D

This class computes the lensing properties of an projection from a spherical cored-truncated NFW profile using Shajib (2019)’s Gauss decomposition method.

__init__(n_sigma=15, sigma_start_mult=0.01, sigma_end_mult=20.0, precision=10, use_scipy_wofz=True)[source]

Set up settings for the Gaussian decomposition. For more details about the decomposition parameters, see Shajib (2019).

Parameters:
  • n_sigma (int) – Number of Gaussian components
  • sigma_start_mult (float) – Lower range of logarithmically spaced sigmas
  • sigma_end_mult (float) – Upper range of logarithmically spaced sigmas
  • precision (int) – Numerical precision of Gaussian decomposition
  • use_scipy_wofz (bool) – To be passed to class GaussianEllipseKappa. If True, Gaussian lensing will use scipy.special.wofz function. Set False for lower precision, but faster speed.
get_kappa_1d(y, **kwargs)[source]

Compute the spherical cored-truncated NFW profile at y.

Parameters:
  • y (float) – y coordinate
  • kwargs – Keyword arguments
Keyword Arguments:
 
  • r_s (float) – Scale radius
  • r_trunc (float) – Truncation radius
  • r_core (float) – Core radius
  • rho_s (float) – Density normalization
  • a (float) – Core regularization parameter
Returns:

projected NFW profile at y

Return type:

type(y)

get_scale(**kwargs)[source]

Identify the scale size from the keyword arguments.

Parameters:

kwargs – Keyword arguments

Keyword Arguments:
 
  • r_s (float) – Scale radius
  • r_trunc (float) – Truncation radius
  • r_core (float) – Core radius
  • rho_s (float) – Density normalization
  • a (float) – Core regularization parameter
Returns:

NFW scale radius

Return type:

float

lower_limit_default = {'a': 0.0, 'center_x': -100, 'center_y': -100, 'r_core': 0, 'r_s': 0, 'r_trunc': 0, 'rho_s': 0}
param_names = ['r_s', 'r_core', 'r_trunc', 'a', 'rho_s', 'center_xcenter_y']
upper_limit_default = {'a': 10.0, 'center_x': 100, 'center_y': 100, 'r_core': 100, 'r_s': 100, 'r_trunc': 100, 'rho_s': 1000}

lenstronomy.LensModel.Profiles.gaussian_ellipse_kappa module

This module defines class GaussianEllipseKappa to compute the lensing properties of an elliptical Gaussian profile with ellipticity in the convergence using the formulae from Shajib (2019).

class GaussianEllipseKappa(use_scipy_wofz=True, min_ellipticity=1e-05)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains functions to evaluate the derivative and hessian matrix of the deflection potential for an elliptical Gaussian convergence.

The formulae are from Shajib (2019).

__init__(use_scipy_wofz=True, min_ellipticity=1e-05)[source]

Setup which method to use the Faddeeva function and the ellipticity limit for spherical approximation.

Parameters:
  • use_scipy_wofz (bool) – If True, use scipy.special.wofz.
  • min_ellipticity (float) – Minimum allowed ellipticity. For q > 1 - min_ellipticity, values for spherical case will be returned.
density_2d(x, y, amp, sigma, e1, e2, center_x=0, center_y=0)[source]

Compute the density of elliptical Gaussian \(A/(2 \pi \sigma^2) \exp(-(x^2+y^2/q^2)/2\sigma^2)\).

Parameters:
  • x (float or numpy.array) – x coordinate.
  • y (float or numpy.array) – y coordinate.
  • amp (float) – Amplitude of Gaussian, convention: \(A/(2 \pi\sigma^2) \exp(-(x^2+y^2/q^2)/2\sigma^2)\)
  • sigma (float) – Standard deviation of Gaussian.
  • e1 (float) – Ellipticity parameter 1.
  • e2 (float) – Ellipticity parameter 2.
  • center_x (float) – x coordinate of centroid.
  • center_y (float) – y coordianate of centroid.
Returns:

Density \(\kappa\) for elliptical Gaussian convergence.

Return type:

float, or numpy.array with shape = x.shape.

derivatives(x, y, amp, sigma, e1, e2, center_x=0, center_y=0)[source]

Compute the derivatives of function angles \(\partial f/\partial x\), \(\partial f/\partial y\) at \(x,\ y\).

Parameters:
  • x (float or numpy.array) – x coordinate
  • y (float or numpy.array) – y coordinate
  • amp (float) – Amplitude of Gaussian, convention: \(A/(2 \pi\sigma^2) \exp(-(x^2+y^2/q^2)/2\sigma^2)\)
  • sigma (float) – Standard deviation of Gaussian
  • e1 (float) – Ellipticity parameter 1
  • e2 (float) – Ellipticity parameter 2
  • center_x (float) – x coordinate of centroid
  • center_y (float) – y coordianate of centroid
Returns:

Deflection angle \(\partial f/\partial x\), \(\partial f/\partial y\) for elliptical Gaussian convergence.

Return type:

tuple (float, float) or (numpy.array, numpy.array) with each numpy.array’s shape equal to x.shape.

function(x, y, amp, sigma, e1, e2, center_x=0, center_y=0)[source]

Compute the potential function for elliptical Gaussian convergence.

Parameters:
  • x (float or numpy.array) – x coordinate
  • y (float or numpy.array) – y coordinate
  • amp (float) – Amplitude of Gaussian, convention: \(A/(2 \pi\sigma^2) \exp(-(x^2+y^2/q^2)/2\sigma^2)\)
  • sigma (float) – Standard deviation of Gaussian
  • e1 (float) – Ellipticity parameter 1
  • e2 (float) – Ellipticity parameter 2
  • center_x (float) – x coordinate of centroid
  • center_y (float) – y coordianate of centroid
Returns:

Potential for elliptical Gaussian convergence

Return type:

float, or numpy.array with shape equal to x.shape

hessian(x, y, amp, sigma, e1, e2, center_x=0, center_y=0)[source]

Compute Hessian matrix of function \(\partial^2f/\partial x^2\), \(\partial^2 f/\partial y^2\), \(\partial^2/\partial x\partial y\).

Parameters:
  • x (float or numpy.array) – x coordinate
  • y (float or numpy.array) – y coordinate
  • amp (float) – Amplitude of Gaussian, convention: \(A/(2 \pi\sigma^2) \exp(-(x^2+y^2/q^2)/2\sigma^2)\)
  • sigma (float) – Standard deviation of Gaussian
  • e1 (float) – Ellipticity parameter 1
  • e2 (float) – Ellipticity parameter 2
  • center_x (float) – x coordinate of centroid
  • center_y (float) – y coordianate of centroid
Returns:

Hessian \(A/(2 \pi \sigma^2) \exp(-(x^2+y^2/q^2)/2\sigma^2)\) for elliptical Gaussian convergence.

Return type:

tuple (float, float, float) , or (numpy.array, numpy.array, numpy.array) with each numpy.array’s shape equal to x.shape.

lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'sigma': 0}
param_names = ['amp', 'sigma', 'e1', 'e2', 'center_x', 'center_y']
static sgn(z)[source]

Compute the sign function \(\mathrm{sgn}(z)\) factor for deflection as sugggested by Bray (1984). For current implementation, returning 1 is sufficient.

Parameters:z (complex) – Complex variable \(z = x + \mathrm{i}y\)
Returns:\(\mathrm{sgn}(z)\)
Return type:float
sigma_function(x, y, q)[source]

Compute the function \(\varsigma (z; q)\) from equation (4.12) of Shajib (2019).

Parameters:
  • x (float or numpy.array) – Real part of complex variable, \(x = \mathrm{Re}(z)\)
  • y (float or numpy.array) – Imaginary part of complex variable, \(y = \mathrm{Im}(z)\)
  • q (float) – Axis ratio
Returns:

real and imaginary part of \(\varsigma(z; q)\) function

Return type:

tuple (type(x), type(x))

upper_limit_default = {'amp': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'sigma': 100}
static w_f_approx(z)[source]

Compute the Faddeeva function \(w_{\mathrm F}(z)\) using the approximation given in Zaghloul (2017).

Parameters:z (complex or numpy.array(dtype=complex)) – complex number
Returns:\(w_\mathrm{F}(z)\)
Return type:complex

lenstronomy.LensModel.Profiles.gaussian_ellipse_potential module

class GaussianEllipsePotential[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains functions to evaluate a Gaussian function and calculates its derivative and hessian matrix with ellipticity in the convergence.

the calculation follows Glenn van de Ven et al. 2009

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

density(r, amp, sigma, e1, e2)[source]
Parameters:
  • r
  • amp
  • sigma
Returns:

density_2d(x, y, amp, sigma, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x
  • y
  • amp
  • sigma
  • e1
  • e2
  • center_x
  • center_y
Returns:

derivatives(x, y, amp, sigma, e1, e2, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function.

function(x, y, amp, sigma, e1, e2, center_x=0, center_y=0)[source]

Returns Gaussian.

hessian(x, y, amp, sigma, e1, e2, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'sigma': 0}
mass_2d(R, amp, sigma, e1, e2)[source]
Parameters:
  • R
  • amp
  • sigma
  • e1
  • e2
Returns:

mass_2d_lens(R, amp, sigma, e1, e2)[source]
Parameters:
  • R
  • amp
  • sigma
  • e1
  • e2
Returns:

mass_3d(R, amp, sigma, e1, e2)[source]
Parameters:
  • R
  • amp
  • sigma
  • e1
  • e2
Returns:

mass_3d_lens(R, amp, sigma, e1, e2)[source]
Parameters:
  • R
  • amp
  • sigma
  • e1
  • e2
Returns:

param_names = ['amp', 'sigma', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'amp': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'sigma': 100}

lenstronomy.LensModel.Profiles.gaussian_kappa module

class GaussianKappa[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains functions to evaluate a Gaussian function and calculates its derivative and hessian matrix.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

alpha_abs(R, amp, sigma)[source]

Absolute value of the deflection.

Parameters:
  • R
  • amp
  • sigma
Returns:

d_alpha_dr(R, amp, sigma_x, sigma_y)[source]
Parameters:
  • R
  • amp
  • sigma_x
  • sigma_y
Returns:

density(r, amp, sigma)[source]
Parameters:
  • r
  • amp
  • sigma
Returns:

density_2d(x, y, amp, sigma, center_x=0, center_y=0)[source]
Parameters:
  • x
  • y
  • amp
  • sigma
  • center_x
  • center_y
Returns:

derivatives(x, y, amp, sigma, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function.

function(x, y, amp, sigma, center_x=0, center_y=0)[source]

Returns Gaussian.

hessian(x, y, amp, sigma, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'sigma': 0}
mass_2d(R, amp, sigma)[source]
Parameters:
  • R
  • amp
  • sigma
Returns:

mass_2d_lens(R, amp, sigma)[source]
Parameters:
  • R
  • amp
  • sigma
Returns:

mass_3d(R, amp, sigma)[source]
Parameters:
  • R
  • amp
  • sigma
Returns:

mass_3d_lens(R, amp, sigma)[source]
Parameters:
  • R
  • amp
  • sigma
Returns:

param_names = ['amp', 'sigma', 'center_x', 'center_y']
upper_limit_default = {'amp': 100, 'center_x': 100, 'center_y': 100, 'sigma': 100}

lenstronomy.LensModel.Profiles.gaussian_potential module

class Gaussian(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains functions to evaluate a Gaussian function and calculates its derivative and hessian matrix.

derivatives(x, y, amp, sigma_x, sigma_y, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function.

function(x, y, amp, sigma_x, sigma_y, center_x=0, center_y=0)[source]

Returns Gaussian.

hessian(x, y, amp, sigma_x, sigma_y, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'sigma': 0}
param_names = ['amp', 'sigma_x', 'sigma_y', 'center_x', 'center_y']
upper_limit_default = {'amp': 100, 'center_x': 100, 'center_y': 100, 'sigma': 100}

lenstronomy.LensModel.Profiles.general_nfw module

class GNFW(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains a double power law profile with flexible inner and outer logarithmic slopes g and n.

\[\rho(r) = \frac{\rho_0}{r^{\gamma}} \frac{Rs^{n}}{\left(r^2 + Rs^2 \right)^{(n - \gamma)/2}}\]

For g = 1.0 and n=3, it is approximately the same as an NFW profile The original reference is [1].

[1]Munoz, Kochanek and Keeton, (2001), astro-ph/0103009, doi:10.1086/322314

TODO: implement the gravitational potential for this profile

alpha2rho0(alpha_Rs, Rs, gamma_inner, gamma_outer)[source]

Convert angle at Rs into rho0.

Parameters:
  • alpha_Rs – deflection angle at RS
  • Rs – scale radius
  • gamma_inner – logarithmic profile slope interior to Rs
  • gamma_outer – logarithmic profile slope outside Rs
Returns:

density normalization (characteristic density)

static density(R, Rs, rho0, gamma_inner, gamma_outer)[source]

Three dimensional NFW profile.

Parameters:
  • R – radius of interest
  • rho0 – central density normalization
  • gamma_inner – logarithmic profile slope interior to Rs
  • gamma_outer – logarithmic profile slope outside Rs
Returns:

rho(R) density

density_2d(x, y, Rs, rho0, gamma_inner, gamma_outer, center_x=0, center_y=0)[source]

Projected two dimensional profile.

Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • Rs – turn over point in the slope of the NFW profile in angular unit
  • rho0 – density normalization at Rs
  • gamma_inner – logarithmic profile slope interior to Rs
  • gamma_outer – logarithmic profile slope outside Rs
  • center_x – profile center (same units as x)
  • center_y – profile center (same units as x)
Returns:

Epsilon(R) projected density at radius R

density_lens(r, Rs, alpha_Rs, gamma_inner, gamma_outer)[source]

Computes the density at 3d radius r given lens model parameterization. The integral in the LOS projection of this quantity results in the convergence quantity.

Parameters:
  • r – 3d radios
  • Rs – scale radius
  • alpha_Rs – deflection at Rs
  • gamma_inner – logarithmic profile slope interior to Rs
  • gamma_outer – logarithmic profile slope outside Rs
Returns:

density rho(r)

derivatives(x, y, Rs, alpha_Rs, gamma_inner, gamma_outer, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function which are the deflection angles.

Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • Rs – turn over point in the slope of the NFW profile in angular unit
  • alpha_Rs – deflection (angular units) at projected Rs
  • gamma_inner – logarithmic profile slope interior to Rs
  • gamma_outer – logarithmic profile slope outside Rs
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

deflection angle in x, deflection angle in y

hessian(x, y, Rs, alpha_Rs, gamma_inner, gamma_outer, center_x=0, center_y=0)[source]
Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • Rs – turn over point in the slope of the NFW profile in angular unit
  • alpha_Rs – deflection (angular units) at projected Rs
  • gamma_inner – logarithmic profile slope interior to Rs
  • gamma_outer – logarithmic profile slope outside Rs
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2

lower_limit_default = {'Rs': 0, 'alpha_Rs': 0, 'center_x': -100, 'center_y': -100, 'gamma_inner': 0.1, 'gamma_outer': 1.0}
mass_2d(R, Rs, rho0, gamma_inner, gamma_outer)[source]

Mass enclosed a 2d cylinder or projected radius R.

Parameters:
  • R – 3d radius
  • Rs – scale radius
  • rho0 – central density normalization
  • gamma_inner – logarithmic profile slope interior to Rs
  • gamma_outer – logarithmic profile slope outside Rs
Returns:

mass in cylinder

static mass_3d(r, Rs, rho0, gamma_inner, gamma_outer)[source]

Mass enclosed a 3d sphere or radius r.

Parameters:
  • r – 3d radius
  • Rs – scale radius
  • rho0 – density normalization
  • gamma_inner – logarithmic profile slope interior to Rs
  • gamma_outer – logarithmic profile slope outside Rs
Returns:

M(<r)

mass_3d_lens(r, Rs, alpha_Rs, gamma_inner, gamma_outer)[source]

Mass enclosed a 3d sphere or radius r. This function takes as input the lensing parameterization.

Parameters:
  • r – 3d radius
  • Rs – scale radius
  • alpha_Rs – deflection angle at Rs
  • gamma_inner – logarithmic profile slope interior to Rs
  • gamma_outer – logarithmic profile slope outside Rs
Returns:

M(<r)

nfwAlpha(R, Rs, rho0, gamma_inner, gamma_outer, ax_x, ax_y)[source]

Deflection angel of NFW profile (times Sigma_crit D_OL) along the projection to coordinate ‘axis’.

Parameters:
  • R – 3d radius
  • Rs – scale radius
  • rho0 – central density normalization
  • gamma_inner – logarithmic profile slope interior to Rs
  • gamma_outer – logarithmic profile slope outside Rs
  • ax_x – x coordinate relative to center
  • ax_y – y coordinate relative to center
Returns:

Epsilon(R) projected density at radius R

nfwGamma(R, Rs, rho0, gamma_inner, gamma_outer, ax_x, ax_y)[source]

Shear gamma of NFW profile (times Sigma_crit) along the projection to coordinate ‘axis’.

Parameters:
  • R – 3d radius
  • Rs – scale radius
  • rho0 – central density normalization
  • gamma_inner – logarithmic profile slope interior to Rs
  • gamma_outer – logarithmic profile slope outside Rs
  • ax_x – x coordinate relative to center
  • ax_y – y coordinate relative to center
Returns:

Epsilon(R) projected density at radius R

param_names = ['Rs', 'alpha_Rs', 'center_x', 'center_y', 'gamma_inner', 'gamma_outer']
profile_name = 'GNFW'
rho02alpha(rho0, Rs, gamma_inner, gamma_outer)[source]

Convert rho0 to angle at Rs.

Parameters:
  • rho0 – density normalization (characteristic density)
  • Rs – scale radius
  • gamma_inner – logarithmic profile slope interior to Rs
  • gamma_outer – logarithmic profile slope outside Rs
Returns:

deflection angle at RS

upper_limit_default = {'Rs': 100, 'alpha_Rs': 10, 'center_x': 100, 'center_y': 100, 'gamma_inner': 2.9, 'gamma_outer': 10.0}

lenstronomy.LensModel.Profiles.hernquist module

class Hernquist(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class to compute the Hernquist 1990 model, which is in 3d: rho(r) = rho0 / (r/Rs * (1 + (r/Rs))**3)

in lensing terms, the normalization parameter ‘sigma0’ is defined such that the deflection at projected RS leads to alpha = 2./3 * Rs * sigma0

>>> from lenstronomy.Cosmo.lens_cosmo import LensCosmo
>>> from astropy.cosmology import FlatLambdaCDM
>>> cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Ob0=0.05)
>>> lens_cosmo = LensCosmo(z_lens=0.5, z_source=1.5, cosmo=cosmo)

Here we compute the angular scale of Rs on the sky (in arc seconds) and the deflection the normalization sigma0 from the total stellar mass in M_sol and Rs in [Mpc]:

>>> sigma0, rs_angle = lens_cosmo.hernquist_phys2angular(mass=10**11, rs=0.02)

And here we perform the inverse calculation given Rs_angle and alpha_Rs to return the physical halo properties.

>>> m_tot, rs = lens_cosmo.hernquist_angular2phys(sigma0=sigma0 rs_angle=rs_angle)

The lens model calculation uses angular units as arguments! So to execute a deflection angle calculation one uses

>>> from lenstronomy.LensModel.Profiles.hernquist import Hernquist
>>> hernquist = Hernquist()
>>> alpha_x, alpha_y = hernquist.derivatives(x=1, y=1, Rs=rs_angle, sigma0=sigma0, center_x=0, center_y=0)
static density(r, rho0, Rs)[source]

Computes the 3-d density.

Parameters:
  • r – 3-d radius
  • rho0 – density normalization
  • Rs – Hernquist radius
Returns:

density at radius r

density_2d(x, y, rho0, Rs, center_x=0, center_y=0)[source]

Projected density along the line of sight at coordinate (x, y)

Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • rho0 – density normalization
  • Rs – Hernquist radius
  • center_x – x-center of the profile
  • center_y – y-center of the profile
Returns:

projected density

density_lens(r, sigma0, Rs)[source]

Density as a function of 3d radius in lensing parameters This function converts the lensing definition sigma0 into the 3d density.

Parameters:
  • r – 3d radius
  • sigma0 – rho0 * Rs (units of projected density)
  • Rs – Hernquist radius
Returns:

enclosed mass in 3d

derivatives(x, y, sigma0, Rs, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate position (units of angle)
  • y – y-coordinate position (units of angle)
  • sigma0 – normalization parameter defined such that the deflection at projected RS leads to alpha = 2./3 * Rs * sigma0
  • Rs – Hernquist radius in units of angle
  • center_x – x-center of the profile (units of angle)
  • center_y – y-center of the profile (units of angle)
Returns:

derivative of function (deflection angles in x- and y-direction)

function(x, y, sigma0, Rs, center_x=0, center_y=0)[source]

Lensing potential.

Parameters:
  • x – x-coordinate position (units of angle)
  • y – y-coordinate position (units of angle)
  • sigma0 – normalization parameter defined such that the deflection at projected RS leads to alpha = 2./3 * Rs * sigma0
  • Rs – Hernquist radius in units of angle
  • center_x – x-center of the profile (units of angle)
  • center_y – y-center of the profile (units of angle)
Returns:

lensing potential at (x,y)

grav_pot(x, y, rho0, Rs, center_x=0, center_y=0)[source]

#TODO decide whether these functions are needed or not

gravitational potential (modulo 4 pi G and rho0 in appropriate units) :param x: x-coordinate position (units of angle) :param y: y-coordinate position (units of angle) :param rho0: density normalization parameter of Hernquist profile :param Rs: Hernquist radius in units of angle :param center_x: x-center of the profile (units of angle) :param center_y: y-center of the profile (units of angle) :return: gravitational potential at projected radius

hessian(x, y, sigma0, Rs, center_x=0, center_y=0)[source]

Hessian terms of the function.

Parameters:
  • x – x-coordinate position (units of angle)
  • y – y-coordinate position (units of angle)
  • sigma0 – normalization parameter defined such that the deflection at projected RS leads to alpha = 2./3 * Rs * sigma0
  • Rs – Hernquist radius in units of angle
  • center_x – x-center of the profile (units of angle)
  • center_y – y-center of the profile (units of angle)
Returns:

df/dxdx, df/dxdy, df/dydx, df/dydy

lower_limit_default = {'Rs': 0, 'center_x': -100, 'center_y': -100, 'sigma0': 0}
mass_2d(r, rho0, Rs)[source]

Mass enclosed projected 2d sphere of radius r.

Parameters:
  • r – projected radius
  • rho0 – density normalization
  • Rs – Hernquist radius
Returns:

mass enclosed 2d projected radius

mass_2d_lens(r, sigma0, Rs)[source]

Mass enclosed projected 2d sphere of radius r Same as mass_2d but with input normalization in units of projected density.

Parameters:
  • r – projected radius
  • sigma0 – rho0 * Rs (units of projected density)
  • Rs – Hernquist radius
Returns:

mass enclosed 2d projected radius

static mass_3d(r, rho0, Rs)[source]

Mass enclosed a 3d sphere or radius r.

Parameters:
  • r – 3-d radius within the mass is integrated (same distance units as density definition)
  • rho0 – density normalization
  • Rs – Hernquist radius
Returns:

enclosed mass

mass_3d_lens(r, sigma0, Rs)[source]

Mass enclosed a 3d sphere or radius r for lens parameterisation This function converts the lensing definition sigma0 into the 3d density.

Parameters:
  • r – radius
  • sigma0 – rho0 * Rs (units of projected density)
  • Rs – Hernquist radius
Returns:

enclosed mass in 3d

static mass_tot(rho0, Rs)[source]

Total mass within the profile.

Parameters:
  • rho0 – density normalization
  • Rs – Hernquist radius
Returns:

total mass within profile

param_names = ['sigma0', 'Rs', 'center_x', 'center_y']
static rho2sigma(rho0, Rs)[source]

Converts 3d density into 2d projected density parameter.

Parameters:
  • rho0 – 3d density normalization of Hernquist model
  • Rs – Hernquist radius
Returns:

sigma0 defined quantity in projected units

static sigma2rho(sigma0, Rs)[source]

Converts projected density parameter (in units of deflection) into 3d density parameter.

Parameters:
  • sigma0 – density defined quantity in projected units
  • Rs – Hernquist radius
Returns:

rho0 the 3d density normalization of Hernquist model

upper_limit_default = {'Rs': 100, 'center_x': 100, 'center_y': 100, 'sigma0': 100}

lenstronomy.LensModel.Profiles.hernquist_ellipse module

class Hernquist_Ellipse[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains functions for the elliptical Hernquist profile.

Ellipticity is defined in the potential.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

density(r, rho0, Rs, e1=0, e2=0)[source]

Computes the 3-d density.

Parameters:
  • r – 3-d radius
  • rho0 – density normalization
  • Rs – Hernquist radius
Returns:

density at radius r

density_2d(x, y, rho0, Rs, e1=0, e2=0, center_x=0, center_y=0)[source]

Projected density along the line of sight at coordinate (x, y)

Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • rho0 – density normalization
  • Rs – Hernquist radius
  • center_x – x-center of the profile
  • center_y – y-center of the profile
Returns:

projected density

density_lens(r, sigma0, Rs, e1=0, e2=0)[source]

Density as a function of 3d radius in lensing parameters This function converts the lensing definition sigma0 into the 3d density.

Parameters:
  • r – 3d radius
  • sigma0 – rho0 * Rs (units of projected density)
  • Rs – Hernquist radius
Returns:

enclosed mass in 3d

derivatives(x, y, sigma0, Rs, e1, e2, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function (integral of NFW)

function(x, y, sigma0, Rs, e1, e2, center_x=0, center_y=0)[source]

Returns double integral of NFW profile.

hessian(x, y, sigma0, Rs, e1, e2, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

lower_limit_default = {'Rs': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'sigma0': 0}
mass_2d(r, rho0, Rs, e1=0, e2=0)[source]

Mass enclosed projected 2d sphere of radius r.

Parameters:
  • r – projected radius
  • rho0 – density normalization
  • Rs – Hernquist radius
Returns:

mass enclosed 2d projected radius

mass_2d_lens(r, sigma0, Rs, e1=0, e2=0)[source]

Mass enclosed projected 2d sphere of radius r Same as mass_2d but with input normalization in units of projected density.

Parameters:
  • r – projected radius
  • sigma0 – rho0 * Rs (units of projected density)
  • Rs – Hernquist radius
Returns:

mass enclosed 2d projected radius

mass_3d(r, rho0, Rs, e1=0, e2=0)[source]

Mass enclosed a 3d sphere or radius r.

Parameters:
  • r – 3-d radius within the mass is integrated (same distance units as density definition)
  • rho0 – density normalization
  • Rs – Hernquist radius
Returns:

enclosed mass

mass_3d_lens(r, sigma0, Rs, e1=0, e2=0)[source]

Mass enclosed a 3d sphere or radius r in lensing parameterization.

Parameters:
  • r – 3-d radius within the mass is integrated (same distance units as density definition)
  • sigma0 – rho0 * Rs (units of projected density)
  • Rs – Hernquist radius
Returns:

enclosed mass

param_names = ['sigma0', 'Rs', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'Rs': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'sigma0': 100}

lenstronomy.LensModel.Profiles.hernquist_ellipse_cse module

class HernquistEllipseCSE[source]

Bases: lenstronomy.LensModel.Profiles.hernquist_ellipse.Hernquist_Ellipse

This class contains functions for the elliptical Hernquist profile.

Ellipticity is defined in the convergence. Approximation with CSE profile introduced by Oguri 2021: https://arxiv.org/pdf/2106.11464.pdf

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, sigma0, Rs, e1, e2, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function (integral of NFW)

function(x, y, sigma0, Rs, e1, e2, center_x=0, center_y=0)[source]

Returns double integral of NFW profile.

hessian(x, y, sigma0, Rs, e1, e2, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

lower_limit_default = {'Rs': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'sigma0': 0}
param_names = ['sigma0', 'Rs', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'Rs': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'sigma0': 100}

lenstronomy.LensModel.Profiles.hessian module

class Hessian(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class for constant Hessian distortion (second order) The input is in the same convention as the LensModel.hessian() output.

derivatives(x, y, f_xx, f_yy, f_xy, f_yx, ra_0=0, dec_0=0)[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y0-coordinate (angle)
  • f_xx – dalpha_x/dx
  • f_yy – dalpha_y/dy
  • f_xy – dalpha_x/dy
  • f_yx – dalpha_y/dx
  • ra_0 – x/ra position where shear deflection is 0
  • dec_0 – y/dec position where shear deflection is 0
Returns:

deflection angles

function(x, y, f_xx, f_yy, f_xy, f_yx, ra_0=0, dec_0=0)[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y0-coordinate (angle)
  • f_xx – dalpha_x/dx
  • f_yy – dalpha_y/dy
  • f_xy – dalpha_x/dy
  • f_yx – dalpha_y/dx
  • ra_0 – x/ra position where shear deflection is 0
  • dec_0 – y/dec position where shear deflection is 0
Returns:

lensing potential

hessian(x, y, f_xx, f_yy, f_xy, f_yx, ra_0=0, dec_0=0)[source]

Hessian. Attention: If f_xy != f_yx then this function is not accurate!

Parameters:
  • x – x-coordinate (angle)
  • y – y0-coordinate (angle)
  • f_xx – dalpha_x/dx
  • f_yy – dalpha_y/dy
  • f_xy – dalpha_x/dy
  • f_yx – dalpha_y/dx
  • ra_0 – x/ra position where shear deflection is 0
  • dec_0 – y/dec position where shear deflection is 0
Returns:

f_xx, f_yy, f_xy

lower_limit_default = {'dec_0': -100, 'f_xx': -100, 'f_xy': -100, 'f_yx': -100, 'f_yy': -100, 'ra_0': -100}
param_names = ['f_xx', 'f_yy', 'f_xy', 'f_yx', 'ra_0', 'dec_0']
upper_limit_default = {'dec_0': 100, 'f_xx': 100, 'f_xy': 100, 'f_yx': 100, 'f_yy': 100, 'ra_0': 100}

lenstronomy.LensModel.Profiles.interpol module

class Interpol(grid=False, min_grid_number=100, kwargs_spline=None)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class which uses an interpolation of a lens model and its first and second order derivatives.

See also the tests in lenstronomy.test.test_LensModel.test_Profiles.test_interpol.py for example use cases as checks against known analytic models.

The deflection angle is in the same convention as the one in the LensModel module, meaning that: source position = image position - deflection angle

__init__(grid=False, min_grid_number=100, kwargs_spline=None)[source]
Parameters:
  • grid – bool, if True, computes the calculation on a grid
  • min_grid_number – minimum numbers of positions to compute the interpolation on a grid, otherwise in a loop
  • kwargs_spline – keyword arguments for the scipy.interpolate.RectBivariateSpline() interpolation (optional) if =None, a default linear interpolation is chosen.
derivatives(x, y, grid_interp_x=None, grid_interp_y=None, f_=None, f_x=None, f_y=None, f_xx=None, f_yy=None, f_xy=None)[source]

Returns df/dx and df/dy of the function.

Parameters:
  • x – x-coordinate (angular position), float or numpy array
  • y – y-coordinate (angular position), float or numpy array
  • grid_interp_x – numpy array (ascending) to mark the x-direction of the interpolation grid
  • grid_interp_y – numpy array (ascending) to mark the y-direction of the interpolation grid
  • f – 2d numpy array of lensing potential, matching the grids in grid_interp_x and grid_interp_y
  • f_x – 2d numpy array of deflection in x-direction, matching the grids in grid_interp_x and grid_interp_y
  • f_y – 2d numpy array of deflection in y-direction, matching the grids in grid_interp_x and grid_interp_y
  • f_xx – 2d numpy array of df/dxx, matching the grids in grid_interp_x and grid_interp_y
  • f_yy – 2d numpy array of df/dyy, matching the grids in grid_interp_x and grid_interp_y
  • f_xy – 2d numpy array of df/dxy, matching the grids in grid_interp_x and grid_interp_y
Returns:

f_x, f_y at interpolated positions (x, y)

do_interp(x_grid, y_grid, f_, f_x, f_y, f_xx=None, f_yy=None, f_xy=None)[source]
f_interp(x, y, x_grid=None, y_grid=None, f_=None, grid=False)[source]
f_x_interp(x, y, x_grid=None, y_grid=None, f_x=None, grid=False)[source]
f_xx_interp(x, y, x_grid=None, y_grid=None, f_xx=None, grid=False)[source]
f_xy_interp(x, y, x_grid=None, y_grid=None, f_xy=None, grid=False)[source]
f_y_interp(x, y, x_grid=None, y_grid=None, f_y=None, grid=False)[source]
f_yy_interp(x, y, x_grid=None, y_grid=None, f_yy=None, grid=False)[source]
function(x, y, grid_interp_x=None, grid_interp_y=None, f_=None, f_x=None, f_y=None, f_xx=None, f_yy=None, f_xy=None)[source]
Parameters:
  • x – x-coordinate (angular position), float or numpy array
  • y – y-coordinate (angular position), float or numpy array
  • grid_interp_x – numpy array (ascending) to mark the x-direction of the interpolation grid
  • grid_interp_y – numpy array (ascending) to mark the y-direction of the interpolation grid
  • f – 2d numpy array of lensing potential, matching the grids in grid_interp_x and grid_interp_y
  • f_x – 2d numpy array of deflection in x-direction, matching the grids in grid_interp_x and grid_interp_y
  • f_y – 2d numpy array of deflection in y-direction, matching the grids in grid_interp_x and grid_interp_y
  • f_xx – 2d numpy array of df/dxx, matching the grids in grid_interp_x and grid_interp_y
  • f_yy – 2d numpy array of df/dyy, matching the grids in grid_interp_x and grid_interp_y
  • f_xy – 2d numpy array of df/dxy, matching the grids in grid_interp_x and grid_interp_y
Returns:

potential at interpolated positions (x, y)

hessian(x, y, grid_interp_x=None, grid_interp_y=None, f_=None, f_x=None, f_y=None, f_xx=None, f_yy=None, f_xy=None)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

Parameters:
  • x – x-coordinate (angular position), float or numpy array
  • y – y-coordinate (angular position), float or numpy array
  • grid_interp_x – numpy array (ascending) to mark the x-direction of the interpolation grid
  • grid_interp_y – numpy array (ascending) to mark the y-direction of the interpolation grid
  • f – 2d numpy array of lensing potential, matching the grids in grid_interp_x and grid_interp_y
  • f_x – 2d numpy array of deflection in x-direction, matching the grids in grid_interp_x and grid_interp_y
  • f_y – 2d numpy array of deflection in y-direction, matching the grids in grid_interp_x and grid_interp_y
  • f_xx – 2d numpy array of df/dxx, matching the grids in grid_interp_x and grid_interp_y
  • f_yy – 2d numpy array of df/dyy, matching the grids in grid_interp_x and grid_interp_y
  • f_xy – 2d numpy array of df/dxy, matching the grids in grid_interp_x and grid_interp_y
Returns:

f_xx, f_xy, f_yx, f_yy at interpolated positions (x, y)

lower_limit_default = {}
param_names = ['grid_interp_x', 'grid_interp_y', 'f_', 'f_x', 'f_y', 'f_xx', 'f_yy', 'f_xy']
upper_limit_default = {}
class InterpolScaled(grid=True, min_grid_number=100, kwargs_spline=None)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class for handling an interpolated lensing map and has the freedom to scale its lensing effect.

Applications are e.g. mass to light ratio.

__init__(grid=True, min_grid_number=100, kwargs_spline=None)[source]
Parameters:
  • grid – bool, if True, computes the calculation on a grid
  • min_grid_number – minimum numbers of positions to compute the interpolation on a grid
  • kwargs_spline – keyword arguments for the scipy.interpolate.RectBivariateSpline() interpolation (optional) if =None, a default linear interpolation is chosen.
derivatives(x, y, scale_factor=1, grid_interp_x=None, grid_interp_y=None, f_=None, f_x=None, f_y=None, f_xx=None, f_yy=None, f_xy=None)[source]
Parameters:
  • x – x-coordinate (angular position), float or numpy array
  • y – y-coordinate (angular position), float or numpy array
  • scale_factor – float, overall scaling of the lens model relative to the input interpolation grid
  • grid_interp_x – numpy array (ascending) to mark the x-direction of the interpolation grid
  • grid_interp_y – numpy array (ascending) to mark the y-direction of the interpolation grid
  • f – 2d numpy array of lensing potential, matching the grids in grid_interp_x and grid_interp_y
  • f_x – 2d numpy array of deflection in x-direction, matching the grids in grid_interp_x and grid_interp_y
  • f_y – 2d numpy array of deflection in y-direction, matching the grids in grid_interp_x and grid_interp_y
  • f_xx – 2d numpy array of df/dxx, matching the grids in grid_interp_x and grid_interp_y
  • f_yy – 2d numpy array of df/dyy, matching the grids in grid_interp_x and grid_interp_y
  • f_xy – 2d numpy array of df/dxy, matching the grids in grid_interp_x and grid_interp_y
Returns:

deflection angles in x- and y-direction at position (x, y)

function(x, y, scale_factor=1, grid_interp_x=None, grid_interp_y=None, f_=None, f_x=None, f_y=None, f_xx=None, f_yy=None, f_xy=None)[source]
Parameters:
  • x – x-coordinate (angular position), float or numpy array
  • y – y-coordinate (angular position), float or numpy array
  • scale_factor – float, overall scaling of the lens model relative to the input interpolation grid
  • grid_interp_x – numpy array (ascending) to mark the x-direction of the interpolation grid
  • grid_interp_y – numpy array (ascending) to mark the y-direction of the interpolation grid
  • f – 2d numpy array of lensing potential, matching the grids in grid_interp_x and grid_interp_y
  • f_x – 2d numpy array of deflection in x-direction, matching the grids in grid_interp_x and grid_interp_y
  • f_y – 2d numpy array of deflection in y-direction, matching the grids in grid_interp_x and grid_interp_y
  • f_xx – 2d numpy array of df/dxx, matching the grids in grid_interp_x and grid_interp_y
  • f_yy – 2d numpy array of df/dyy, matching the grids in grid_interp_x and grid_interp_y
  • f_xy – 2d numpy array of df/dxy, matching the grids in grid_interp_x and grid_interp_y
Returns:

potential at interpolated positions (x, y)

hessian(x, y, scale_factor=1, grid_interp_x=None, grid_interp_y=None, f_=None, f_x=None, f_y=None, f_xx=None, f_yy=None, f_xy=None)[source]
Parameters:
  • x – x-coordinate (angular position), float or numpy array
  • y – y-coordinate (angular position), float or numpy array
  • scale_factor – float, overall scaling of the lens model relative to the input interpolation grid
  • grid_interp_x – numpy array (ascending) to mark the x-direction of the interpolation grid
  • grid_interp_y – numpy array (ascending) to mark the y-direction of the interpolation grid
  • f – 2d numpy array of lensing potential, matching the grids in grid_interp_x and grid_interp_y
  • f_x – 2d numpy array of deflection in x-direction, matching the grids in grid_interp_x and grid_interp_y
  • f_y – 2d numpy array of deflection in y-direction, matching the grids in grid_interp_x and grid_interp_y
  • f_xx – 2d numpy array of df/dxx, matching the grids in grid_interp_x and grid_interp_y
  • f_yy – 2d numpy array of df/dyy, matching the grids in grid_interp_x and grid_interp_y
  • f_xy – 2d numpy array of df/dxy, matching the grids in grid_interp_x and grid_interp_y
Returns:

second derivatives of the lensing potential f_xx, f_yy, f_xy at position (x, y)

lower_limit_default = {'scale_factor': 0}
param_names = ['scale_factor', 'grid_interp_x', 'grid_interp_y', 'f_', 'f_x', 'f_y', 'f_xx', 'f_yy', 'f_xy']
upper_limit_default = {'scale_factor': 100}

lenstronomy.LensModel.Profiles.multi_gaussian_kappa module

class MultiGaussianKappa[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

density(r, amp, sigma, scale_factor=1)[source]
Parameters:
  • r
  • amp
  • sigma
Returns:

density_2d(x, y, amp, sigma, center_x=0, center_y=0, scale_factor=1)[source]
Parameters:
  • R
  • am
  • sigma_x
  • sigma_y
Returns:

derivatives(x, y, amp, sigma, center_x=0, center_y=0, scale_factor=1)[source]
Parameters:
  • x
  • y
  • amp
  • sigma
  • center_x
  • center_y
Returns:

function(x, y, amp, sigma, center_x=0, center_y=0, scale_factor=1)[source]
Parameters:
  • x
  • y
  • amp
  • sigma
  • center_x
  • center_y
Returns:

hessian(x, y, amp, sigma, center_x=0, center_y=0, scale_factor=1)[source]
Parameters:
  • x
  • y
  • amp
  • sigma
  • center_x
  • center_y
Returns:

lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'sigma': 0}
mass_3d_lens(R, amp, sigma, scale_factor=1)[source]
Parameters:
  • R
  • amp
  • sigma
Returns:

param_names = ['amp', 'sigma', 'center_x', 'center_y']
upper_limit_default = {'amp': 100, 'center_x': 100, 'center_y': 100, 'sigma': 100}
class MultiGaussianKappaEllipse[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

density(r, amp, sigma, e1, e2, scale_factor=1)[source]
Parameters:
  • r
  • amp
  • sigma
Returns:

density_2d(x, y, amp, sigma, e1, e2, center_x=0, center_y=0, scale_factor=1)[source]
Parameters:
  • R
  • am
  • sigma_x
  • sigma_y
Returns:

derivatives(x, y, amp, sigma, e1, e2, center_x=0, center_y=0, scale_factor=1)[source]
Parameters:
  • x
  • y
  • amp
  • sigma
  • center_x
  • center_y
Returns:

function(x, y, amp, sigma, e1, e2, center_x=0, center_y=0, scale_factor=1)[source]
Parameters:
  • x
  • y
  • amp
  • sigma
  • center_x
  • center_y
Returns:

hessian(x, y, amp, sigma, e1, e2, center_x=0, center_y=0, scale_factor=1)[source]
Parameters:
  • x
  • y
  • amp
  • sigma
  • center_x
  • center_y
Returns:

lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'sigma': 0}
mass_3d_lens(R, amp, sigma, e1, e2, scale_factor=1)[source]
Parameters:
  • R
  • amp
  • sigma
Returns:

param_names = ['amp', 'sigma', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'amp': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'sigma': 100}

lenstronomy.LensModel.Profiles.multipole module

class Multipole(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains a multipole contribution (for 1 component with m>=2) This uses the same definitions as Xu et al.(2013) in Appendix B3 https://arxiv.org/pdf/1307.4220.pdf Equation B12 m : int, multipole order, m>=2 a_m : float, multipole strength phi_m : float, multipole orientation in radian

derivatives(x, y, m, a_m, phi_m, center_x=0, center_y=0)[source]

Deflection of a multipole contribution (for 1 component with m>=2) This uses the same definitions as Xu et al.(2013) in Appendix B3 https://arxiv.org/pdf/1307.4220.pdf Equation B12

Parameters:
  • x – x-coordinate to evaluate function
  • y – y-coordinate to evaluate function
  • m – int, multipole order, m>=2
  • a_m – float, multipole strength
  • phi_m – float, multipole orientation in radian
  • center_x – x-position
  • center_y – y-position
Returns:

deflection angles alpha_x, alpha_y

function(x, y, m, a_m, phi_m, center_x=0, center_y=0)[source]

Lensing potential of multipole contribution (for 1 component with m>=2) This uses the same definitions as Xu et al.(2013) in Appendix B3 https://arxiv.org/pdf/1307.4220.pdf

Parameters:
  • x – x-coordinate to evaluate function
  • y – y-coordinate to evaluate function
  • m – int, multipole order, m>=2
  • a_m – float, multipole strength
  • phi_m – float, multipole orientation in radian
  • center_x – x-position
  • center_y – y-position
Returns:

lensing potential

hessian(x, y, m, a_m, phi_m, center_x=0, center_y=0)[source]

Hessian of a multipole contribution (for 1 component with m>=2) This uses the same definitions as Xu et al.(2013) in Appendix B3 https://arxiv.org/pdf/1307.4220.pdf

Parameters:
  • x – x-coordinate to evaluate function
  • y – y-coordinate to evaluate function
  • m – int, multipole order, m>=2
  • a_m – float, multipole strength
  • phi_m – float, multipole orientation in radian
  • center_x – x-position
  • center_y – y-position
Returns:

f_xx, f_xy, f_yx, f_yy

lower_limit_default = {'a_m': 0, 'center_x': -100, 'center_y': -100, 'm': 2, 'phi_m': -3.141592653589793}
param_names = ['m', 'a_m', 'phi_m', 'center_x', 'center_y']
upper_limit_default = {'a_m': 100, 'center_x': 100, 'center_y': 100, 'm': 100, 'phi_m': 3.141592653589793}

lenstronomy.LensModel.Profiles.nfw module

class NFW(interpol=False, num_interp_X=1000, max_interp_X=10)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains functions concerning the NFW profile.

relation are: R_200 = c * Rs The definition of ‘Rs’ is in angular (arc second) units and the normalization is put in with regard to a deflection angle at ‘Rs’ - ‘alpha_Rs’. To convert a physical mass and concentration definition into those lensing quantities for a specific redshift configuration and cosmological model, you can find routines in lenstronomy.Cosmo.lens_cosmo.py

>>> from lenstronomy.Cosmo.lens_cosmo import LensCosmo
>>> from astropy.cosmology import FlatLambdaCDM
>>> cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Ob0=0.05)
>>> lens_cosmo = LensCosmo(z_lens=0.5, z_source=1.5, cosmo=cosmo)

Here we compute the angular scale of Rs on the sky (in arc seconds) and the deflection angle at Rs (in arc seconds):

>>> Rs_angle, alpha_Rs = lens_cosmo.nfw_physical2angle(M=10**13, c=6)

And here we perform the inverse calculation given Rs_angle and alpha_Rs to return the physical halo properties.

>>> rho0, Rs, c, r200, M200 = lens_cosmo.nfw_angle2physical(Rs_angle=Rs_angle, alpha_Rs=alpha_Rs)

The lens model calculation uses angular units as arguments! So to execute a deflection angle calculation one uses

>>> from lenstronomy.LensModel.Profiles.nfw import NFW
>>> nfw = NFW()
>>> alpha_x, alpha_y = nfw.derivatives(x=1, y=1, Rs=Rs_angle, alpha_Rs=alpha_Rs, center_x=0, center_y=0)
F_(X)[source]

Computes h()

Parameters:X
Returns:
__init__(interpol=False, num_interp_X=1000, max_interp_X=10)[source]
Parameters:
  • interpol – bool, if True, interpolates the functions F(), g() and h()
  • num_interp_X – int (only considered if interpol=True), number of interpolation elements in units of r/r_s
  • max_interp_X – float (only considered if interpol=True), maximum r/r_s value to be interpolated (returning zeros outside)
static alpha2rho0(alpha_Rs, Rs)[source]

Convert angle at Rs into rho0.

Parameters:
  • alpha_Rs – deflection angle at RS
  • Rs – scale radius
Returns:

density normalization (characteristic density)

static density(R, Rs, rho0)[source]

Three-dimensional NFW profile.

Parameters:
  • R (float/numpy array) – radius of interest
  • Rs (float) – scale radius
  • rho0 (float) – density normalization (characteristic density)
Returns:

rho(R) density

density_2d(x, y, Rs, rho0, center_x=0, center_y=0)[source]

Projected two-dimensional NFW profile (kappa)

Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • Rs (float) – scale radius
  • rho0 (float) – density normalization (characteristic density)
  • center_x – x-centroid position
  • center_y – y-centroid position
Returns:

Epsilon(R) projected density at radius R

density_lens(r, Rs, alpha_Rs)[source]

Computes the density at 3d radius r given lens model parameterization. The integral in the LOS projection of this quantity results in the convergence quantity.

Parameters:
  • r – 3d radios
  • Rs – turn-over radius of NFW profile
  • alpha_Rs – deflection at Rs
Returns:

density rho(r)

derivatives(x, y, Rs, alpha_Rs, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function (integral of NFW), which are the deflection angles.

Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • Rs – turn over point in the slope of the NFW profile in angular unit
  • alpha_Rs – deflection (angular units) at projected Rs
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

deflection angle in x, deflection angle in y

function(x, y, Rs, alpha_Rs, center_x=0, center_y=0)[source]
Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • Rs – turn over point in the slope of the NFW profile in angular unit
  • alpha_Rs – deflection (angular units) at projected Rs
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

lensing potential

g_(X)[source]

Computes h()

Parameters:X (float >0) – R/Rs
Returns:
h_(X)[source]

Computes h()

Parameters:X (float >0) – R/Rs
Returns:h(X)
hessian(x, y, Rs, alpha_Rs, center_x=0, center_y=0)[source]
Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • Rs – turn over point in the slope of the NFW profile in angular unit
  • alpha_Rs – deflection (angular units) at projected Rs
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2

lower_limit_default = {'Rs': 0, 'alpha_Rs': 0, 'center_x': -100, 'center_y': -100}
mass_2d(R, Rs, rho0)[source]

Mass enclosed a 2d cylinder or projected radius R :param R: projected radius :param Rs: scale radius :param rho0: density normalization (characteristic density) :return: mass in cylinder.

mass_2d_lens(R, Rs, alpha_Rs)[source]
Parameters:
  • R – projected radius
  • Rs – scale radius
  • alpha_Rs – deflection (angular units) at projected Rs
Returns:

mass enclosed 2d cylinder <R

mass_3d(r, Rs, rho0)[source]

Mass enclosed a 3d sphere or radius r.

Parameters:
  • r – 3d radius
  • Rs – scale radius
  • rho0 – density normalization (characteristic density)
Returns:

M(<r)

mass_3d_lens(r, Rs, alpha_Rs)[source]

Mass enclosed a 3d sphere or radius r. This function takes as input the lensing parameterization.

Parameters:
  • r – 3d radius
  • Rs – scale radius
  • alpha_Rs – deflection (angular units) at projected Rs
Returns:

M(<r)

nfwAlpha(R, Rs, rho0, ax_x, ax_y)[source]

Deflection angel of NFW profile (times Sigma_crit D_OL) along the projection to coordinate ‘axis’.

Parameters:
  • R (float/numpy array) – radius of interest
  • Rs (float) – scale radius
  • rho0 (float) – density normalization (characteristic density)
  • ax_x (same as R) – projection to either x- or y-axis
  • ax_y (same as R) – projection to either x- or y-axis
Returns:

Epsilon(R) projected density at radius R

nfwGamma(R, Rs, rho0, ax_x, ax_y)[source]

Shear gamma of NFW profile (times Sigma_crit) along the projection to coordinate ‘axis’.

Parameters:
  • R (float/numpy array) – radius of interest
  • Rs (float) – scale radius
  • rho0 (float) – density normalization (characteristic density)
  • ax_x (same as R) – projection to either x- or y-axis
  • ax_y (same as R) – projection to either x- or y-axis
Returns:

Epsilon(R) projected density at radius R

nfwPot(R, Rs, rho0)[source]

Lensing potential of NFW profile (Sigma_crit D_OL**2)

Parameters:
  • R (float/numpy array) – radius of interest
  • Rs (float) – scale radius
  • rho0 (float) – density normalization (characteristic density)
Returns:

Epsilon(R) projected density at radius R

param_names = ['Rs', 'alpha_Rs', 'center_x', 'center_y']
profile_name = 'NFW'
static rho02alpha(rho0, Rs)[source]

Convert rho0 to angle at Rs.

Parameters:
  • rho0 – density normalization (characteristic density)
  • Rs – scale radius
Returns:

deflection angle at RS

upper_limit_default = {'Rs': 100, 'alpha_Rs': 10, 'center_x': 100, 'center_y': 100}

lenstronomy.LensModel.Profiles.nfw_ellipse module

class NFW_ELLIPSE(interpol=False, num_interp_X=1000, max_interp_X=10)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains functions concerning the NFW profile with an ellipticity defined in the potential parameterization of alpha_Rs and Rs is the same as for the spherical NFW profile.

from Glose & Kneib: https://cds.cern.ch/record/529584/files/0112138.pdf

relation are: R_200 = c * Rs

__init__(interpol=False, num_interp_X=1000, max_interp_X=10)[source]
Parameters:
  • interpol – bool, if True, interpolates the functions F(), g() and h()
  • num_interp_X – int (only considered if interpol=True), number of interpolation elements in units of r/r_s
  • max_interp_X – float (only considered if interpol=True), maximum r/r_s value to be interpolated (returning zeros outside)
density_lens(r, Rs, alpha_Rs, e1=1, e2=0)[source]

Computes the density at 3d radius r given lens model parameterization. The integral in the LOS projection of this quantity results in the convergence quantity.

Parameters:
  • r – 3d radios
  • Rs – turn-over radius of NFW profile
  • alpha_Rs – deflection at Rs
Returns:

density rho(r)

derivatives(x, y, Rs, alpha_Rs, e1, e2, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function, calculated as an elliptically distorted deflection angle of the spherical NFW profile.

Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • Rs – turn over point in the slope of the NFW profile in angular unit
  • alpha_Rs – deflection (angular units) at projected Rs
  • e1 – eccentricity component in x-direction
  • e2 – eccentricity component in y-direction
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

deflection in x-direction, deflection in y-direction

function(x, y, Rs, alpha_Rs, e1, e2, center_x=0, center_y=0)[source]

Returns elliptically distorted NFW lensing potential.

Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • Rs – turn over point in the slope of the NFW profile in angular unit
  • alpha_Rs – deflection (angular units) at projected Rs
  • e1 – eccentricity component in x-direction
  • e2 – eccentricity component in y-direction
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

lensing potential

hessian(x, y, Rs, alpha_Rs, e1, e2, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy the calculation is performed as a numerical differential from the deflection field. Analytical relations are possible.

Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • Rs – turn over point in the slope of the NFW profile in angular unit
  • alpha_Rs – deflection (angular units) at projected Rs
  • e1 – eccentricity component in x-direction
  • e2 – eccentricity component in y-direction
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2

lower_limit_default = {'Rs': 0, 'alpha_Rs': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5}
mass_3d_lens(r, Rs, alpha_Rs, e1=1, e2=0)[source]
Parameters:
  • r – radius (in angular units)
  • Rs
  • alpha_Rs
  • e1
  • e2
Returns:

param_names = ['Rs', 'alpha_Rs', 'e1', 'e2', 'center_x', 'center_y']
profile_name = 'NFW_ELLIPSE'
upper_limit_default = {'Rs': 100, 'alpha_Rs': 10, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5}

lenstronomy.LensModel.Profiles.nfw_ellipse_cse module

class NFW_ELLIPSE_CSE(high_accuracy=True)[source]

Bases: lenstronomy.LensModel.Profiles.nfw_ellipse.NFW_ELLIPSE

this class contains functions concerning the NFW profile with an ellipticity defined in the convergence parameterization of alpha_Rs and Rs is the same as for the spherical NFW profile Approximation with CSE profile introduced by Oguri 2021: https://arxiv.org/pdf/2106.11464.pdf Match to NFW using CSEs is approximate: kappa matches to ~1-2%

relation are: R_200 = c * Rs

__init__(high_accuracy=True)[source]
Parameters:high_accuracy (boolean) – if True uses a more accurate larger set of CSE profiles (see Oguri 2021)
derivatives(x, y, Rs, alpha_Rs, e1, e2, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function, calculated as an elliptically distorted deflection angle of the spherical NFW profile.

Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • Rs – turn over point in the slope of the NFW profile in angular unit
  • alpha_Rs – deflection (angular units) at projected Rs
  • e1 – eccentricity component in x-direction
  • e2 – eccentricity component in y-direction
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

deflection in x-direction, deflection in y-direction

function(x, y, Rs, alpha_Rs, e1, e2, center_x=0, center_y=0)[source]

Returns elliptically distorted NFW lensing potential.

Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • Rs – turn over point in the slope of the NFW profile in angular unit
  • alpha_Rs – deflection (angular units) at projected Rs
  • e1 – eccentricity component in x-direction
  • e2 – eccentricity component in y-direction
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

lensing potential

hessian(x, y, Rs, alpha_Rs, e1, e2, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy the calculation is performed as a numerical differential from the deflection field. Analytical relations are possible.

Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • Rs – turn over point in the slope of the NFW profile in angular unit
  • alpha_Rs – deflection (angular units) at projected Rs
  • e1 – eccentricity component in x-direction
  • e2 – eccentricity component in y-direction
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2

lower_limit_default = {'Rs': 0, 'alpha_Rs': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5}
param_names = ['Rs', 'alpha_Rs', 'e1', 'e2', 'center_x', 'center_y']
profile_name = 'NFW_ELLIPSE_CSE'
upper_limit_default = {'Rs': 100, 'alpha_Rs': 10, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5}

lenstronomy.LensModel.Profiles.nfw_mass_concentration module

This module contains a class to compute the Navarro-Frank-White function in mass/kappa space.

class NFWMC(z_lens, z_source, cosmo=None, static=False)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

this class contains functions parameterises the NFW profile with log10 M200 and the concentration rs/r200 relation are: R_200 = c * Rs

ATTENTION: the parameterization is cosmology and redshift dependent! The cosmology to connect mass and deflection relations is fixed to default H0=70km/s Omega_m=0.3 flat LCDM. It is recommended to keep a given cosmology definition in the lens modeling as the observable reduced deflection angles are sensitive in this parameterization. If you do not want to impose a mass-concentration relation, it is recommended to use the default NFW lensing profile parameterized in reduced deflection angles.

__init__(z_lens, z_source, cosmo=None, static=False)[source]
Parameters:
  • z_lens – redshift of lens
  • z_source – redshift of source
  • cosmo – astropy cosmology instance
  • static – boolean, if True, only operates with fixed parameter values
derivatives(x, y, logM, concentration, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function (integral of NFW)

function(x, y, logM, concentration, center_x=0, center_y=0)[source]
Parameters:
  • x – angular position
  • y – angular position
  • Rs – angular turn over point
  • alpha_Rs – deflection at Rs
  • center_x – center of halo
  • center_y – center of halo
Returns:

hessian(x, y, logM, concentration, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

lower_limit_default = {'center_x': -100, 'center_y': -100, 'concentration': 0.01, 'logM': 0}
param_names = ['logM', 'concentration', 'center_x', 'center_y']
set_dynamic()[source]
Returns:
set_static(logM, concentration, *args, **kwargs)[source]
Parameters:
  • logM – log10(M200)
  • concentration – halo concentration c = r_200 / r_s
Returns:

upper_limit_default = {'center_x': 100, 'center_y': 100, 'concentration': 1000, 'logM': 16}

lenstronomy.LensModel.Profiles.nfw_vir_trunc module

class NFWVirTrunc(z_lens, z_source, cosmo=None)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

this class contains functions concerning the NFW profile that is sharply truncated at the virial radius https://arxiv.org/pdf/astro-ph/0304034.pdf

relation are: R_200 = c * Rs

__init__(z_lens, z_source, cosmo=None)[source]
Parameters:
  • z_lens – redshift of lens
  • z_source – redshift of source
  • cosmo – astropy cosmology instance
kappa(theta, logM, c)[source]

Projected surface brightness.

Parameters:
  • theta – radial angle from the center of the profile
  • logM – log_10 halo mass in physical units of M_sun
  • c – concentration of the halo; r_200 = c * r_s
Returns:

convergence at theta

lenstronomy.LensModel.Profiles.nie module

class NIE[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Non-singular isothermal ellipsoid (NIE)

\[\kappa = \theta_E/2 \left[s^2_{scale} + qx^2 + y^2/q]−1/2\]
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

density_lens(r, theta_E, e1, e2, s_scale, center_x=0, center_y=0)[source]

3d mass density at 3d radius r. This function assumes spherical symmetry/ignoring the eccentricity.

Parameters:
  • r – 3d radius
  • theta_E – Einstein radius
  • e1 – eccentricity component
  • e2 – eccentricity component
  • s_scale – smoothing scale
  • center_x – profile center
  • center_y – profile center
Returns:

3d mass density at 3d radius r

derivatives(x, y, theta_E, e1, e2, s_scale, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate in image plane
  • y – y-coordinate in image plane
  • theta_E – Einstein radius
  • e1 – eccentricity component
  • e2 – eccentricity component
  • s_scale – smoothing scale
  • center_x – profile center
  • center_y – profile center
Returns:

alpha_x, alpha_y

function(x, y, theta_E, e1, e2, s_scale, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate in image plane
  • y – y-coordinate in image plane
  • theta_E – Einstein radius
  • e1 – eccentricity component
  • e2 – eccentricity component
  • s_scale – smoothing scale
  • center_x – profile center
  • center_y – profile center
Returns:

lensing potential

hessian(x, y, theta_E, e1, e2, s_scale, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate in image plane
  • y – y-coordinate in image plane
  • theta_E – Einstein radius
  • e1 – eccentricity component
  • e2 – eccentricity component
  • s_scale – smoothing scale
  • center_x – profile center
  • center_y – profile center
Returns:

f_xx, f_xy, f_yx, f_yy

lower_limit_default = {'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 's_scale': 0, 'theta_E': 0}
mass_3d_lens(r, theta_E, e1, e2, s_scale, center_x=0, center_y=0)[source]

Mass enclosed a 3d radius r. This function assumes spherical symmetry/ignoring the eccentricity.

Parameters:
  • r – 3d radius
  • theta_E – Einstein radius
  • e1 – eccentricity component
  • e2 – eccentricity component
  • s_scale – smoothing scale
  • center_x – profile center
  • center_y – profile center
Returns:

3d mass density at 3d radius r

param_conv(theta_E, e1, e2, s_scale)[source]
param_names = ['theta_E', 'e1', 'e2', 's_scale', 'center_x', 'center_y']
set_dynamic()[source]
Returns:
set_static(theta_E, e1, e2, s_scale, center_x=0, center_y=0)[source]
Parameters:
  • theta_E – Einstein radius
  • e1 – eccentricity component
  • e2 – eccentricity component
  • s_scale – smoothing scale
  • center_x – profile center
  • center_y – profile center
Returns:

self variables set

upper_limit_default = {'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 's_scale': 100, 'theta_E': 10}
class NIEMajorAxis(diff=1e-10)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains the function and the derivatives of the non-singular isothermal ellipse. See Keeton and Kochanek 1998, https://arxiv.org/pdf/astro-ph/9705194.pdf

\[\kappa = b * (q2(s2 + x2) + y2􏰉)^{−1/2}`\]
__init__(diff=1e-10)[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, b, s, q)[source]

Returns df/dx and df/dy of the function.

function(x, y, b, s, q)[source]

Lensing potential (only needed for specific calculations, such as time delays)

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
hessian(x, y, b, s, q)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

static kappa(x, y, b, s, q)[source]

convergence.

Parameters:
  • x – major axis coordinate
  • y – minor axis coordinate
  • b – normalization
  • s – smoothing scale
  • q – axis ratio
Returns:

convergence

param_names = ['b', 's', 'q', 'center_x', 'center_y']

lenstronomy.LensModel.Profiles.nie_potential module

class NIE_POTENTIAL[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class implements the elliptical potential of Eq.

(67) of LECTURES ON GRAVITATIONAL LENSING and Eq. (1) of Blandford & Kochanek 1987, mapped to Eq. (8) of Barnaka1998 to find the ellipticity bounds

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, theta_E, theta_c, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coord (in angles)
  • y – y-coord (in angles)
  • theta_E – Einstein radius (in angles)
  • theta_c – core radius (in angles)
  • e1 – eccentricity component, x direction(dimensionless)
  • e2 – eccentricity component, y direction (dimensionless)
Returns:

deflection angle (in angles)

function(x, y, theta_E, theta_c, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coord (in angles)
  • y – y-coord (in angles)
  • theta_E – Einstein radius (in angles)
  • theta_c – core radius (in angles)
  • e1 – eccentricity component, x direction(dimensionless)
  • e2 – eccentricity component, y direction (dimensionless)
Returns:

lensing potential

hessian(x, y, theta_E, theta_c, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coord (in angles)
  • y – y-coord (in angles)
  • theta_E – Einstein radius (in angles)
  • theta_c – core radius (in angles)
  • e1 – eccentricity component, x direction(dimensionless)
  • e2 – eccentricity component, y direction (dimensionless)
Returns:

hessian matrix (in angles)

lower_limit_default = {'center_x': -100, 'center_y': -100, 'e1': 0, 'e2': 0, 'theta_E': 0, 'theta_c': 0}
param_conv(theta_E, theta_c, e1, e2)[source]
param_names = ['center_x', 'center_y', 'theta_E', 'theta_c', 'e1', 'e2']
set_dynamic()[source]
Returns:
set_static(theta_E, theta_c, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate in image plane
  • y – y-coordinate in image plane
  • theta_E – Einstein radius
  • theta_c – core radius
  • e1 – eccentricity component
  • e2 – eccentricity component
  • center_x – profile center
  • center_y – profile center
Returns:

self variables set

upper_limit_default = {'center_x': 100, 'center_y': 100, 'e1': 0.2, 'e2': 0.2, 'theta_E': 10, 'theta_c': 10}
class NIEPotentialMajorAxis(diff=1e-10)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class implements the elliptical potential of Eq.

(67) of LECTURES ON GRAVITATIONAL LENSING and Eq. (1) of Blandford & Kochanek 1987, mapped to Eq. (8) of Barnaka1998 to find the ellipticity bounds

__init__(diff=1e-10)[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, theta_E, theta_c, eps)[source]

Returns df/dx and df/dy of the function.

function(x, y, theta_E, theta_c, eps)[source]

Lensing potential (only needed for specific calculations, such as time delays)

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
hessian(x, y, theta_E, theta_c, eps)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

param_names = ['theta_E', 'theta_c', 'eps', 'center_x', 'center_y']

lenstronomy.LensModel.Profiles.numerical_deflections module

class TabulatedDeflections(custom_class)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

A user-defined class that returns deflection angles given a set of observed coordinates on the sky (x, y).

This class has similar functionality as INTERPOL, with the difference being that the interpolation for this class is done prior to class creation. When used with routines in the lenstronomy.Sampling, this class effectively acts as a fixed lens model with no keyword arguments.

__init__(custom_class)[source]
Parameters:custom_class – a user-defined class that has a __call___ method that returns deflection angles

Code example:

>>> custom_class = CustomLensingClass()
>>> alpha_x, alpha_y = custom_class(x, y, **kwargs)

or equivalently:

>>> from lenstronomy.LensModel.lens_model import LensModel
>>> lens_model_list = ['NumericalAlpha']
>>> lens_model = LensModel(lens_model_list, numerical_alpha_class=custom_class)
>>>> alpha_x, alpha_y = lens_model.alpha(x, y, **kwargs)
derivatives(x, y, center_x=0, center_y=0, **kwargs)[source]
Parameters:
  • x – x coordinate [arcsec]
  • y – x coordinate [arcsec]
  • center_x – deflector x center [arcsec]
  • center_y – deflector y center [arcsec]
  • kwargs – keyword arguments for the custom profile
Returns:

function(x, y, center_x=0, center_y=0, **kwargs)[source]

Lensing potential (only needed for specific calculations, such as time delays)

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
hessian(x, y, center_x=0, center_y=0, **kwargs)[source]

Returns the components of the hessian matrix :param x: x coordinate [arcsec] :param y: y coordinate [arcsec] :param center_x: the deflector x coordinate :param center_y: the deflector y coordinate :param kwargs: keyword arguments for the profile :return: the derivatives of the deflection angles that make up the hessian matrix.

lower_limit_default = {}
param_names = []
profile_name = 'TABULATED_DEFLECTIONS'
upper_limit_default = {}

lenstronomy.LensModel.Profiles.p_jaffe module

class PJaffe[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

class to compute the DUAL PSEUDO ISOTHERMAL ELLIPTICAL MASS DISTRIBUTION based on Eliasdottir (2007) https://arxiv.org/pdf/0710.5636.pdf Appendix A

Module name: ‘PJAFFE’;

An alternative name is dPIED.

The 3D density distribution is

\[\rho(r) = \frac{\rho_0}{(1+r^2/Ra^2)(1+r^2/Rs^2)}\]

with \(Rs > Ra\).

The projected density is

\[\Sigma(R) = \Sigma_0 \frac{Ra Rs}{Rs-Ra}\left(\frac{1}{\sqrt{Ra^2+R^2}} - \frac{1}{\sqrt{Rs^2+R^2}} \right)\]

with

\[\Sigma_0 = \pi \rho_0 \frac{Ra Rs}{Rs + Ra}\]

In the lensing parameterization,

\[\sigma_0 = \frac{\Sigma_0}{\Sigma_{\rm crit}}\]
__init__()[source]
density(r, rho0, Ra, Rs)[source]

Computes the density.

Parameters:
  • r – radial distance from the center (in 3D)
  • rho0 – density normalization (see class documentation above)
  • Ra – core radius
  • Rs – transition radius from logarithmic slope -2 to -4
Returns:

density at r

density_2d(x, y, rho0, Ra, Rs, center_x=0, center_y=0)[source]

Projected density.

Parameters:
  • x – projected coordinate on the sky
  • y – projected coordinate on the sky
  • rho0 – density normalization (see class documentation above)
  • Ra – core radius
  • Rs – transition radius from logarithmic slope -2 to -4
  • center_x – center of profile
  • center_y – center of profile
Returns:

projected density

derivatives(x, y, sigma0, Ra, Rs, center_x=0, center_y=0)[source]

Deflection angles.

Parameters:
  • x – projected coordinate on the sky
  • y – projected coordinate on the sky
  • sigma0 – sigma0/sigma_crit (see class documentation above)
  • Ra – core radius (see class documentation above)
  • Rs – transition radius from logarithmic slope -2 to -4 (see class documentation above)
  • center_x – center of profile
  • center_y – center of profile
Returns:

f_x, f_y

function(x, y, sigma0, Ra, Rs, center_x=0, center_y=0)[source]

Lensing potential.

Parameters:
  • x – projected coordinate on the sky
  • y – projected coordinate on the sky
  • sigma0 – sigma0/sigma_crit (see class documentation above)
  • Ra – core radius (see class documentation above)
  • Rs – transition radius from logarithmic slope -2 to -4 (see class documentation above)
  • center_x – center of profile
  • center_y – center of profile
Returns:

lensing potential

grav_pot(r, rho0, Ra, Rs)[source]

Gravitational potential (modulo 4 pi G and rho0 in appropriate units)

Parameters:
  • r – radial distance from the center (in 3D)
  • rho0 – density normalization (see class documentation above)
  • Ra – core radius
  • Rs – transition radius from logarithmic slope -2 to -4
Returns:

gravitational potential (modulo 4 pi G and rho0 in appropriate units)

hessian(x, y, sigma0, Ra, Rs, center_x=0, center_y=0)[source]

Hessian of lensing potential.

Parameters:
  • x – projected coordinate on the sky
  • y – projected coordinate on the sky
  • sigma0 – sigma0/sigma_crit (see class documentation above)
  • Ra – core radius (see class documentation above)
  • Rs – transition radius from logarithmic slope -2 to -4 (see class documentation above)
  • center_x – center of profile
  • center_y – center of profile
Returns:

f_xx, f_xy, f_yx, f_yy

lower_limit_default = {'Ra': 0, 'Rs': 0, 'center_x': -100, 'center_y': -100, 'sigma0': 0}
mass_2d(r, rho0, Ra, Rs)[source]

Mass enclosed projected 2d sphere of radius r.

Parameters:
  • r – radial distance from the center in projection
  • rho0 – density normalization (see class documentation above)
  • Ra – core radius
  • Rs – transition radius from logarithmic slope -2 to -4
Returns:

Sigma(<r)

mass_3d(r, rho0, Ra, Rs)[source]

Mass enclosed a 3d sphere or radius r.

Parameters:
  • r – radial distance from the center (in 3D)
  • rho0 – density normalization (see class documentation above)
  • Ra – core radius
  • Rs – transition radius from logarithmic slope -2 to -4
Returns:

M(<r)

mass_3d_lens(r, sigma0, Ra, Rs)[source]

Mass enclosed a 3d sphere or radius r given a lens parameterization with angular units.

Parameters:
  • r – radial distance from the center (in 3D)
  • sigma0 – density normalization (see class documentation above)
  • Ra – core radius
  • Rs – transition radius from logarithmic slope -2 to -4
Returns:

M(<r) in angular units (modulo critical mass density)

mass_tot(rho0, Ra, Rs)[source]

Total mass within the profile.

Parameters:
  • rho0 – density normalization (see class documentation above)
  • Ra – core radius
  • Rs – transition radius from logarithmic slope -2 to -4
Returns:

total mass

param_names = ['sigma0', 'Ra', 'Rs', 'center_x', 'center_y']
rho2sigma(rho0, Ra, Rs)[source]

Converts 3d density into 2d projected density parameter, Equation A4 in Eliasdottir (2007)

Parameters:
  • rho0 – density normalization
  • Ra – core radius (see class documentation above)
  • Rs – transition radius from logarithmic slope -2 to -4 (see class documentation above)
Returns:

projected density normalization

sigma2rho(sigma0, Ra, Rs)[source]

Inverse of rho2sigma()

Parameters:
  • sigma0 – projected density normalization
  • Ra – core radius (see class documentation above)
  • Rs – transition radius from logarithmic slope -2 to -4 (see class documentation above)
Returns:

3D density normalization

upper_limit_default = {'Ra': 100, 'Rs': 100, 'center_x': 100, 'center_y': 100, 'sigma0': 10}

lenstronomy.LensModel.Profiles.p_jaffe_ellipse module

class PJaffe_Ellipse[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

class to compute the DUAL PSEUDO ISOTHERMAL ELLIPTICAL MASS DISTRIBUTION based on Eliasdottir (2007) https://arxiv.org/pdf/0710.5636.pdf Appendix A with the ellipticity implemented in the potential

Module name: ‘PJAFFE_ELLIPSE’;

An alternative name is dPIED.

The 3D density distribution is

\[\rho(r) = \frac{\rho_0}{(1+r^2/Ra^2)(1+r^2/Rs^2)}\]

with \(Rs > Ra\).

The projected density is

\[\Sigma(R) = \Sigma_0 \frac{Ra Rs}{Rs-Ra}\left(\frac{1}{\sqrt{Ra^2+R^2}} - \frac{1}{\sqrt{Rs^2+R^2}} \right)\]

with

\[\Sigma_0 = \pi \rho_0 \frac{Ra Rs}{Rs + Ra}\]

In the lensing parameterization,

\[\sigma_0 = \frac{\Sigma_0}{\Sigma_{\rm crit}}\]
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, sigma0, Ra, Rs, e1, e2, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function (integral of NFW)

function(x, y, sigma0, Ra, Rs, e1, e2, center_x=0, center_y=0)[source]

Returns double integral of NFW profile.

hessian(x, y, sigma0, Ra, Rs, e1, e2, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

lower_limit_default = {'Ra': 0, 'Rs': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'sigma0': 0}
mass_3d_lens(r, sigma0, Ra, Rs, e1=0, e2=0)[source]
Parameters:
  • r
  • sigma0
  • Ra
  • Rs
  • e1
  • e2
Returns:

param_names = ['sigma0', 'Ra', 'Rs', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'Ra': 100, 'Rs': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'sigma0': 10}

lenstronomy.LensModel.Profiles.pemd module

class PEMD(suppress_fastell=False)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class for power law ellipse mass density profile (PEMD). This class effectively calls the class SPEMD_SMOOTH with a fixed and very small central smoothing scale to perform the numerical integral using the FASTELL code by Renan Barkana. An alternative implementation of the same model using pure python with analytical functions is probided as ‘EPL’ profile.

\[\kappa(x, y) = \frac{3-\gamma}{2} \left(\frac{\theta_{E}}{\sqrt{q x^2 + y^2/q}} \right)^{\gamma-1}\]

with \(\theta_{E}\) is the (circularized) Einstein radius, \(\gamma\) is the negative power-law slope of the 3D mass distributions, \(q\) is the minor/major axis ratio, and \(x\) and \(y\) are defined in a coordinate system aligned with the major and minor axis of the lens.

In terms of eccentricities, this profile is defined as

\[\kappa(r) = \frac{3-\gamma}{2} \left(\frac{\theta'_{E}}{r \sqrt{1 − e*\cos(2*\phi)}} \right)^{\gamma-1}\]

with \(\epsilon\) is the ellipticity defined as

\[\epsilon = \frac{1-q^2}{1+q^2}\]

And an Einstein radius \(\theta'_{\rm E}\) related to the definition used is

\[\left(\frac{\theta'_{\rm E}}{\theta_{\rm E}}\right)^{2} = \frac{2q}{1+q^2}.\]
__init__(suppress_fastell=False)[source]
Parameters:suppress_fastell – bool, if True, does not raise if fastell4py is not installed
density_lens(r, theta_E, gamma, e1=None, e2=None)[source]

Computes the density at 3d radius r given lens model parameterization. The integral in the LOS projection of this quantity results in the convergence quantity.

Parameters:
  • r – radius within the mass is computed
  • theta_E – Einstein radius
  • gamma – power-law slope
  • e1 – eccentricity component (not used)
  • e2 – eccentricity component (not used)
Returns:

mass enclosed a 3D radius r

derivatives(x, y, theta_E, gamma, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y-coordinate (angle)
  • theta_E – Einstein radius (angle), pay attention to specific definition!
  • gamma – logarithmic slope of the power-law profile. gamma=2 corresponds to isothermal
  • e1 – eccentricity component
  • e2 – eccentricity component
  • center_x – x-position of lens center
  • center_y – y-position of lens center
Returns:

deflection angles alpha_x, alpha_y

function(x, y, theta_E, gamma, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y-coordinate (angle)
  • theta_E – Einstein radius (angle), pay attention to specific definition!
  • gamma – logarithmic slope of the power-law profile. gamma=2 corresponds to isothermal
  • e1 – eccentricity component
  • e2 – eccentricity component
  • center_x – x-position of lens center
  • center_y – y-position of lens center
Returns:

lensing potential

hessian(x, y, theta_E, gamma, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y-coordinate (angle)
  • theta_E – Einstein radius (angle), pay attention to specific definition!
  • gamma – logarithmic slope of the power-law profile. gamma=2 corresponds to isothermal
  • e1 – eccentricity component
  • e2 – eccentricity component
  • center_x – x-position of lens center
  • center_y – y-position of lens center
Returns:

Hessian components f_xx, f_xy, f_yx, f_yy

lower_limit_default = {'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'gamma': 1.5, 'theta_E': 0}
mass_3d_lens(r, theta_E, gamma, e1=None, e2=None)[source]

Computes the spherical power-law mass enclosed (with SPP routine).

Parameters:
  • r – radius within the mass is computed
  • theta_E – Einstein radius
  • gamma – power-law slope
  • e1 – eccentricity component (not used)
  • e2 – eccentricity component (not used)
Returns:

mass enclosed a 3D radius r

param_names = ['theta_E', 'gamma', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'gamma': 2.5, 'theta_E': 100}

lenstronomy.LensModel.Profiles.point_mass module

class PointMass[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class to compute the physical deflection angle of a point mass, given as an Einstein radius.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, theta_E, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coord (in angles)
  • y – y-coord (in angles)
  • theta_E – Einstein radius (in angles)
Returns:

deflection angle (in angles)

function(x, y, theta_E, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coord (in angles)
  • y – y-coord (in angles)
  • theta_E – Einstein radius (in angles)
Returns:

lensing potential

hessian(x, y, theta_E, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coord (in angles)
  • y – y-coord (in angles)
  • theta_E – Einstein radius (in angles)
Returns:

hessian matrix (in angles)

lower_limit_default = {'center_x': -100, 'center_y': -100, 'theta_E': 0}
param_names = ['theta_E', 'center_x', 'center_y']
upper_limit_default = {'center_x': 100, 'center_y': 100, 'theta_E': 100}

lenstronomy.LensModel.Profiles.sersic module

class Sersic(smoothing=1e-05, sersic_major_axis=False)[source]

Bases: lenstronomy.LensModel.Profiles.sersic_utils.SersicUtil, lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

this class contains functions to evaluate a Sersic mass profile: https://arxiv.org/pdf/astro-ph/0311559.pdf

\[\kappa(R) = \kappa_{\rm eff} \exp \left[ -b_n (R/R_{\rm Sersic})^{\frac{1}{n}}\right]\]

with \(b_{n}\approx 1.999n-0.327\)

Example for converting physical mass units into convergence units used in the definition of this profile.

We first define an AstroPy cosmology instance and a LensCosmo class instance with a lens and source redshift.

>>> from lenstronomy.Cosmo.lens_cosmo import LensCosmo
>>> from astropy.cosmology import FlatLambdaCDM
>>> cosmo = FlatLambdaCDM(H0=70, Om0=0.3, Ob0=0.05)
>>> lens_cosmo = LensCosmo(z_lens=0.5, z_source=1.5, cosmo=cosmo)

We define the half-light radius R_sersic (arc seconds on the sky) and Sersic index n_sersic

>>> R_sersic = 2
>>> n_sersic = 4

Here we compute k_eff, the convergence at the half-light radius R_sersic for a stellar mass in Msun

>>> k_eff = lens_cosmo.sersic_m_star2k_eff(m_star=10**11.5, R_sersic=R_sersic, n_sersic=n_sersic)

And here we perform the inverse calculation given k_eff to return the physical stellar mass.

>>> m_star = lens_cosmo.sersic_k_eff2m_star(k_eff=k_eff, R_sersic=R_sersic, n_sersic=n_sersic)

The lens model calculation uses angular units as arguments! So to execute a deflection angle calculation one uses

>>> from lenstronomy.LensModel.Profiles.sersic import Sersic
>>> sersic = Sersic()
>>> alpha_x, alpha_y = sersic.derivatives(x=1, y=1, k_eff=k_eff, R_sersic=R_sersic, center_x=0, center_y=0)
derivatives(x, y, n_sersic, R_sersic, k_eff, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function.

function(x, y, n_sersic, R_sersic, k_eff, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • n_sersic – Sersic index
  • R_sersic – half light radius
  • k_eff – convergence at half light radius
  • center_x – x-center
  • center_y – y-center
Returns:

hessian(x, y, n_sersic, R_sersic, k_eff, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

lower_limit_default = {'R_sersic': 0, 'center_x': -100, 'center_y': -100, 'k_eff': 0, 'n_sersic': 0.5}
param_names = ['k_eff', 'R_sersic', 'n_sersic', 'center_x', 'center_y']
upper_limit_default = {'R_sersic': 100, 'center_x': 100, 'center_y': 100, 'k_eff': 10, 'n_sersic': 8}

lenstronomy.LensModel.Profiles.sersic_ellipse_kappa module

class SersicEllipseKappa[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains the function and the derivatives of an elliptical sersic profile with the ellipticity introduced in the convergence (not the potential).

This requires the use of numerical integrals (Keeton 2004)

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, n_sersic, R_sersic, k_eff, e1, e2, center_x=0, center_y=0)[source]

Deflection angles.

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
function(x, y, n_sersic, R_sersic, k_eff, e1, e2, center_x=0, center_y=0)[source]

Lensing potential (only needed for specific calculations, such as time delays)

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
hessian(x, y, n_sersic, R_sersic, k_eff, e1, e2, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

lower_limit_default = {'R_sersic': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'k_eff': 0, 'n_sersic': 0.5}
param_names = ['k_eff', 'R_sersic', 'n_sersic', 'e1', 'e2', 'center_x', 'center_y']
projected_mass(x, y, q, n_sersic, R_sersic, k_eff, u=1, power=1)[source]
upper_limit_default = {'R_sersic': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'k_eff': 10, 'n_sersic': 8}

lenstronomy.LensModel.Profiles.sersic_ellipse_potential module

class SersicEllipse[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

this class contains functions to evaluate a Sersic mass profile: https://arxiv.org/pdf/astro-ph/0311559.pdf

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, n_sersic, R_sersic, k_eff, e1, e2, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function.

function(x, y, n_sersic, R_sersic, k_eff, e1, e2, center_x=0, center_y=0)[source]

Returns Gaussian.

hessian(x, y, n_sersic, R_sersic, k_eff, e1, e2, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

lower_limit_default = {'R_sersic': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'k_eff': 0, 'n_sersic': 0.5}
param_names = ['k_eff', 'R_sersic', 'n_sersic', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'R_sersic': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'k_eff': 10, 'n_sersic': 8}

lenstronomy.LensModel.Profiles.sersic_utils module

class SersicUtil(smoothing=1e-05, sersic_major_axis=False)[source]

Bases: object

__init__(smoothing=1e-05, sersic_major_axis=False)[source]
Parameters:
  • smoothing – smoothing scale of the innermost part of the profile (for numerical reasons)
  • sersic_major_axis – boolean; if True, defines the half-light radius of the Sersic light profile along the semi-major axis (which is the Galfit convention) if False, uses the product average of semi-major and semi-minor axis as the convention (default definition for all light profiles in lenstronomy other than the Sersic profile)
alpha_abs(x, y, n_sersic, r_eff, k_eff, center_x=0, center_y=0)[source]
Parameters:
  • x
  • y
  • n_sersic
  • r_eff
  • k_eff
  • center_x
  • center_y
Returns:

static b_n(n)[source]

B(n) computation. This is the approximation of the exact solution to the relation, 2*incomplete_gamma_function(2n; b_n) = Gamma_function(2*n).

Parameters:n – the sersic index
Returns:b(n)
d_alpha_dr(x, y, n_sersic, r_eff, k_eff, center_x=0, center_y=0)[source]
Parameters:
  • x
  • y
  • n_sersic
  • r_eff
  • k_eff
  • center_x
  • center_y
Returns:

density(x, y, n_sersic, r_eff, k_eff, center_x=0, center_y=0)[source]

De-projection of the Sersic profile based on Prugniel & Simien (1997) :return:

get_distance_from_center(x, y, e1, e2, center_x, center_y)[source]

Get the distance from the center of Sersic, accounting for orientation and axis ratio :param x:

Parameters:
  • y
  • e1 – eccentricity
  • e2 – eccentricity
  • center_x – center x of sersic
  • center_y – center y of sersic
k_Re(n, k)[source]
k_bn(n, Re)[source]

Returns normalisation of the sersic profile such that Re is the half light radius given n_sersic slope.

total_flux(amp, R_sersic, n_sersic, e1=0, e2=0, **kwargs)[source]

Computes analytical integral to compute total flux of the Sersic profile.

Parameters:
  • amp – amplitude parameter in Sersic function (surface brightness at R_sersic
  • R_sersic – half-light radius in semi-major axis
  • n_sersic – Sersic index
  • e1 – eccentricity
  • e2 – eccentricity
Returns:

Analytic integral of the total flux of the Sersic profile

lenstronomy.LensModel.Profiles.shapelet_pot_cartesian module

class CartShapelets(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains the function and the derivatives of the cartesian shapelets.

H_n(n, x)[source]

Constructs the Hermite polynomial of order n at position x (dimensionless)

Parameters:
  • n – The n’the basis function.
  • x – 1-dim position (dimensionless)
Returns:

array– H_n(x).

Raises:

AttributeError, KeyError

derivatives(x, y, coeffs, beta, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function.

function(x, y, coeffs, beta, center_x=0, center_y=0)[source]

Lensing potential (only needed for specific calculations, such as time delays)

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
hessian(x, y, coeffs, beta, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

lower_limit_default = {'beta': 0, 'center_x': -100, 'center_y': -100, 'coeffs': [0]}
param_names = ['coeffs', 'beta', 'center_x', 'center_y']
phi_n(n, x)[source]

Constructs the 1-dim basis function (formula (1) in Refregier et al. 2001)

Parameters:
  • n – The n’the basis function.
  • x – 1-dim position (dimensionless)
Returns:

array– phi_n(x).

Raises:

AttributeError, KeyError

pre_calc(x, y, beta, n_order, center_x, center_y)[source]

Calculates the H_n(x) and H_n(y) for a given x-array and y-array :param x:

Parameters:
  • y
  • amp
  • beta
  • n_order
  • center_x
  • center_y
Returns:

list of H_n(x) and H_n(y)

upper_limit_default = {'beta': 100, 'center_x': 100, 'center_y': 100, 'coeffs': [100]}

lenstronomy.LensModel.Profiles.shapelet_pot_polar module

class PolarShapelets[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains the function and the derivatives of the Singular Isothermal Sphere.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, coeffs, beta, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function.

function(x, y, coeffs, beta, center_x=0, center_y=0)[source]

Lensing potential (only needed for specific calculations, such as time delays)

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
hessian(x, y, coeffs, beta, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

lower_limit_default = {'beta': 0, 'center_x': -100, 'center_y': -100, 'coeffs': [0]}
param_names = ['coeffs', 'beta', 'center_x', 'center_y']
upper_limit_default = {'beta': 100, 'center_x': 100, 'center_y': 100, 'coeffs': [100]}

lenstronomy.LensModel.Profiles.shear module

class Shear(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class for external shear gamma1, gamma2 expression.

derivatives(x, y, gamma1, gamma2, ra_0=0, dec_0=0)[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y0-coordinate (angle)
  • gamma1 – shear component
  • gamma2 – shear component
  • ra_0 – x/ra position where shear deflection is 0
  • dec_0 – y/dec position where shear deflection is 0
Returns:

deflection angles

function(x, y, gamma1, gamma2, ra_0=0, dec_0=0)[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y0-coordinate (angle)
  • gamma1 – shear component
  • gamma2 – shear component
  • ra_0 – x/ra position where shear deflection is 0
  • dec_0 – y/dec position where shear deflection is 0
Returns:

lensing potential

hessian(x, y, gamma1, gamma2, ra_0=0, dec_0=0)[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y0-coordinate (angle)
  • gamma1 – shear component
  • gamma2 – shear component
  • ra_0 – x/ra position where shear deflection is 0
  • dec_0 – y/dec position where shear deflection is 0
Returns:

f_xx, f_xy, f_yx, f_yy

lower_limit_default = {'dec_0': -100, 'gamma1': -0.5, 'gamma2': -0.5, 'ra_0': -100}
param_names = ['gamma1', 'gamma2', 'ra_0', 'dec_0']
upper_limit_default = {'dec_0': 100, 'gamma1': 0.5, 'gamma2': 0.5, 'ra_0': 100}
class ShearGammaPsi[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

class to model a shear field with shear strength and direction. The translation ot the cartesian shear distortions is as follow:

\[\gamma_1 = \gamma_{ext} \cos(2 \phi_{ext}) \gamma_2 = \gamma_{ext} \sin(2 \phi_{ext})\]
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, gamma_ext, psi_ext, ra_0=0, dec_0=0)[source]

Deflection angles.

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
static function(x, y, gamma_ext, psi_ext, ra_0=0, dec_0=0)[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y0-coordinate (angle)
  • gamma_ext – shear strength
  • psi_ext – shear angle (radian)
  • ra_0 – x/ra position where shear deflection is 0
  • dec_0 – y/dec position where shear deflection is 0
Returns:

hessian(x, y, gamma_ext, psi_ext, ra_0=0, dec_0=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
lower_limit_default = {'dec_0': -100, 'gamma_ext': 0, 'psi_ext': -3.141592653589793, 'ra_0': -100}
param_names = ['gamma_ext', 'psi_ext', 'ra_0', 'dec_0']
upper_limit_default = {'dec_0': 100, 'gamma_ext': 1, 'psi_ext': 3.141592653589793, 'ra_0': 100}
class ShearReduced[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Reduced shear distortions \(\gamma' = \gamma / (1-\kappa)\). This distortion keeps the magnification as unity and, thus, does not change the size of apparent objects. To keep the magnification at unity, it requires.

\[(1-\kappa)^2) - \gamma_1^2 - \gamma_2^ = 1\]

Thus, for given pair of reduced shear \((\gamma'_1, \gamma'_2)\), an additional convergence term is calculated and added to the lensing distortions.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

derivatives(x, y, gamma1, gamma2, ra_0=0, dec_0=0)[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y0-coordinate (angle)
  • gamma1 – shear component
  • gamma2 – shear component
  • ra_0 – x/ra position where shear deflection is 0
  • dec_0 – y/dec position where shear deflection is 0
Returns:

deflection angles

function(x, y, gamma1, gamma2, ra_0=0, dec_0=0)[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y0-coordinate (angle)
  • gamma1 – shear component
  • gamma2 – shear component
  • ra_0 – x/ra position where shear deflection is 0
  • dec_0 – y/dec position where shear deflection is 0
Returns:

lensing potential

hessian(x, y, gamma1, gamma2, ra_0=0, dec_0=0)[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y0-coordinate (angle)
  • gamma1 – shear component
  • gamma2 – shear component
  • ra_0 – x/ra position where shear deflection is 0
  • dec_0 – y/dec position where shear deflection is 0
Returns:

f_xx, f_xy, f_yx, f_yy

lower_limit_default = {'dec_0': -100, 'gamma1': -0.5, 'gamma2': -0.5, 'ra_0': -100}
param_names = ['gamma1', 'gamma2', 'ra_0', 'dec_0']
upper_limit_default = {'dec_0': 100, 'gamma1': 0.5, 'gamma2': 0.5, 'ra_0': 100}

lenstronomy.LensModel.Profiles.sie module

class SIE(NIE=True)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class for singular isothermal ellipsoid (SIS with ellipticity)

\[\kappa(x, y) = \frac{1}{2} \left(\frac{\theta_{E}}{\sqrt{q x^2 + y^2/q}} \right)\]

with \(\theta_{E}\) is the (circularized) Einstein radius, \(q\) is the minor/major axis ratio, and \(x\) and \(y\) are defined in a coordinate sys- tem aligned with the major and minor axis of the lens.

In terms of eccentricities, this profile is defined as

\[\kappa(r) = \frac{1}{2} \left(\frac{\theta'_{E}}{r \sqrt{1 − e*\cos(2*\phi)}} \right)\]

with \(\epsilon\) is the ellipticity defined as

\[\epsilon = \frac{1-q^2}{1+q^2}\]

And an Einstein radius \(\theta'_{\rm E}\) related to the definition used is

\[\left(\frac{\theta'_{\rm E}}{\theta_{\rm E}}\right)^{2} = \frac{2q}{1+q^2}.\]
__init__(NIE=True)[source]
Parameters:NIE – bool, if True, is using the NIE analytic model. Otherwise it uses PEMD with gamma=2 from fastell4py
static density(r, rho0, e1=0, e2=0)[source]

Computes the density.

Parameters:
  • r – radius in angles
  • rho0 – density at angle=1
Returns:

density at r

static density_2d(x, y, rho0, e1=0, e2=0, center_x=0, center_y=0)[source]

Projected density.

Parameters:
  • x
  • y
  • rho0
  • e1
  • e2
  • center_x
  • center_y
Returns:

density_lens(r, theta_E, e1=0, e2=0)[source]

Computes the density at 3d radius r given lens model parameterization. The integral in the LOS projection of this quantity results in the convergence quantity.

Parameters:
  • r – radius in angles
  • theta_E – Einstein radius
  • e1 – eccentricity component
  • e2 – eccentricity component
Returns:

density

derivatives(x, y, theta_E, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate (angular coordinates)
  • y – y-coordinate (angular coordinates)
  • theta_E – Einstein radius
  • e1 – eccentricity
  • e2 – eccentricity
  • center_x – centroid
  • center_y – centroid
Returns:

function(x, y, theta_E, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate (angular coordinates)
  • y – y-coordinate (angular coordinates)
  • theta_E – Einstein radius
  • e1 – eccentricity
  • e2 – eccentricity
  • center_x – centroid
  • center_y – centroid
Returns:

grav_pot(x, y, rho0, e1=0, e2=0, center_x=0, center_y=0)[source]

Gravitational potential (modulo 4 pi G and rho0 in appropriate units)

Parameters:
  • x
  • y
  • rho0
  • e1
  • e2
  • center_x
  • center_y
Returns:

hessian(x, y, theta_E, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate (angular coordinates)
  • y – y-coordinate (angular coordinates)
  • theta_E – Einstein radius
  • e1 – eccentricity
  • e2 – eccentricity
  • center_x – centroid
  • center_y – centroid
Returns:

lower_limit_default = {'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'theta_E': 0}
mass_2d(r, rho0, e1=0, e2=0)[source]

Mass enclosed projected 2d sphere of radius r.

Parameters:
  • r
  • rho0
  • e1
  • e2
Returns:

mass_2d_lens(r, theta_E, e1=0, e2=0)[source]
Parameters:
  • r
  • theta_E
  • e1
  • e2
Returns:

static mass_3d(r, rho0, e1=0, e2=0)[source]

Mass enclosed a 3d sphere or radius r.

Parameters:
  • r – radius in angular units
  • rho0 – density at angle=1
Returns:

mass in angular units

mass_3d_lens(r, theta_E, e1=0, e2=0)[source]

Mass enclosed a 3d sphere or radius r given a lens parameterization with angular units.

Parameters:
  • r – radius in angular units
  • theta_E – Einstein radius
Returns:

mass in angular units

param_names = ['theta_E', 'e1', 'e2', 'center_x', 'center_y']
static theta2rho(theta_E)[source]

Converts projected density parameter (in units of deflection) into 3d density parameter.

Parameters:theta_E
Returns:
upper_limit_default = {'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'theta_E': 100}

lenstronomy.LensModel.Profiles.sis module

class SIS(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains the function and the derivatives of the Singular Isothermal Sphere.

\[\kappa(x, y) = \frac{1}{2} \left(\frac{\theta_{E}}{\sqrt{x^2 + y^2}} \right)\]

with \(\theta_{E}\) is the Einstein radius,

static density(r, rho0)[source]

Computes the density :param r: radius in angles :param rho0: density at angle=1 :return: density at r.

static density_2d(x, y, rho0, center_x=0, center_y=0)[source]

Projected density :param x:

Parameters:
  • y
  • rho0
  • center_x
  • center_y
Returns:

density_lens(r, theta_E)[source]

Computes the density at 3d radius r given lens model parameterization. The integral in projected in units of angles (i.e. arc seconds) results in the convergence quantity.

Parameters:
  • r – 3d radius
  • theta_E – Einstein radius
Returns:

density(r)

derivatives(x, y, theta_E, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function.

function(x, y, theta_E, center_x=0, center_y=0)[source]

Lensing potential (only needed for specific calculations, such as time delays)

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
grav_pot(x, y, rho0, center_x=0, center_y=0)[source]

Gravitational potential (modulo 4 pi G and rho0 in appropriate units) :param x:

Parameters:
  • y
  • rho0
  • center_x
  • center_y
Returns:

hessian(x, y, theta_E, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

lower_limit_default = {'center_x': -100, 'center_y': -100, 'theta_E': 0}
static mass_2d(r, rho0)[source]

Mass enclosed projected 2d sphere of radius r :param r:

Parameters:rho0
Returns:
mass_2d_lens(r, theta_E)[source]
Parameters:
  • r – radius
  • theta_E – Einstein radius
Returns:

mass within a radius in projection

static mass_3d(r, rho0)[source]

Mass enclosed a 3d sphere or radius r :param r: radius in angular units :param rho0: density at angle=1 :return: mass in angular units.

mass_3d_lens(r, theta_E)[source]

Mass enclosed a 3d sphere or radius r given a lens parameterization with angular units.

Parameters:
  • r – radius in angular units
  • theta_E – Einstein radius
Returns:

mass in angular units

param_names = ['theta_E', 'center_x', 'center_y']
static rho2theta(rho0)[source]

Converts 3d density into 2d projected density parameter :param rho0:

Returns:
static theta2rho(theta_E)[source]

Converts projected density parameter (in units of deflection) into 3d density parameter :param theta_E: Einstein radius :return:

upper_limit_default = {'center_x': 100, 'center_y': 100, 'theta_E': 100}

lenstronomy.LensModel.Profiles.sis_truncate module

class SIS_truncate(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains the function and the derivatives of the Singular Isothermal Sphere.

derivatives(x, y, theta_E, r_trunc, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function.

function(x, y, theta_E, r_trunc, center_x=0, center_y=0)[source]

Lensing potential (only needed for specific calculations, such as time delays)

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
hessian(x, y, theta_E, r_trunc, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

lower_limit_default = {'center_x': -100, 'center_y': -100, 'r_trunc': 0, 'theta_E': 0}
param_names = ['theta_E', 'r_trunc', 'center_x', 'center_y']
upper_limit_default = {'center_x': 100, 'center_y': 100, 'r_trunc': 100, 'theta_E': 100}

lenstronomy.LensModel.Profiles.spemd module

class SPEMD(suppress_fastell=False)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class for smooth power law ellipse mass density profile (SPEMD). This class effectively performs the FASTELL calculations by Renan Barkana. The parameters are changed and represent a spherically averaged Einstein radius an a logarithmic 3D mass profile slope.

The SPEMD mass profile is defined as follow:

\[\kappa(x, y) = \frac{3-\gamma}{2} \left(\frac{\theta_{E}}{\sqrt{q x^2 + y^2/q + s^2}} \right)^{\gamma-1}\]

with \(\theta_{E}\) is the (circularized) Einstein radius, \(\gamma\) is the negative power-law slope of the 3D mass distributions, \(q\) is the minor/major axis ratio, and \(x\) and \(y\) are defined in a coordinate system aligned with the major and minor axis of the lens.

the FASTELL definitions are as follows:

The parameters are position \((x1,x2)\), overall factor (\(b\)), power (gam), axis ratio (arat) which is <=1, core radius squared (\(s2\)), and the output potential (\(\phi\)). The projected mass density distribution, in units of the critical density, is

\[\kappa(x1,x2)=b_{fastell} \left[u2+s2\right]^{-gam},\]

with \(u2=\left[x1^2+x2^2/(arat^2)\right]\).

The conversion from lenstronomy definitions of this class to FASTELL are:

\[q_{fastell} \equiv q_{lenstronomy}\]
\[gam \equiv (\gamma-1)/2\]
\[b_{fastell} \equiv (3-\gamma)/2. * \left(\theta_{E}^2 / q\right)^{gam}\]
\[s2_{fastell} = s_{lenstronomy}^2 * q\]
__init__(suppress_fastell=False)[source]
static convert_params(theta_E, gamma, q, s_scale)[source]

Converts parameter definitions into quantities used by the FASTELL fortran library.

Parameters:
  • theta_E – Einstein radius
  • gamma – 3D power-law slope of mass profile
  • q – axis ratio minor/major
  • s_scale – float, smoothing scale in the core
Returns:

pre-factors to SPEMP profile for FASTELL

derivatives(x, y, theta_E, gamma, e1, e2, s_scale, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y-coordinate (angle)
  • theta_E – Einstein radius (angle), pay attention to specific definition!
  • gamma – logarithmic slope of the power-law profile. gamma=2 corresponds to isothermal
  • e1 – eccentricity component
  • e2 – eccentricity component
  • s_scale – smoothing scale in the center of the profile
  • center_x – x-position of lens center
  • center_y – y-position of lens center
Returns:

deflection angles alpha_x, alpha_y

function(x, y, theta_E, gamma, e1, e2, s_scale, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y-coordinate (angle)
  • theta_E – Einstein radius (angle), pay attention to specific definition!
  • gamma – logarithmic slope of the power-law profile. gamma=2 corresponds to isothermal
  • e1 – eccentricity component
  • e2 – eccentricity component
  • s_scale – smoothing scale in the center of the profile (angle)
  • center_x – x-position of lens center
  • center_y – y-position of lens center
Returns:

lensing potential

hessian(x, y, theta_E, gamma, e1, e2, s_scale, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate (angle)
  • y – y-coordinate (angle)
  • theta_E – Einstein radius (angle), pay attention to specific definition!
  • gamma – logarithmic slope of the power-law profile. gamma=2 corresponds to isothermal
  • e1 – eccentricity component
  • e2 – eccentricity component
  • s_scale – smoothing scale in the center of the profile
  • center_x – x-position of lens center
  • center_y – y-position of lens center
Returns:

Hessian components f_xx, f_xy, f_yx, f_yy

static is_not_empty(x1, x2)[source]

Check if float or not an empty array.

Returns:True if x1 and x2 are either floats/ints or an non-empty array, False if e.g. objects are []
Return type:bool
lower_limit_default = {'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'gamma': 0, 's_scale': 0, 'theta_E': 0}
param_names = ['theta_E', 'gamma', 'e1', 'e2', 's_scale', 'center_x', 'center_y']
param_transform(x, y, theta_E, gamma, e1, e2, s_scale, center_x=0, center_y=0)[source]

Transforms parameters in the format of fastell4py.

Parameters:
  • x – x-coordinate (angle)
  • y – y-coordinate (angle)
  • theta_E – Einstein radius (angle), pay attention to specific definition!
  • gamma – logarithmic slope of the power-law profile. gamma=2 corresponds to isothermal
  • e1 – eccentricity component
  • e2 – eccentricity component
  • s_scale – smoothing scale in the center of the profile
  • center_x – x-position of lens center
  • center_y – y-position of lens center
Returns:

x-rotated, y-rotated, q_fastell, gam, s2, q, phi_G

upper_limit_default = {'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'gamma': 100, 's_scale': 100, 'theta_E': 100}

lenstronomy.LensModel.Profiles.spep module

class SPEP[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class for Softened power-law elliptical potential (SPEP)

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

density_lens(r, theta_E, gamma, e1=None, e2=None)[source]

Computes the density at 3d radius r given lens model parameterization. The integral in the LOS projection of this quantity results in the convergence quantity.

Parameters:
  • r – radius within the mass is computed
  • theta_E – Einstein radius
  • gamma – power-law slope
  • e1 – eccentricity component (not used)
  • e2 – eccentricity component (not used)
Returns:

mass enclosed a 3D radius r

derivatives(x, y, theta_E, gamma, e1, e2, center_x=0, center_y=0)[source]

Deflection angles.

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
function(x, y, theta_E, gamma, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x (array of size (n)) – set of x-coordinates
  • theta_E (float.) – Einstein radius of lense
  • gamma (<2 float) – power law slope of mass profifle
  • e1 (-1<e1<1) – eccentricity
  • e2 (-1<e1<1) – eccentricity
Returns:

function

Raises:

AttributeError, KeyError

hessian(x, y, theta_E, gamma, e1, e2, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
lower_limit_default = {'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'gamma': 0, 'theta_E': 0}
mass_3d_lens(r, theta_E, gamma, e1=None, e2=None)[source]

Computes the spherical power-law mass enclosed (with SPP routine)

Parameters:
  • r – radius within the mass is computed
  • theta_E – Einstein radius
  • gamma – power-law slope
  • e1 – eccentricity component (not used)
  • e2 – eccentricity component (not used)
Returns:

mass enclosed a 3D radius r

param_names = ['theta_E', 'gamma', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'gamma': 100, 'theta_E': 100}

lenstronomy.LensModel.Profiles.splcore module

class SPLCORE(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This lens profile corresponds to a spherical power law (SPL) mass distribution with logarithmic slope gamma and a 3D core radius r_core.

\[\rho\left(r, \rho_0, r_c, \gamma\right) = \rho_0 \frac{{r_c}^\gamma}{\left(r^2 + r_c^2\right)^{\frac{\gamma}{2}}}\]

The difference between this and EPL is that this model contains a core radius, is circular, and is also defined for gamma=3.

With respect to SPEMD, this model is different in that it is also defined for gamma = 3, is circular, and is defined in terms of a physical density parameter rho0, or the central density at r=0 divided by the critical density for lensing such that rho0 has units 1/arcsec.

This class is defined for all gamma > 1

alpha(r, sigma0, r_core, gamma)[source]

Returns the deflection angle at r.

Parameters:
  • r – radius [arcsec]
  • sigma0 – convergence at r=0
  • r_core – core radius [arcsec]
  • gamma – logarithmic slope at r -> infinity
Returns:

deflection angle at r

static density(r, rho0, r_core, gamma)[source]

Returns the 3D density at r.

Parameters:
  • r – radius [arcsec]
  • rho0 – convergence at r=0
  • r_core – core radius [arcsec]
  • gamma – logarithmic slope at r -> infinity
Returns:

density at r

density_2d(x, y, rho0, r_core, gamma)[source]

Returns the convergence at radius r.

Parameters:
  • x – x position [arcsec]
  • y – y position [arcsec]
  • rho0 – convergence at r=0
  • r_core – core radius [arcsec]
  • gamma – logarithmic slope at r -> infinity
Returns:

convergence at r

density_lens(r, sigma0, r_core, gamma)[source]

Returns the 3D density at r.

Parameters:
  • r – radius [arcsec]
  • sigma0 – convergence at r=0
  • r_core – core radius [arcsec]
  • gamma – logarithmic slope at r -> infinity
Returns:

density at r

derivatives(x, y, sigma0, r_core, gamma, center_x=0, center_y=0)[source]
Parameters:
  • x – projected x position at which to evaluate function [arcsec]
  • y – projected y position at which to evaluate function [arcsec]
  • sigma0 – convergence at r = 0
  • r_core – core radius [arcsec]
  • gamma – logarithmic slope at r -> infinity
  • center_x – x coordinate center of lens model [arcsec]
  • center_y – y coordinate center of lens model [arcsec]
Returns:

deflection angle alpha in x and y directions

function(x, y, sigma0, r_core, gamma, center_x=0, center_y=0)[source]

Lensing potential (only needed for specific calculations, such as time delays)

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
hessian(x, y, sigma0, r_core, gamma, center_x=0, center_y=0)[source]
Parameters:
  • x – projected x position at which to evaluate function [arcsec]
  • y – projected y position at which to evaluate function [arcsec]
  • sigma0 – convergence at r = 0
  • r_core – core radius [arcsec]
  • gamma – logarithmic slope at r -> infinity
  • center_x – x coordinate center of lens model [arcsec]
  • center_y – y coordinate center of lens model [arcsec]
Returns:

hessian elements

alpha_(x/y) = alpha_r * cos/sin(x/y / r)

lower_limit_default = {'center_x': -100, 'center_y': -100, 'gamma': 1.000001, 'r_core': 1e-06, 'sigma0': 0}
mass_2d(r, rho0, r_core, gamma)[source]

Mass enclosed projected 2d disk of radius r.

Parameters:
  • r – radius [arcsec]
  • rho0 – density at r = 0 in units [rho_0_physical / sigma_crit] (which should be equal to [1/arcsec]) where rho_0_physical is a physical density normalization and sigma_crit is the critical density for lensing
  • r_core – core radius [arcsec]
  • gamma – logarithmic slope at r -> infinity
Returns:

projected mass inside disk of radius r

mass_2d_lens(r, sigma0, r_core, gamma)[source]

Mass enclosed projected 2d disk of radius r.

Parameters:
  • r – radius [arcsec]
  • sigma0 – convergence at r = 0 where rho_0_physical is a physical density normalization and sigma_crit is the critical density for lensing
  • r_core – core radius [arcsec]
  • gamma – logarithmic slope at r -> infinity
Returns:

projected mass inside disk of radius r

mass_3d(r, rho0, r_core, gamma)[source]

Mass enclosed a 3d sphere or radius r.

Parameters:
  • r – radius [arcsec]
  • rho0 – density at r = 0 in units [rho_0_physical / sigma_crit] (which should be equal to [arcsec]) where rho_0_physical is a physical density normalization and sigma_crit is the critical density for lensing
  • r_core – core radius [arcsec]
  • gamma – logarithmic slope at r -> infinity
Returns:

mass inside radius r

mass_3d_lens(r, sigma0, r_core, gamma)[source]

Mass enclosed a 3d sphere or radius r.

Parameters:
  • r – radius [arcsec]
  • sigma0 – convergence at r = 0
  • r_core – core radius [arcsec]
  • gamma – logarithmic slope at r -> infinity
Returns:

mass inside radius r

param_names = ['sigma0', 'center_x', 'center_y', 'r_core', 'gamma']
upper_limit_default = {'center_x': 100, 'center_y': 100, 'gamma': 5.0, 'r_core': 100, 'sigma0': 1000000000000.0}

lenstronomy.LensModel.Profiles.spp module

class SPP(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

Class for circular power-law mass distribution.

static density(r, rho0, gamma)[source]

Computes the density.

Parameters:
  • r
  • rho0
  • gamma
Returns:

static density_2d(x, y, rho0, gamma, center_x=0, center_y=0)[source]

Projected density.

Parameters:
  • x
  • y
  • rho0
  • gamma
  • center_x
  • center_y
Returns:

density_lens(r, theta_E, gamma)[source]

Computes the density at 3d radius r given lens model parameterization.

The integral in projected in units of angles (i.e. arc seconds) results in the convergence quantity.

derivatives(x, y, theta_E, gamma, center_x=0.0, center_y=0.0)[source]

Deflection angles.

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
function(x, y, theta_E, gamma, center_x=0, center_y=0)[source]
Parameters:
  • x (array of size (n)) – set of x-coordinates
  • y (array of size (n)) – set of y-coordinates
  • theta_E (float.) – Einstein radius of lens
  • gamma (<2 float) – power law slope of mass profile
Returns:

function

Raises:

AttributeError, KeyError

grav_pot(x, y, rho0, gamma, center_x=0, center_y=0)[source]

Gravitational potential (modulo 4 pi G and rho0 in appropriate units)

Parameters:
  • x
  • y
  • rho0
  • gamma
  • center_x
  • center_y
Returns:

hessian(x, y, theta_E, gamma, center_x=0.0, center_y=0.0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2.

Parameters:kwargs – keywords of the profile
Returns:raise as definition is not defined
lower_limit_default = {'center_x': -100, 'center_y': -100, 'gamma': 1.5, 'theta_E': 0}
mass_2d(r, rho0, gamma)[source]

Mass enclosed projected 2d sphere of radius r.

Parameters:
  • r
  • rho0
  • gamma
Returns:

mass_2d_lens(r, theta_E, gamma)[source]
Parameters:
  • r – projected radius
  • theta_E – Einstein radius
  • gamma – power-law slope
Returns:

2d projected radius enclosed

static mass_3d(r, rho0, gamma)[source]

Mass enclosed a 3d sphere or radius r.

Parameters:
  • r
  • rho0
  • gamma
Returns:

mass_3d_lens(r, theta_E, gamma)[source]
Parameters:
  • r
  • theta_E
  • gamma
Returns:

param_names = ['theta_E', 'gamma', 'center_x', 'center_y']
static rho2theta(rho0, gamma)[source]

Converts 3d density into 2d projected density parameter.

Parameters:
  • rho0
  • gamma
Returns:

static theta2rho(theta_E, gamma)[source]

Converts projected density parameter (in units of deflection) into 3d density parameter.

Parameters:
  • theta_E
  • gamma
Returns:

upper_limit_default = {'center_x': 100, 'center_y': 100, 'gamma': 2.5, 'theta_E': 100}

lenstronomy.LensModel.Profiles.tnfw module

class TNFW[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains functions concerning the truncated NFW profile with a truncation function (r_trunc^2)*(r^2+r_trunc^2)

density equation is:

\[\rho(r) = \frac{r_\text{trunc}^2}{r^2+r_\text{trunc}^2}\frac{\rho_0(\alpha_{R_s})}{r/R_s(1+r/R_s)^2}\]

relation are: R_200 = c * Rs

F(x)[source]

Classic NFW function in terms of arctanh and arctan.

Parameters:x – r/Rs
Returns:
__init__()[source]
static alpha2rho0(alpha_Rs, Rs)[source]

Convert angle at Rs into rho0; neglects the truncation.

Parameters:
  • alpha_Rs – deflection angle at RS
  • Rs – scale radius
Returns:

density normalization (characteristic density)

static density(r, Rs, rho0, r_trunc)[source]

Three dimensional truncated NFW profile.

Parameters:
  • r (float/numpy array) – radius of interest
  • Rs (float > 0) – scale radius
  • r_trunc (float > 0) – truncation radius (angular units)
Returns:

rho(r) density

density_2d(x, y, Rs, rho0, r_trunc, center_x=0, center_y=0)[source]

Projected two dimensional NFW profile (kappa*Sigma_crit)

Parameters:
  • R (float/numpy array) – projected radius of interest
  • Rs (float) – scale radius
  • rho0 (float) – density normalization (characteristic density)
  • r_trunc (float > 0) – truncation radius (angular units)
Returns:

Epsilon(R) projected density at radius R

derivatives(x, y, Rs, alpha_Rs, r_trunc, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function (integral of TNFW), which are the deflection angles.

Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • Rs – turn over point in the slope of the NFW profile in angular unit
  • alpha_Rs – deflection (angular units) at projected Rs
  • r_trunc – truncation radius (angular units)
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

deflection angle in x, deflection angle in y

function(x, y, Rs, alpha_Rs, r_trunc, center_x=0, center_y=0)[source]
Parameters:
  • x – angular position
  • y – angular position
  • Rs – angular turn over point
  • alpha_Rs – deflection at Rs
  • r_trunc – truncation radius
  • center_x – center of halo
  • center_y – center of halo
Returns:

lensing potential

hessian(x, y, Rs, alpha_Rs, r_trunc, center_x=0, center_y=0)[source]

Returns d^2f/dx^2, d^2f/dxdy, d^2f/dydx, d^2f/dy^2 of the TNFW potential f.

Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • Rs – turn over point in the slope of the NFW profile in angular unit
  • alpha_Rs – deflection (angular units) at projected Rs
  • r_trunc – truncation radius (angular units)
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy

lower_limit_default = {'Rs': 0, 'alpha_Rs': 0, 'center_x': -100, 'center_y': -100, 'r_trunc': 0}
mass_2d(R, Rs, rho0, r_trunc)[source]

Analytic solution of the projection integral (convergence)

Parameters:
  • R – projected radius
  • Rs – scale radius
  • rho0 – density normalization (characteristic density)
  • r_trunc – truncation radius (angular units)
Returns:

mass enclosed 2d projected cylinder

mass_3d(r, Rs, rho0, r_trunc)[source]

Mass enclosed a 3d sphere or radius r.

Parameters:
  • r – 3d radius
  • Rs – scale radius
  • rho0 – density normalization (characteristic density)
  • r_trunc – truncation radius (angular units)
Returns:

M(<r)

nfwAlpha(R, Rs, rho0, r_trunc, ax_x, ax_y)[source]

Deflection angel of NFW profile along the projection to coordinate axis.

Parameters:
  • R (float/numpy array) – radius of interest
  • Rs (float) – scale radius
  • rho0 (float) – density normalization (characteristic density)
  • r_trunc (float > 0) – truncation radius (angular units)
  • axis (same as R) – projection to either x- or y-axis
Returns:

nfwGamma(R, Rs, rho0, r_trunc, ax_x, ax_y)[source]

Shear gamma of NFW profile (times Sigma_crit) along the projection to coordinate ‘axis’.

Parameters:
  • R (float/numpy array) – radius of interest
  • Rs (float) – scale radius
  • rho0 (float) – density normalization (characteristic density)
  • r_trunc (float > 0) – truncation radius (angular units)
  • axis (same as R) – projection to either x- or y-axis
Returns:

nfwPot(R, Rs, rho0, r_trunc)[source]

Lensing potential of truncated NFW profile.

Parameters:
  • R (float/numpy array) – radius of interest
  • Rs (float) – scale radius
  • rho0 (float) – density normalization (characteristic density)
  • r_trunc (float > 0) – truncation radius (angular units)
Returns:

lensing potential

param_names = ['Rs', 'alpha_Rs', 'r_trunc', 'center_x', 'center_y']
profile_name = 'TNFW'
static rho02alpha(rho0, Rs)[source]

Convert rho0 to angle at Rs; neglects the truncation.

Parameters:
  • rho0 – density normalization (characteristic density)
  • Rs – scale radius
Returns:

deflection angle at RS

upper_limit_default = {'Rs': 100, 'alpha_Rs': 10, 'center_x': 100, 'center_y': 100, 'r_trunc': 100}

lenstronomy.LensModel.Profiles.tnfw_ellipse module

class TNFW_ELLIPSE[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains functions concerning the truncated NFW profile with an ellipticity defined in the potential parameterization of alpha_Rs, Rs and r_trunc is the same as for the spherical NFW profile.

from Glose & Kneib: https://cds.cern.ch/record/529584/files/0112138.pdf

relation are: R_200 = c * Rs

__init__()[source]
density_lens(r, Rs, alpha_Rs, r_trunc, e1=1, e2=0)[source]

Computes the density at 3d radius r given lens model parameterization. The integral in the LOS projection of this quantity results in the convergence quantity.

Parameters:
  • r – 3d radios
  • Rs – turn-over radius of NFW profile
  • alpha_Rs – deflection at Rs
  • r_trunc – truncation radius
  • e1 – eccentricity component in x-direction
  • e2 – eccentricity component in y-direction
Returns:

density rho(r)

derivatives(x, y, Rs, alpha_Rs, r_trunc, e1, e2, center_x=0, center_y=0)[source]

Returns df/dx and df/dy of the function, calculated as an elliptically distorted deflection angle of the spherical NFW profile.

Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • Rs – turn over point in the slope of the NFW profile in angular unit
  • alpha_Rs – deflection (angular units) at projected Rs
  • r_trunc – truncation radius
  • e1 – eccentricity component in x-direction
  • e2 – eccentricity component in y-direction
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

deflection in x-direction, deflection in y-direction

function(x, y, Rs, alpha_Rs, r_trunc, e1, e2, center_x=0, center_y=0)[source]

Returns elliptically distorted NFW lensing potential.

Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • Rs – turn over point in the slope of the NFW profile in angular unit
  • alpha_Rs – deflection (angular units) at projected Rs
  • r_trunc – truncation radius
  • e1 – eccentricity component in x-direction
  • e2 – eccentricity component in y-direction
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

lensing potential

hessian(x, y, Rs, alpha_Rs, r_trunc, e1, e2, center_x=0, center_y=0)[source]

Returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy the calculation is performed as a numerical differential from the deflection field. Analytical relations are possible.

Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • Rs – turn over point in the slope of the NFW profile in angular unit
  • alpha_Rs – deflection (angular units) at projected Rs
  • r_trunc – truncation radius
  • e1 – eccentricity component in x-direction
  • e2 – eccentricity component in y-direction
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2

lower_limit_default = {'Rs': 0, 'alpha_Rs': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'r_trunc': 0}
mass_3d_lens(r, Rs, alpha_Rs, r_trunc, e1=1, e2=0)[source]
Parameters:
  • r – radius (in angular units)
  • Rs – turn-over radius of NFW profile
  • alpha_Rs – deflection at Rs
  • r_trunc – truncation radius
  • e1 – eccentricity component in x-direction
  • e2 – eccentricity component in y-direction
Returns:

param_names = ['Rs', 'alpha_Rs', 'r_trunc', 'e1', 'e2', 'center_x', 'center_y']
profile_name = 'TNFW_ELLIPSE'
upper_limit_default = {'Rs': 100, 'alpha_Rs': 10, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'r_trunc': 100}

lenstronomy.LensModel.Profiles.uldm module

class Uldm(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.base_profile.LensProfileBase

This class contains functions concerning the ULDM soliton density profile, whose good approximation is (see for example https://arxiv.org/pdf/1406.6586.pdf )

\[\rho = \rho_0 (1 + a(\theta/\theta_c)^2)^{-\beta}\]

where \(\theta_c\) is the core radius, corresponding to the radius where the density drops by half its central value, :math: beta is the slope (called just slope in the parameters of this model), :math: rho_0 = kappa_0 Sigma_c/D_lens, and :math: a is a parameter, dependent on :math: beta, chosen such that :math: theta_c indeed corresponds to the radius where the density drops by half (simple math gives :math: a = 0.5^{-1/beta} - 1 ). For an ULDM soliton profile without contributions to background potential, it turns out that :math: beta = 8, a = 0.091. We allow :math: beta to be different from 8 to model solitons which feel the influence of background potential (see 2105.10873) The profile has, as parameters:

  • kappa_0: central convergence
  • theta_c: core radius (in arcseconds)
  • slope: exponent entering the profile, default value is 8
static alpha_radial(r, kappa_0, theta_c, slope=8)[source]

Returns the radial part of the deflection angle.

Parameters:
  • kappa_0 – central convergence of profile
  • theta_c – core radius (in arcsec)
  • slope – exponent entering the profile
  • r – radius where the deflection angle is computed
Returns:

radial deflection angle

density(R, kappa_0, theta_c, slope=8)[source]

Three dimensional ULDM profile in angular units (rho0_physical = rho0_angular Sigma_crit / D_lens)

Parameters:
  • R – radius of interest
  • kappa_0 – central convergence of profile
  • theta_c – core radius (in arcsec)
  • slope – exponent entering the profile
Returns:

rho(R) density in angular units

density_2d(x, y, kappa_0, theta_c, center_x=0, center_y=0, slope=8)[source]

Projected two dimensional ULDM profile (convergence * Sigma_crit), but given our units convention for rho0, it is basically the convergence.

Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • kappa_0 – central convergence of profile
  • theta_c – core radius (in arcsec)
  • slope – exponent entering the profile
Returns:

Epsilon(R) projected density at radius R

density_lens(r, kappa_0, theta_c, slope=8)[source]

Computes the density at 3d radius r given lens model parameterization. The integral in the LOS projection of this quantity results in the convergence quantity.

Parameters:
  • r – 3d radius
  • kappa_0 – central convergence of profile
  • theta_c – core radius (in arcsec)
  • slope – exponent entering the profile
Returns:

density rho(r)

derivatives(x, y, kappa_0, theta_c, center_x=0, center_y=0, slope=8)[source]

Returns df/dx and df/dy of the function (lensing potential), which are the deflection angles.

Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • kappa_0 – central convergence of profile
  • theta_c – core radius (in arcsec)
  • slope – exponent entering the profile
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

deflection angle in x, deflection angle in y

function(x, y, kappa_0, theta_c, center_x=0, center_y=0, slope=8)[source]
Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • kappa_0 – central convergence of profile
  • theta_c – core radius (in arcsec)
  • slope – exponent entering the profile
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

lensing potential (in arcsec^2)

hessian(x, y, kappa_0, theta_c, center_x=0, center_y=0, slope=8)[source]
Parameters:
  • x – angular position (normally in units of arc seconds)
  • y – angular position (normally in units of arc seconds)
  • kappa_0 – central convergence of profile
  • theta_c – core radius (in arcsec)
  • slope – exponent entering the profile
  • center_x – center of halo (in angular units)
  • center_y – center of halo (in angular units)
Returns:

Hessian matrix of function d^2f/dx^2, d^2/dxdy, d^2/dydx, d^f/dy^2

static kappa_r(R, kappa_0, theta_c, slope=8)[source]

Convergence of the cored density profile. This routine is also for testing.

Parameters:
  • R – radius (angular scale)
  • kappa_0 – convergence in the core
  • theta_c – core radius
  • slope – exponent entering the profile
Returns:

convergence at r

lower_limit_default = {'center_x': -100, 'center_y': -100, 'kappa_0': 0, 'slope': 3.5, 'theta_c': 0}
mass_2d(R, kappa_0, theta_c, slope=8)[source]

Mass enclosed a 2d sphere or radius r.

Parameters:
  • R – radius over which the mass is computed
  • kappa_0 – central convergence of profile
  • theta_c – core radius (in arcsec)
  • slope – exponent entering the profile
Returns:

mass enclosed in 2d sphere

mass_3d(R, kappa_0, theta_c, slope=8)[source]

Mass enclosed a 3d sphere or radius r.

Parameters:
  • R – radius in arcseconds
  • kappa_0 – central convergence of profile
  • theta_c – core radius (in arcsec)
  • slope – exponent entering the profile
Returns:

mass of soliton in angular units

mass_3d_lens(r, kappa_0, theta_c, slope=8)[source]

Mass enclosed a 3d sphere or radius r.

Parameters:
  • r – radius over which the mass is computed
  • kappa_0 – central convergence of profile
  • theta_c – core radius (in arcsec)
  • slope – exponent entering the profile
Returns:

mass enclosed in 3D ball

param_names = ['kappa_0', 'theta_c', 'slope', 'center_x', 'center_y']
static rhotilde(kappa_0, theta_c, slope=8)[source]

Computes the central density in angular units.

Parameters:
  • kappa_0 – central convergence of profile
  • theta_c – core radius (in arcsec)
  • slope – exponent entering the profile
Returns:

central density in 1/arcsec

upper_limit_default = {'center_x': 100, 'center_y': 100, 'kappa_0': 1.0, 'slope': 10, 'theta_c': 100}

Module contents