lenstronomy.LightModel.Profiles package

Submodules

lenstronomy.LightModel.Profiles.chameleon module

class Chameleon[source]

Bases: object

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

__init__()[source]

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

function(x, y, amp, w_c, w_t, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – ra-coordinate
  • y – dec-coordinate
  • w_c
  • w_t
  • amp – amplitude of first power-law flux
  • e1 – eccentricity parameter
  • e2 – eccentricity parameter
  • center_x – center
  • center_y – center
Returns:

flux of chameleon profile

light_3d(r, amp, w_c, w_t, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • r – 3d radius
  • w_c
  • w_t
  • amp – amplitude of first power-law flux
  • e1 – eccentricity parameter
  • e2 – eccentricity parameter
  • center_x – center
  • center_y – center
Returns:

3d flux of chameleon profile at radius r

lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'w_c': 0, 'w_t': 0}
param_names = ['amp', 'w_c', 'w_t', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'amp': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'w_c': 100, 'w_t': 100}
class DoubleChameleon[source]

Bases: object

Class of the double Chameleon model.

See Dutton+2011, Suyu+2014 for the single Chameleon model.

__init__()[source]

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

function(x, y, amp, ratio, w_c1, w_t1, e11, e21, w_c2, w_t2, e12, e22, center_x=0, center_y=0)[source]
Parameters:
  • x
  • y
  • amp
  • ratio
  • w_c1
  • w_t1
  • e11
  • e21
  • w_c2
  • w_t2
  • e12
  • e22
  • center_x
  • center_y
Returns:

light_3d(r, amp, ratio, w_c1, w_t1, e11, e21, w_c2, w_t2, e12, e22, center_x=0, center_y=0)[source]
Parameters:
  • r – 3d radius
  • amp
  • ratio – ratio of first to second amplitude of Chameleon surface brightness
  • w_c1
  • w_t1
  • e11
  • e21
  • w_c2
  • w_t2
  • e12
  • e22
  • center_x
  • center_y
Returns:

3d light density at radius r

lower_limit_default = {'amp': 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}
param_names = ['amp', 'ratio', 'w_c1', 'w_t1', 'e11', 'e21', 'w_c2', 'w_t2', 'e12', 'e22', 'center_x', 'center_y']
upper_limit_default = {'amp': 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: object

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.

function(x, y, amp, 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:
  • x
  • y
  • amp
  • 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
  • w_c3
  • w_t3
  • e13
  • e23
  • center_x
  • center_y
Returns:

light_3d(r, amp, 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 light radius
  • amp
  • 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
  • w_c3
  • w_t3
  • e13
  • e23
  • center_x
  • center_y
Returns:

lower_limit_default = {'amp': 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.0, 'w_c1': 0, 'w_c2': 0, 'w_c3': 0, 'w_t1': 0, 'w_t2': 0, 'w_t3': 0}
param_names = ['amp', 'ratio12', 'ratio13', 'w_c1', 'w_t1', 'e11', 'e21', 'w_c2', 'w_t2', 'e12', 'e22', 'w_c3', 'w_t3', 'e13', 'e23', 'center_x', 'center_y']
upper_limit_default = {'amp': 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}

lenstronomy.LightModel.Profiles.ellipsoid module

class Ellipsoid[source]

Bases: object

Class for an universal surface brightness within an ellipsoid.

__init__()[source]

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

function(x, y, amp, radius, e1, e2, center_x, center_y)[source]
Parameters:
  • x
  • y
  • amp – surface brightness within the ellipsoid
  • radius – radius (product average of semi-major and semi-minor axis) of the ellipsoid
  • e1 – eccentricity
  • e2 – eccentricity
  • center_x – center
  • center_y – center
Returns:

surface brightness

lenstronomy.LightModel.Profiles.gaussian module

class Gaussian[source]

Bases: object

Class for Gaussian light profile The two-dimensional Gaussian profile amplitude is defined such that the 2D integral leads to the ‘amp’ value.

profile name in LightModel module: ‘GAUSSIAN’

__init__()[source]

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

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

Surface brightness per angular unit.

Parameters:
  • x – coordinate on the sky
  • y – coordinate on the sky
  • amp – amplitude, such that 2D integral leads to this value
  • sigma – sigma of Gaussian in each direction
  • center_x – center of profile
  • center_y – center of profile
Returns:

surface brightness at (x, y)

light_3d(r, amp, sigma)[source]

3D brightness per angular volume element.

Parameters:
  • r – 3d distance from center of profile
  • amp – amplitude, such that 2D integral leads to this value
  • sigma – sigma of Gaussian in each direction
Returns:

3D brightness per angular volume element

total_flux(amp, sigma, center_x=0, center_y=0)[source]

Integrated flux of the profile.

Parameters:
  • amp – amplitude, such that 2D integral leads to this value
  • sigma – sigma of Gaussian in each direction
  • center_x – center of profile
  • center_y – center of profile
Returns:

total flux

class GaussianEllipse[source]

Bases: object

Class for Gaussian light profile with ellipticity.

profile name in LightModel module: ‘GAUSSIAN_ELLIPSE’

__init__()[source]

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

function(x, y, amp, sigma, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – coordinate on the sky
  • y – coordinate on the sky
  • amp – amplitude, such that 2D integral leads to this value
  • sigma – sigma of Gaussian in each direction
  • e1 – eccentricity modulus
  • e2 – eccentricity modulus
  • center_x – center of profile
  • center_y – center of profile
Returns:

surface brightness at (x, y)

light_3d(r, amp, sigma, e1=0, e2=0)[source]

3D brightness per angular volume element.

Parameters:
  • r – 3d distance from center of profile
  • amp – amplitude, such that 2D integral leads to this value
  • sigma – sigma of Gaussian in each direction
  • e1 – eccentricity modulus
  • e2 – eccentricity modulus
Returns:

3D brightness per angular volume element

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']
total_flux(amp, sigma=None, e1=None, e2=None, center_x=None, center_y=None)[source]

Total integrated flux of profile.

Parameters:
  • amp – amplitude, such that 2D integral leads to this value
  • sigma – sigma of Gaussian in each direction
  • e1 – eccentricity modulus
  • e2 – eccentricity modulus
  • center_x – center of profile
  • center_y – center of profile
Returns:

total flux

upper_limit_default = {'amp': 1000, 'center_x': 100, 'center_y': 100, 'e1': -0.5, 'e2': -0.5, 'sigma': 100}
class MultiGaussian[source]

Bases: object

Class for elliptical pseudo Jaffe lens light (2d projected light/mass distribution.

profile name in LightModel module: ‘MULTI_GAUSSIAN’

__init__()[source]

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

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

Surface brightness per angular unit.

Parameters:
  • x – coordinate on the sky
  • y – coordinate on the sky
  • amp – list of amplitudes of individual Gaussian profiles
  • sigma – list of widths of individual Gaussian profiles
  • center_x – center of profile
  • center_y – center of profile
Returns:

surface brightness at (x, y)

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

Split surface brightness in individual components.

Parameters:
  • x – coordinate on the sky
  • y – coordinate on the sky
  • amp – list of amplitudes of individual Gaussian profiles
  • sigma – list of widths of individual Gaussian profiles
  • center_x – center of profile
  • center_y – center of profile
Returns:

list of arrays of surface brightness

light_3d(r, amp, sigma)[source]

3D brightness per angular volume element.

Parameters:
  • r – 3d distance from center of profile
  • amp – list of amplitudes of individual Gaussian profiles
  • sigma – list of widths of individual Gaussian profiles
Returns:

3D brightness per angular volume element

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

Total integrated flux of profile.

Parameters:
  • amp – list of amplitudes of individual Gaussian profiles
  • sigma – list of widths of individual Gaussian profiles
  • center_x – center of profile
  • center_y – center of profile
Returns:

total flux

upper_limit_default = {'amp': 1000, 'center_x': 100, 'center_y': 100, 'e1': -0.5, 'e2': -0.5, 'sigma': 100}
class MultiGaussianEllipse[source]

Bases: object

Class for elliptical multi Gaussian profile.

profile name in LightModel module: ‘MULTI_GAUSSIAN_ELLIPSE’

__init__()[source]

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

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

Surface brightness per angular unit.

Parameters:
  • x – coordinate on the sky
  • y – coordinate on the sky
  • amp – list of amplitudes of individual Gaussian profiles
  • sigma – list of widths of individual Gaussian profiles
  • e1 – eccentricity modulus
  • e2 – eccentricity modulus
  • center_x – center of profile
  • center_y – center of profile
Returns:

surface brightness at (x, y)

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

Split surface brightness in individual components.

Parameters:
  • x – coordinate on the sky
  • y – coordinate on the sky
  • amp – list of amplitudes of individual Gaussian profiles
  • sigma – list of widths of individual Gaussian profiles
  • e1 – eccentricity modulus
  • e2 – eccentricity modulus
  • center_x – center of profile
  • center_y – center of profile
Returns:

list of arrays of surface brightness

light_3d(r, amp, sigma, e1=0, e2=0)[source]

3D brightness per angular volume element.

Parameters:
  • r – 3d distance from center of profile
  • amp – list of amplitudes of individual Gaussian profiles
  • sigma – list of widths of individual Gaussian profiles
  • e1 – eccentricity modulus
  • e2 – eccentricity modulus
Returns:

3D brightness per angular volume element

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']
total_flux(amp, sigma, e1, e2, center_x=0, center_y=0)[source]

Total integrated flux of profile.

Parameters:
  • amp – list of amplitudes of individual Gaussian profiles
  • sigma – list of widths of individual Gaussian profiles
  • e1 – eccentricity modulus
  • e2 – eccentricity modulus
  • center_x – center of profile
  • center_y – center of profile
Returns:

total flux

upper_limit_default = {'amp': 1000, 'center_x': 100, 'center_y': 100, 'e1': -0.5, 'e2': -0.5, 'sigma': 100}

lenstronomy.LightModel.Profiles.hernquist module

class Hernquist[source]

Bases: object

Class for pseudo Jaffe lens light (2d projected light/mass distribution.

__init__()[source]

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

function(x, y, amp, Rs, center_x=0, center_y=0)[source]
Parameters:
  • x
  • y
  • amp
  • Rs – scale radius: half-light radius = Rs / 0.551
  • center_x
  • center_y
Returns:

light_3d(r, amp, Rs)[source]
Parameters:
  • r
  • amp
  • Rs
Returns:

class HernquistEllipse[source]

Bases: object

Class for elliptical pseudo Jaffe lens light (2d projected light/mass distribution.

__init__()[source]

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

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

light_3d(r, amp, Rs, e1=0, e2=0)[source]
Parameters:
  • r
  • amp
  • Rs
  • e1
  • e2
Returns:

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

lenstronomy.LightModel.Profiles.interpolation module

class Interpol[source]

Bases: object

Class which uses an interpolation of an image to compute the surface brightness.

parameters are ‘image’: 2d numpy array of surface brightness per square arc second (not integrated flux per pixel!) ‘center_x’: coordinate of center of image in angular units (i.e. arc seconds) ‘center_y’: coordinate of center of image in angular units (i.e. arc seconds) ‘phi_G’: rotation of image relative to the rectangular ra-to-dec orientation ‘scale’: arcseconds per pixel of the image to be interpolated

__init__()[source]

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

static coord2image_pixel(ra, dec, center_x, center_y, phi_G, scale)[source]
Parameters:
  • ra – angular coordinate
  • dec – angular coordinate
  • center_x – center of image in angular coordinates
  • center_y – center of image in angular coordinates
  • phi_G – rotation angle
  • scale – pixel scale of image
Returns:

pixel coordinates

delete_cache()[source]

Delete the cached interpolated image.

function(x, y, image=None, amp=1, center_x=0, center_y=0, phi_G=0, scale=1)[source]
Parameters:
  • x – x-coordinate to evaluate surface brightness
  • y – y-coordinate to evaluate surface brightness
  • image (2d numpy array) – pixelized surface brightness (an image) to be used to interpolate in units of surface brightness (flux per square arc seconds, not flux per pixel!)
  • amp – amplitude of surface brightness scaling in respect of original input image
  • center_x – center of interpolated image
  • center_y – center of interpolated image
  • phi_G – rotation angle of simulated image in respect to input gird
  • scale – pixel scale (in angular units) of the simulated image
Returns:

surface brightness from the model at coordinates (x, y)

image_interp(x, y, image)[source]
lower_limit_default = {'amp': 0, 'center_x': -1000, 'center_y': -1000, 'phi_G': -3.141592653589793, 'scale': 1e-09}
param_names = ['image', 'amp', 'center_x', 'center_y', 'phi_G', 'scale']
static total_flux(image, scale, amp=1, center_x=0, center_y=0, phi_G=0)[source]

Sums up all the image surface brightness (image pixels defined in surface brightness at the coordinate of the pixel) times pixel area.

Parameters:
  • image – pixelized surface brightness used to interpolate in units of surface brightness (flux per square arc seconds, not flux per pixel!)
  • scale – scale of the pixel in units of angle
  • amp – linear scaling parameter of the surface brightness multiplicative with the initial image
  • center_x – center of image in angular coordinates
  • center_y – center of image in angular coordinates
  • phi_G – rotation angle
Returns:

total flux of the image

upper_limit_default = {'amp': 1000000, 'center_x': 1000, 'center_y': 1000, 'phi_G': 3.141592653589793, 'scale': 10000000000}

lenstronomy.LightModel.Profiles.moffat module

class Moffat[source]

Bases: object

This class contains functions to evaluate a Moffat surface brightness profile.

\[I(r) = I_0 * (1 + (r/\alpha)^2)^{-\beta}\]

with \(I_0 = amp\).

__init__()[source]

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

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

2D Moffat profile.

Parameters:
  • x – x-position (angle)
  • y – y-position (angle)
  • amp – normalization
  • alpha – scale
  • beta – exponent
  • center_x – x-center
  • center_y – y-center
Returns:

surface brightness

lenstronomy.LightModel.Profiles.nie module

class NIE[source]

Bases: lenstronomy.LightModel.Profiles.profile_base.LightProfileBase

Non-divergent isothermal ellipse (projected) This is effectively the convergence profile of the NIE lens model with an amplitude ‘amp’ rather than an Einstein radius ‘theta_E’.

function(x, y, amp, e1, e2, s_scale, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • amp – surface brightness normalization
  • e1 – eccentricity component
  • e2 – eccentricity component
  • s_scale – smoothing scale (square averaged of minor and major axis)
  • center_x – center of profile
  • center_y – center of profile
Returns:

surface brightness of NIE profile

light_3d(r, amp, e1, e2, s_scale, center_x=0, center_y=0)[source]

3d light distribution (in spherical regime)

Parameters:
  • r – 3d radius
  • amp – surface brightness normalization
  • e1 – eccentricity component
  • e2 – eccentricity component
  • s_scale – smoothing scale (square averaged of minor and major axis)
  • center_x – center of profile
  • center_y – center of profile
Returns:

light density at 3d radius

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

lenstronomy.LightModel.Profiles.p_jaffe module

class PJaffe[source]

Bases: object

Class for pseudo Jaffe lens light (2d projected light/mass distribution)

__init__()[source]

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

function(x, y, amp, Ra, Rs, center_x=0, center_y=0)[source]
Parameters:
  • x
  • y
  • amp
  • Ra
  • Rs
  • center_x
  • center_y
Returns:

light_3d(r, amp, Ra, Rs)[source]
Parameters:
  • r
  • amp
  • Rs
  • Ra
Returns:

lower_limit_default = {'Ra': 0, 'Rs': 0, 'amp': 0, 'center_x': -100, 'center_y': -100}
param_names = ['amp', 'Ra', 'Rs', 'center_x', 'center_y']
upper_limit_default = {'Ra': 100, 'Rs': 100, 'amp': 100, 'center_x': 100, 'center_y': 100}
class PJaffeEllipse[source]

Bases: object

Calss for elliptical pseudo Jaffe lens light.

__init__()[source]

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

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

light_3d(r, amp, Ra, Rs, e1=0, e2=0)[source]
Parameters:
  • r
  • amp
  • Ra
  • Rs
Returns:

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

lenstronomy.LightModel.Profiles.power_law module

class PowerLaw[source]

Bases: object

Class for power-law elliptical light distribution.

__init__()[source]

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

function(x, y, amp, gamma, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – ra-coordinate
  • y – dec-coordinate
  • amp – amplitude of flux
  • gamma – projected power-law slope
  • e1 – ellipticity
  • e2 – ellipticity
  • center_x – center
  • center_y – center
Returns:

projected flux

light_3d(r, amp, gamma, e1=0, e2=0)[source]
Parameters:
  • r
  • amp
  • gamma
  • e1
  • e2
Returns:

lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'gamma': 1}
param_names = ['amp', 'gamma', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'amp': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'gamma': 3}

lenstronomy.LightModel.Profiles.profile_base module

class LightProfileBase[source]

Bases: object

Base class of all light profiles.

__init__()[source]

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

function(*args, **kwargs)[source]
Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • kwargs – keyword arguments of profile
Returns:

surface brightness, raise as definition is not defined

light_3d(*args, **kwargs)[source]
Parameters:
  • r – 3d radius
  • kwargs – keyword arguments of profile
Returns:

3d light profile, raise as definition is not defined

lenstronomy.LightModel.Profiles.sersic module

class Sersic(smoothing=1e-05, sersic_major_axis=False)[source]

Bases: lenstronomy.LensModel.Profiles.sersic_utils.SersicUtil

This class contains functions to evaluate a spherical Sersic function.

\[I(R) = I_0 \exp \left[ -b_n (R/R_{\rm Sersic})^{\frac{1}{n}}\right]\]

with \(I_0 = amp\) and with \(b_{n}\approx 1.999n-0.327\)

function(x, y, amp, R_sersic, n_sersic, center_x=0, center_y=0, max_R_frac=1000.0)[source]
Parameters:
  • x
  • y
  • amp – surface brightness/amplitude value at the half light radius
  • R_sersic – semi-major axis half light radius
  • n_sersic – Sersic index
  • center_x – center in x-coordinate
  • center_y – center in y-coordinate
  • max_R_frac – maximum window outside which the mass is zeroed, in units of R_sersic (float)
Returns:

Sersic profile value at (x, y)

lower_limit_default = {'R_sersic': 0, 'amp': 0, 'center_x': -100, 'center_y': -100, 'n_sersic': 0.5}
param_names = ['amp', 'R_sersic', 'n_sersic', 'center_x', 'center_y']
upper_limit_default = {'R_sersic': 100, 'amp': 100, 'center_x': 100, 'center_y': 100, 'n_sersic': 8}
class SersicElliptic(smoothing=1e-05, sersic_major_axis=False)[source]

Bases: lenstronomy.LensModel.Profiles.sersic_utils.SersicUtil

This class contains functions to evaluate an elliptical Sersic function.

\[I(R) = I_0 \exp \left[ -b_n (R/R_{\rm Sersic})^{\frac{1}{n}}\right]\]

with \(I_0 = amp\), \(R = \sqrt{q \theta^2_x + \theta^2_y/q}\) and with \(b_{n}\approx 1.999n-0.327\)

function(x, y, amp, R_sersic, n_sersic, e1, e2, center_x=0, center_y=0, max_R_frac=1000.0)[source]
Parameters:
  • x
  • y
  • amp – surface brightness/amplitude value at the half light radius
  • R_sersic – half light radius (either semi-major axis or product average of semi-major and semi-minor axis)
  • n_sersic – Sersic index
  • e1 – eccentricity parameter e1
  • e2 – eccentricity parameter e2
  • center_x – center in x-coordinate
  • center_y – center in y-coordinate
  • max_R_frac – maximum window outside which the mass is zeroed, in units of R_sersic (float)
Returns:

Sersic profile value at (x, y)

lower_limit_default = {'R_sersic': 0, 'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'n_sersic': 0.5}
param_names = ['amp', 'R_sersic', 'n_sersic', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'R_sersic': 100, 'amp': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'n_sersic': 8}
class SersicElliptic_qPhi(*args, **kwargs)[source]

Bases: lenstronomy.LensModel.Profiles.sersic_utils.SersicUtil

This class is the same as SersicElliptic except sampling over q and phi instead of e1 and e2.

__init__(*args, **kwargs)[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)
function(x, y, amp, R_sersic, n_sersic, q, phi, center_x=0, center_y=0, max_R_frac=100.0)[source]
Parameters:
  • x
  • y
  • amp – surface brightness/amplitude value at the half light radius
  • R_sersic – half light radius (either semi-major axis or product average of semi-major and semi-minor axis)
  • n_sersic – Sersic index
  • q – axis ratio
  • phi – position angle (radians)
  • center_x – center in x-coordinate
  • center_y – center in y-coordinate
  • max_R_frac – maximum window outside of which the mass is zeroed, in units of R_sersic (float)
Returns:

Sersic profile value at (x, y)

lower_limit_default = {'R_sersic': 0, 'amp': 0, 'center_x': -100, 'center_y': -100, 'n_sersic': 0.5, 'phi': -3.141592653589793, 'q': 0}
param_names = ['amp', 'R_sersic', 'n_sersic', 'q', 'phi', 'center_x', 'center_y']
upper_limit_default = {'R_sersic': 100, 'amp': 100, 'center_x': 100, 'center_y': 100, 'n_sersic': 8, 'phi': 3.141592653589793, 'q': 1.0}
class CoreSersic(smoothing=1e-05, sersic_major_axis=False)[source]

Bases: lenstronomy.LensModel.Profiles.sersic_utils.SersicUtil

This class contains the Core-Sersic function introduced by e.g. Trujillo et al. 2004.

\[I(R) = I' \left[1 + (R_b/R)^{\alpha} \right]^{\gamma / \alpha} \exp \left{ -b_n \left[(R^{\alpha} + R_b^{\alpha})/R_e^{\alpha} \right]^{1 / (n\alpha)} \right}\]

with

\[I' = I_b 2^{-\gamma/ \alpha} \exp \left[b_n 2^{1 / (n\alpha)} (R_b/R_e)^{1/n} \right]\]

where \(I_b\) is the intensity at the break radius and \(R = \sqrt{q \theta^2_x + \theta^2_y/q}\).

function(x, y, amp, R_sersic, Rb, n_sersic, gamma, e1, e2, center_x=0, center_y=0, alpha=3.0, max_R_frac=1000.0)[source]
Parameters:
  • x
  • y
  • amp – surface brightness/amplitude value at the half light radius
  • R_sersic – half light radius (either semi-major axis or product average of semi-major and semi-minor axis)
  • Rb – “break” core radius
  • n_sersic – Sersic index
  • gamma – inner power-law exponent
  • e1 – eccentricity parameter e1
  • e2 – eccentricity parameter e2
  • center_x – center in x-coordinate
  • center_y – center in y-coordinate
  • alpha – sharpness of the transition between the cusp and the outer Sersic profile (float)
  • max_R_frac – maximum window outside which the mass is zeroed, in units of R_sersic (float)
Returns:

Cored Sersic profile value at (x, y)

lower_limit_default = {'Rb': 0, 'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'gamma': 0, 'n_sersic': 0.5}
param_names = ['amp', 'R_sersic', 'Rb', 'n_sersic', 'gamma', 'e1', 'e2', 'center_x', 'center_y']
upper_limit_default = {'Rb': 100, 'amp': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'gamma': 10, 'n_sersic': 8}

lenstronomy.LightModel.Profiles.shapelets module

class Shapelets(interpolation=False, precalc=False, stable_cut=True, cut_scale=5)[source]

Bases: object

Class for 2d cartesian Shapelets.

Sources: Refregier 2003: Shapelets: I. A Method for Image Analysis https://arxiv.org/abs/astro-ph/0105178 Refregier 2003: Shapelets: II. A Method for Weak Lensing Measurements https://arxiv.org/abs/astro-ph/0105179

For one dimension, the shapelets are defined as

\[\phi_n(x) \equiv \left[2^n \pi^{1/2} n! \right]]^{-1/2}H_n(x) e^{-\frac{x^2}{2}}\]

This basis is orthonormal. The dimensional basis function is

\[B_n(x;\beta) \equiv \beta^{-1/2} \phi_n(\beta^{-1}x)\]

which are orthonormal as well.

The two-dimensional basis function is

\[\phi_{\bf n}({f x}) \equiv \phi_{n1}(x1) \phi_{n2}(x2)\]

where \({\bf n} \equiv (n1, n2)\) and \({\bf x} \equiv (x1, x2)\).

The dimensional two-dimentional basis function is

\[B_{\bf n}({\bf x};\beta) \equiv \beta^{-1/2} \phi_{\bf n}(\beta^{-1}{\bf x}).\]
H_n(n, x)[source]

Constructs the Hermite polynomial of order n at position x (dimensionless)

Parameters:
  • n – The n’the basis function.
  • x (float or numpy array.) – 1-dim position (dimensionless)
Returns:

array– H_n(x).

__init__(interpolation=False, precalc=False, stable_cut=True, cut_scale=5)[source]

Load interpolation of the Hermite polynomials in a range [-30,30] in order n<= 150.

Parameters:
  • interpolation – boolean; if True, uses interpolated pre-calculated shapelets in the evaluation
  • precalc – boolean; if True interprets as input (x, y) as pre-calculated normalized shapelets
  • stable_cut – boolean; if True, sets the values outside of \(\sqrt\left(n_{\rm max} + 1 \right) \beta s_{\rm cut scale} = 0\).
  • cut_scale – float, scaling parameter where to cut the shapelets. This is for numerical reasons such that the polynomials in the Hermite function do not get unstable.
function(x, y, amp, beta, n1, n2, center_x, center_y)[source]

2d cartesian shapelet.

Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • amp – amplitude of shapelet
  • beta – scale factor of shapelet
  • n1 – x-order of Hermite polynomial
  • n2 – y-order of Hermite polynomial
  • center_x – center in x
  • center_y – center in y
Returns:

flux surface brightness at (x, y)

hermval(x, n_array, tensor=True)[source]

computes the Hermit polynomial as numpy.polynomial.hermite.hermval difference: for values more than sqrt(n_max + 1) * cut_scale, the value is set to zero this should be faster and numerically stable

Parameters:
  • x – array of values
  • n_array – list of coeffs in H_n
  • tensor – see numpy.polynomial.hermite.hermval
Returns:

see numpy.polynomial.hermite.hermval

lower_limit_default = {'amp': 0, 'beta': 0.01, 'center_x': -100, 'center_y': -100, 'n1': 0, 'n2': 0}
param_names = ['amp', 'beta', 'n1', 'n2', 'center_x', 'center_y']
phi_n(n, x)[source]

Constructs the 1-dim basis function (formula (1) in Refregier et al. 2001)

Parameters:
  • n (int.) – The n’the basis function.
  • x (float or numpy array.) – 1-dim position (dimensionless)
Returns:

array– phi_n(x).

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 for the full order in the polynomials.

Parameters:
  • x – x-coordinates (numpy array)
  • y – 7-coordinates (numpy array)
  • beta – shapelet scale
  • n_order – order of shapelets
  • center_x – shapelet center
  • center_y – shapelet center
Returns:

list of H_n(x) and H_n(y)

upper_limit_default = {'amp': 100, 'beta': 100, 'center_x': 100, 'center_y': 100, 'n1': 150, 'n2': 150}
class ShapeletSet[source]

Bases: object

Class to operate on entire shapelet set limited by a maximal polynomial order n_max, such that n1 + n2 <= n_max.

__init__()[source]

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

decomposition(image, x, y, n_max, beta, deltaPix, center_x=0, center_y=0)[source]

Decomposes an image into the shapelet coefficients in same order as for the function call.

Parameters:
  • image
  • x
  • y
  • n_max
  • beta
  • center_x
  • center_y
Returns:

function(x, y, amp, n_max, beta, center_x=0, center_y=0)[source]
Parameters:
  • x – x-coordinates
  • y – y-coordinates
  • amp – array of amplitudes in pre-defined order of shapelet basis functions
  • beta – shapelet scale
  • n_max – maximum polynomial order in Hermite polynomial
  • center_x – shapelet center
  • center_y – shapelet center
Returns:

surface brightness of combined shapelet set

function_split(x, y, amp, n_max, beta, center_x=0, center_y=0)[source]

Splits shapelet set in list of individual shapelet basis function responses.

Parameters:
  • x – x-coordinates
  • y – y-coordinates
  • amp – array of amplitudes in pre-defined order of shapelet basis functions
  • beta – shapelet scale
  • n_max – maximum polynomial order in Hermite polynomial
  • center_x – shapelet center
  • center_y – shapelet center
Returns:

list of individual shapelet basis function responses

lower_limit_default = {'beta': 0.01, 'center_x': -100, 'center_y': -100}
param_names = ['amp', 'n_max', 'beta', 'center_x', 'center_y']
shapelet_basis_2d(num_order, beta, numPix, deltaPix=1, center_x=0, center_y=0)[source]
Parameters:
  • num_order – max shapelet order
  • beta – shapelet scale
  • numPix – number of pixel of the grid
Returns:

list of shapelets drawn on pixel grid, centered.

upper_limit_default = {'beta': 100, 'center_x': 100, 'center_y': 100}

lenstronomy.LightModel.Profiles.shapelets_polar module

class ShapeletsPolar[source]

Bases: object

2D polar Shapelets, see Massey & Refregier 2005.

__init__()[source]

Load interpolation of the Hermite polynomials in a range [-30,30] in order n<= 150 :return:

function(x, y, amp, beta, n, m, complex_bool, center_x, center_y)[source]
Parameters:
  • x – x-coordinate, numpy array
  • y – y-ccordinate, numpy array
  • amp – amplitude normalization
  • beta – shaplet scale
  • n – order of polynomial
  • m – rotational invariance
  • complex_bool – boolean; if True uses complex value of function _chi_n_m()
  • center_x – center of shapelet
  • center_y – center of shapelet
Returns:

amplitude of shapelet at possition (x, y)

index2poly(index)[source]

Manages the convention from an iterative index to the specific polynomial n, m, (real/imaginary part)

Parameters:index – int, index of list
Returns:n, m bool
lower_limit_default = {'amp': 0, 'beta': 0, 'center_x': -100, 'center_y': -100, 'm': 0, 'n': 0}
static num_param(n_max)[source]
Parameters:n_max – maximal polynomial order
Returns:number of basis components
param_names = ['amp', 'beta', 'n', 'm', 'center_x', 'center_y']
param_names_latex = {'$I_0$', '$\\beta$', '$m$', '$n$', '$x_0$', '$y_0$'}
static poly2index(n, m, complex_bool)[source]
Parameters:
  • n – non-negative integer
  • m – integer, running from -n to n in steps of two
  • complex_bool – bool, if True, assigns complex part
Returns:

upper_limit_default = {'amp': 100, 'beta': 100, 'center_x': 100, 'center_y': 100, 'm': 150, 'n': 150}
class ShapeletsPolarExp[source]

Bases: object

2D exponential shapelets, Berge et al.

2019

__init__()[source]

Load interpolation of the Hermite polynomials in a range [-30,30] in order n<= 150 :return:

function(x, y, amp, beta, n, m, complex_bool, center_x, center_y)[source]
Parameters:
  • x – x-coordinate, numpy array
  • y – y-ccordinate, numpy array
  • amp – amplitude normalization
  • beta – shaplet scale
  • n – order of polynomial
  • m – rotational invariance
  • complex_bool – boolean; if True uses complex value of function _chi_n_m()
  • center_x – center of shapelet
  • center_y – center of shapelet
Returns:

amplitude of shapelet at possition (x, y)

index2poly(index)[source]
Parameters:index
Returns:
lower_limit_default = {'amp': 0, 'beta': 0, 'center_x': -100, 'center_y': -100, 'm': 0, 'n': 0}
static num_param(n_max)[source]
Parameters:n_max – maximal polynomial order
Returns:number of basis components
param_names = ['amp', 'beta', 'n', 'm', 'center_x', 'center_y']
static poly2index(n, m, complex_bool)[source]
Parameters:
  • n
  • m
  • complex_bool
Returns:

index convention, integer

upper_limit_default = {'amp': 100, 'beta': 100, 'center_x': 100, 'center_y': 100, 'm': 150, 'n': 150}
class ShapeletSetPolar(exponential=False)[source]

Bases: object

Class to operate on entire shapelet set.

__init__(exponential=False)[source]

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

decomposition(image, x, y, n_max, beta, deltaPix, center_x=0, center_y=0)[source]

Decomposes an image into the shapelet coefficients in same order as for the function call :param image:

Parameters:
  • x
  • y
  • n_max
  • beta
  • center_x
  • center_y
Returns:

function(x, y, amp, n_max, beta, center_x=0, center_y=0)[source]
Parameters:
  • x
  • y
  • amp
  • n_max
  • beta
  • center_x
  • center_y
Returns:

function_split(x, y, amp, n_max, beta, center_x=0, center_y=0)[source]
index2poly(index)[source]
Parameters:index – index of coefficient in the convention here
Returns:n, m, complex_bool
lower_limit_default = {'beta': 0, 'center_x': -100, 'center_y': -100}
param_names = ['amp', 'n_max', 'beta', 'center_x', 'center_y']
upper_limit_default = {'beta': 100, 'center_x': 100, 'center_y': 100}

lenstronomy.LightModel.Profiles.starlets module

class SLIT_Starlets(thread_count=1, fast_inverse=True, second_gen=False, show_pysap_plots=False, force_no_pysap=False)[source]

Bases: object

Decomposition of an image using the Isotropic Undecimated Walevet Transform, also known as “starlet” or “B-spline”, using the ‘a trous’ algorithm.

Astronomical data (galaxies, stars, …) are often very sparsely represented in the starlet basis.

Based on Starck et al. : https://ui.adsabs.harvard.edu/abs/2007ITIP…16..297S/abstract

__init__(thread_count=1, fast_inverse=True, second_gen=False, show_pysap_plots=False, force_no_pysap=False)[source]

Load pySAP package if found, and initialize the Starlet transform.

Parameters:
  • thread_count – number of threads used for pySAP computations
  • fast_inverse – if True, reconstruction is simply the sum of each scale (only for 1st generation starlet transform)
  • second_gen – if True, uses the second generation of starlet transform
  • show_pysap_plots – if True, displays pySAP plots when calling the decomposition method
  • force_no_pysap – if True, does not load pySAP and computes starlet transforms in python.
decomposition(image, n_scales)[source]

1D starlet transform from starlet coefficients stored in coeffs.

Parameters:
  • image – 2D image to be decomposed, ndarray with shape (sqrt(n_pixels), sqrt(n_pixels))
  • n_scales – number of decomposition scales
Returns:

reconstructed signal as 1D array of shape (n_scales*n_pixels,)

decomposition_2d(image, n_scales)[source]

2D starlet transform from starlet coefficients stored in coeffs.

Parameters:
  • image – 2D image to be decomposed, ndarray with shape (sqrt(n_pixels), sqrt(n_pixels))
  • n_scales – number of decomposition scales
Returns:

reconstructed signal as 2D array of shape (n_scales, sqrt(n_pixels), sqrt(n_pixels))

delete_cache()[source]

Delete the cached interpolated image.

function(x, y, amp=None, n_scales=None, n_pixels=None, scale=1, center_x=0, center_y=0)[source]

1D inverse starlet transform from starlet coefficients stored in coeffs Follows lenstronomy conventions for light profiles.

Parameters:
  • amp – decomposition coefficients (‘amp’ to follow conventions in other light profile) This is an ndarray with shape (n_scales, sqrt(n_pixels), sqrt(n_pixels)) or (n_scales*n_pixels,)
  • n_scales – number of decomposition scales
  • n_pixels – number of pixels in a single scale
Returns:

reconstructed signal as 1D array of shape (n_pixels,)

function_2d(coeffs, n_scales, n_pixels)[source]

2D inverse starlet transform from starlet coefficients stored in coeffs.

Parameters:
  • coeffs – decomposition coefficients, ndarray with shape (n_scales, sqrt(n_pixels), sqrt(n_pixels))
  • n_scales – number of decomposition scales
Returns:

reconstructed signal as 2D array of shape (sqrt(n_pixels), sqrt(n_pixels))

lower_limit_default = {'amp': [0], 'center_x': -1000, 'center_y': -1000, 'n_pixels': 5, 'n_scales': 2, 'scale': 1e-09}
param_names = ['amp', 'n_scales', 'n_pixels', 'scale', 'center_x', 'center_y']
param_names_latex = {'$I_0$', '$n_{\\rm pix}$', '$n_{\\rm scales}$', '$x_0$', '$y_0$', 'scale'}
upper_limit_default = {'amp': [100000000.0], 'center_x': 1000, 'center_y': 1000, 'n_pixels': 10000000000.0, 'n_scales': 20, 'scale': 10000000000}

lenstronomy.LightModel.Profiles.starlets_util module

transform(img, n_scales, second_gen=False)[source]

Performs starlet decomposition of an 2D array.

Parameters:
  • img – input image
  • n_scales – number of decomposition scales
  • second_gen – if True, ‘second generation’ starlets are used
inverse_transform(wave, fast=True, second_gen=False)[source]

Reconstructs an image fron its starlet decomposition coefficients.

Parameters:
  • wave – input coefficients, with shape (n_scales, np.sqrt(n_pixel), np.sqrt(n_pixel))
  • fast – if True, and only with second_gen is False, simply sums up all scales to reconstruct the image
  • second_gen – if True, ‘second generation’ starlets are used

lenstronomy.LightModel.Profiles.uniform module

class Uniform[source]

Bases: object

Uniform light profile.

This profile can also compensate for an inaccurate background subtraction. name for profile: ‘UNIFORM’

__init__()[source]

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

function(x, y, amp)[source]
Parameters:
  • x – x-coordinate
  • y – y-coordinate
  • amp – surface brightness
Returns:

constant flux

lower_limit_default = {'amp': -100}
param_names = ['amp']
param_names_latex = {'$I_0$'}
upper_limit_default = {'amp': 100}

Module contents