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.

param_names = ['amp', 'w_c', 'w_t', 'e1', 'e2', 'center_x', 'center_y']
lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'w_c': 0, 'w_t': 0}
upper_limit_default = {'amp': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'w_c': 100, 'w_t': 100}
__init__()[source]
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

class DoubleChameleon[source]

Bases: object

Class of the double Chameleon model.

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

param_names = ['amp', 'ratio', 'w_c1', 'w_t1', 'e11', 'e21', 'w_c2', 'w_t2', 'e12', 'e22', 'center_x', 'center_y']
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}
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}
__init__()[source]
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

class TripleChameleon[source]

Bases: object

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

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']
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}
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}
__init__()[source]
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:

lenstronomy.LightModel.Profiles.ellipsoid module

class Ellipsoid[source]

Bases: object

Class for a universal surface brightness within an ellipsoid.

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

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

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

class GaussianEllipse[source]

Bases: object

Class for Gaussian light profile with ellipticity.

profile name in LightModel module: ‘GAUSSIAN_ELLIPSE’

param_names = ['amp', 'sigma', 'e1', 'e2', 'center_x', 'center_y']
lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'sigma': 0}
upper_limit_default = {'amp': 1000, 'center_x': 100, 'center_y': 100, 'e1': -0.5, 'e2': -0.5, 'sigma': 100}
__init__()[source]
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)

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

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

class MultiGaussian[source]

Bases: object

Class for Multi Gaussian lens light (2d projected light/mass distribution.

profile name in LightModel module: ‘MULTI_GAUSSIAN’

param_names = ['amp', 'sigma', 'center_x', 'center_y']
lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'sigma': 0}
upper_limit_default = {'amp': 1000, 'center_x': 100, 'center_y': 100, 'sigma': 100}
__init__()[source]
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)

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

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

class MultiGaussianEllipse[source]

Bases: object

Class for elliptical multi Gaussian profile.

profile name in LightModel module: ‘MULTI_GAUSSIAN_ELLIPSE’

param_names = ['amp', 'sigma', 'e1', 'e2', 'center_x', 'center_y']
lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'sigma': 0}
upper_limit_default = {'amp': 1000, 'center_x': 100, 'center_y': 100, 'e1': -0.5, 'e2': -0.5, 'sigma': 100}
__init__()[source]
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)

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

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

lenstronomy.LightModel.Profiles.hernquist module

class Hernquist[source]

Bases: object

Class for Hernquist lens light (2d projected light/mass distribution).

__init__()[source]
function(x, y, amp, Rs, center_x=0, center_y=0)[source]
Parameters:
  • x – x-position

  • y – y-position

  • amp – surface brightness amplitude

  • Rs – scale radius: half-light radius = Rs / 0.551

  • center_x – centroid in x-direction

  • center_y – centroid in y-direction

Returns:

surface brightness

light_3d(r, amp, Rs)[source]
Parameters:
  • r – 3d radius (in angular units)

  • amp – surface brightness amplitude

  • Rs – scale radius: half-light radius = Rs / 0.551

Returns:

static total_flux(amp, Rs, center_x=0, center_y=0)[source]
Parameters:
  • amp – surface brightness amplitude

  • Rs – scale radius: half-light radius = Rs / 0.551

Returns:

total integrated flux of profile

class HernquistEllipse[source]

Bases: object

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

param_names = ['amp', 'Rs', 'e1', 'e2', 'center_x', 'center_y']
lower_limit_default = {'Rs': 0, 'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5}
upper_limit_default = {'Rs': 100, 'amp': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5}
__init__()[source]
function(x, y, amp, Rs, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – x-position

  • y – y-position

  • amp – surface brightness amplitude

  • Rs – scale radius: half-light radius = Rs / 0.551

  • e1 – eccentricity component

  • e2 – eccentricity component

  • center_x – centroid in x-direction

  • center_y – centroid in y-direction

Returns:

surface brightness

light_3d(r, amp, Rs, e1=0, e2=0, **kwargs)[source]
Parameters:
  • r – 3d radius (in angular units)

  • amp – surface brightness amplitude

  • Rs – scale radius: half-light radius = Rs / 0.551

  • e1 – eccentricity component

  • e2 – eccentricity component

Returns:

flux density in 3d

total_flux(amp, Rs, **kwargs)[source]
Parameters:
  • amp – surface brightness amplitude

  • Rs – scale radius: half-light radius = Rs / 0.551

Returns:

total integrated flux

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

param_names = ['image', 'amp', 'center_x', 'center_y', 'phi_G', 'scale']
lower_limit_default = {'amp': 0, 'center_x': -1000, 'center_y': -1000, 'phi_G': -3.141592653589793, 'scale': 1e-09}
upper_limit_default = {'amp': 1000000, 'center_x': 1000, 'center_y': 1000, 'phi_G': 3.141592653589793, 'scale': 10000000000}
__init__()[source]
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]
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

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.

lenstronomy.LightModel.Profiles.linear module

class Linear[source]

Bases: object

Class for two-dimensional Linear light profile.

profile name in LightModel module: ‘LINEAR’

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

Surface brightness per angular unit.

Parameters:
  • x – coordinate on the sky

  • y – coordinate on the sky

  • k – slope value for the linear profile

  • amp – the intercept value before time amp

  • center_x – center of profile

  • center_y – center of profile

Returns:

surface brightness at (x, y)

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

Integrated flux of the profile.

Parameters:
  • k – slope value for the linear profile

  • amp – the intercept value before time amp

  • center_x – center of profile

  • center_y – center of profile

Returns:

total flux

class LinearEllipse[source]

Bases: object

Class for Linear light profile with ellipticity.

profile name in LightModel module: ‘LINEAR_ELLIPSE’

param_names = ['amp', 'k', 'e1', 'e2', 'center_x', 'center_y']
lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'k': -1000}
upper_limit_default = {'amp': 100, 'center_x': 100, 'center_y': 100, 'e1': -0.5, 'e2': -0.5, 'k': 1000}
__init__()[source]
function(x, y, amp, k, e1, e2, center_x=0, center_y=0)[source]
Parameters:
  • x – coordinate on the sky

  • y – coordinate on the sky

  • k – slope value for the linear profile

  • amp – the intercept value before time amp

  • e1 – eccentricity modulus

  • e2 – eccentricity modulus

  • center_x – center of profile

  • center_y – center of profile

Returns:

surface brightness at (x, y)

total_flux(amp, k, e1=None, e2=None, center_x=None, center_y=None)[source]

Total integrated flux of profile.

Parameters:
  • k – slope value for the linear profile

  • amp – the intercept value before time amp

  • e1 – eccentricity modulus

  • e2 – eccentricity modulus

  • center_x – center of profile

  • center_y – center of profile

Returns:

total flux

lenstronomy.LightModel.Profiles.lineprofile module

class LineProfile[source]

Bases: object

Horizontal line segment class.

The line extends length arcseconds from (start_x, start_y) at an angle angle degrees to the horizontal. Line width is centered in the perpendicular direction, e.g. a profile with 1 arcsecond width and angle=0 will span -0.5 to 0.5 in the y-direction. Surface brightness is constant and given by amp.

param_names = ['amp', 'angle', 'length', 'width', 'start_x', 'start_y']
lower_limit_default = {'amp': 0, 'angle': -180, 'length': 0.01, 'start_x': -100, 'start_y': -100, 'width': 0.01}
upper_limit_default = {'amp': 10, 'angle': 180, 'length': 10, 'start_x': 100, 'start_y': 100, 'width': 5}
__init__()[source]
function(x, y, amp, angle, length, width, start_x=0, start_y=0)[source]

Surface brightness per angular unit.

Parameters:
  • x – x-coordinate on sky

  • y – y-coordinate on sky

  • amp – constant surface brightness of line

  • angle – angle of line to the horizontal (degrees)

  • length – length of line (arcseconds)

  • width – width of line (arcseconds), line width extends symmetrically

  • start_x – ra coordinate of start of line

  • start_y – dec-coordinate of start of line

Returns:

surface brightness, raise as definition is not defined

total_flux(amp, angle, length, width, start_x=0, start_y=0)[source]

Integrated flux of the profile.

Parameters:
  • amp – constant surface brightness of line

  • angle – angle of line to the horizontal (degrees)

  • length – length of line (arcseconds)

  • width – width of line (arcseconds), line width extends symmetrically

  • start_x – ra coordinate of start of line

  • start_y – dec-coordinate of start of line

Returns:

total flux

lenstronomy.LightModel.Profiles.mge_ellipse module

class MGEEllipse(n_comp)[source]

Bases: object

Multi Gaussian Sets with elliptical axis ratios.

param_names = ['amp', 'sigma_min', 'sigma_width', 'e1', 'e2', 'center_x', 'center_y']
lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.6, 'e2': -0.6, 'sigma_min': 0.0001, 'sigma_width': 0.001}
upper_limit_default = {'amp': 1000, 'center_x': 100, 'center_y': 100, 'e1': 0.6, 'e2': 0.6, 'sigma_min': 50, 'sigma_width': 1000}
__init__(n_comp)[source]
Parameters:

n_comp (int > 1) – number of Gaussian component

property num_linear

Number of linear parameters.

Returns:

function(x, y, amp, sigma_min, sigma_width, e1, e2, 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

  • sigma_min – minimum Gaussian sigma (sigmas being logarithmically scalled between min and max)

  • sigma_width – sigma_min + sigma_width is maximum Gaussian sigma

  • e1 – eccentricity component 1

  • e2 – eccentricity component 2

  • center_x – MGE center x

  • center_y – MGE center y

Returns:

surface brightness

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

Slits surface brightness into individual Gaussian components.

Parameters:
  • x – x-coordinates

  • y – y-coordinates

  • amp – array of amplitudes in pre-defined order of shapelet basis functions

  • sigma_min – minimum Gaussian sigma (sigmas being logarithmically scalled between min and max)

  • sigma_width – sigma_min + sigma_width is maximum Gaussian sigma

  • e1 – eccentricity component 1

  • e2 – eccentricity component 2

  • center_x – MGE center x

  • center_y – MGE center y

Returns:

surface brightness split in different components

total_flux(amp, sigma_min, sigma_width, e1, e2, center_x=0, center_y=0)[source]

Total integrated flux of profile.

Parameters:
  • amp – list of amplitudes of individual Gaussian profiles

  • sigma_min – minimum Gaussian sigma (sigmas being logarithmically scalled between min and max)

  • sigma_width – sigma_min + sigma_width is maximum Gaussian sigma

  • e1 – eccentricity component 1

  • e2 – eccentricity component 2

  • center_x – center of profile

  • center_y – center of profile

Returns:

total flux

light_3d(r, amp, sigma_min, sigma_width, e1, e2)[source]

3D brightness per angular volume element.

Parameters:
  • r – 3d distance from center of profile

  • amp – list of amplitudes of individual Gaussian profiles

  • sigma_min – minimum Gaussian sigma (sigmas being logarithmically scalled between min and max)

  • sigma_width – sigma_min + sigma_width is maximum Gaussian sigma

  • e1 – eccentricity component 1

  • e2 – eccentricity component 2

Returns:

3D brightness per angular volume element

lenstronomy.LightModel.Profiles.mge_set module

class MGESet(n_comp)[source]

Bases: object

Class for Multi Gaussian lens light (2d projected light/mass distribution as a set of Gaussians in logarithmic spacing.

profile name in LightModel module: ‘MGE_SET

param_names = ['amp', 'sigma_min', 'sigma_width', 'center_x', 'center_y']
lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'sigma_min': 0.0001, 'sigma_width': 0.001}
upper_limit_default = {'amp': 1000, 'center_x': 100, 'center_y': 100, 'sigma_min': 50, 'sigma_width': 1000}
__init__(n_comp)[source]
Parameters:

n_comp (int > 1) – number of Gaussian component

property num_linear

Number of linear parameters.

Returns:

function(x, y, amp, sigma_min, sigma_width, 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_min – minimum Gaussian sigma (sigmas being logarithmically scalled between min and max)

  • sigma_width – sigma_min + sigma_width is maximum Gaussian sigma

  • center_x – center of profile

  • center_y – center of profile

Returns:

surface brightness at (x, y)

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

Total integrated flux of profile.

Parameters:
  • amp – list of amplitudes of individual Gaussian profiles

  • sigma_min – minimum Gaussian sigma (sigmas being logarithmically scalled between min and max)

  • sigma_width – sigma_min + sigma_width is maximum Gaussian sigma

  • center_x – center of profile

  • center_y – center of profile

Returns:

total flux

function_split(x, y, amp, sigma_min, sigma_width, 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_min – minimum Gaussian sigma (sigmas being logarithmically scalled between min and max)

  • sigma_width – sigma_min + sigma_width is maximum Gaussian sigma

  • center_x – center of profile

  • center_y – center of profile

Returns:

list of arrays of surface brightness

light_3d(r, amp, sigma_min, sigma_width)[source]

3D brightness per angular volume element.

Parameters:
  • r – 3d distance from center of profile

  • amp – list of amplitudes of individual Gaussian profiles

  • sigma_min – minimum Gaussian sigma (sigmas being logarithmically scalled between min and max)

  • sigma_width – sigma_min + sigma_width is maximum Gaussian sigma

Returns:

3D brightness per angular volume element

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]
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: 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’.

param_names = ['amp', 'e1', 'e2', 's_scale', 'center_x', 'center_y']
lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 's_scale': 0}
upper_limit_default = {'amp': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 's_scale': 100}
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

lenstronomy.LightModel.Profiles.pl_sersic module

class PL_Sersic[source]

Bases: object

This class contains functions to evaluate a 2D PL-Sérsic surface brightness profile.

The surface luminosity density profile corresponding to the 3D PL-Sérsic profile is written as (see Wei, Du 2020)):

  • For \(R < r_c\), \(I(R) = 2 amp r_c \tilde{z} 2F1(alpha_c/2, 1; 3/2; \tilde{z}^2) + 2 \int_{r_c}^{\infty} j(r) r dr / sqrt(r^2 - R^2)\)

  • For \(R > r_c\), \(I(R) = I_0 \exp{-(R/s)^{nu}}\)

with \(j_c = amp\)

param_names = ['amp', 'R_sersic', 'n_sersic', 'alpha_c', 'r_c', 'e1', 'e2', 'center_x', 'center_y']
lower_limit_default = {'R_sersic': 0, 'alpha_c': 0.1, 'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'n_sersic': 0.5, 'r_c': 0.1}
upper_limit_default = {'R_sersic': 100, 'alpha_c': 3.0, 'amp': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'n_sersic': 8, 'r_c': 10}
calculate_u_nu(n_sersic)[source]

Calculate u and nu based on n_sersic.

Parameters:

n_sersic – Sérsic index

Returns:

(u, nu) parameters

calculate_param(R_sersic, n_sersic)[source]

Calculate the scale radius s from the 2D effective radius R_sersic and the Sérsic index n.

Parameters:
  • R_sersic – 2D effective radius

  • n_sersic – Sérsic index

Returns:

scale radius s

get_distance_from_center_bpl(x, y, e1, e2, center_x, center_y)[source]
function(x, y, amp, R_sersic, n_sersic, alpha_c, r_c, e1, e2, center_x=0, center_y=0, max_R_frac=1000.0)[source]

PL-Sérsic 2D surface brightness from a 3D PL-Sérsic luminosity density:

I(R) = 2 amp r_c tilde{z} 2F1(alpha_c/2, 1; 3/2; tilde{z}^2)
  • 2 int_{r_c}^{infty} j(r) r dr / sqrt(r^2 - R^2) (R < r_c)

I(R) = I_0 exp[-(R/s)^nu] (R >= r_c)

total_flux(amp, R_sersic, n_sersic, alpha_c, r_c, e1=0, e2=0, **kwargs)[source]

Analytic total flux from the 3D luminosity density j(r):

F_tot = 4*pi * [ amp*r_c^3/(3-alpha_c)
  • j0*s^3/nu * Gamma((3-u)/nu, (r_c/s)^nu) ]

where Gamma(a,x) is the upper incomplete gamma function.

lenstronomy.LightModel.Profiles.power_law module

class PowerLaw[source]

Bases: object

Class for power-law elliptical light distribution.

param_names = ['amp', 'gamma', 'e1', 'e2', 'center_x', 'center_y']
lower_limit_default = {'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5, 'gamma': 1}
upper_limit_default = {'amp': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'gamma': 3}
__init__()[source]
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:

lenstronomy.LightModel.Profiles.profile_base module

class LightProfileBase[source]

Bases: object

Base class of all light profiles.

__init__()[source]
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.pseudo_jaffe module

class PseudoJaffe[source]

Bases: object

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

param_names = ['amp', 'Ra', 'Rs', 'center_x', 'center_y']
lower_limit_default = {'Ra': 0, 'Rs': 0, 'amp': 0, 'center_x': -100, 'center_y': -100}
upper_limit_default = {'Ra': 100, 'Rs': 100, 'amp': 100, 'center_x': 100, 'center_y': 100}
__init__()[source]
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:

class PseudoJaffeEllipse[source]

Bases: object

Calss for elliptical pseudo Jaffe lens light.

param_names = ['amp', 'Ra', 'Rs', 'e1', 'e2', 'center_x', 'center_y']
lower_limit_default = {'Ra': 0, 'Rs': 0, 'amp': 0, 'center_x': -100, 'center_y': -100, 'e1': -0.5, 'e2': -0.5}
upper_limit_default = {'Ra': 100, 'Rs': 100, 'amp': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5}
__init__()[source]
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:

lenstronomy.LightModel.Profiles.sersic module

class Sersic(smoothing=0.0001, sersic_major_axis=False)[source]

Bases: SersicUtil

This class contains functions to evaluate a spherical Sersic function.

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

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

param_names = ['amp', 'R_sersic', 'n_sersic', 'center_x', 'center_y']
lower_limit_default = {'R_sersic': 0, 'amp': 0, 'center_x': -100, 'center_y': -100, 'n_sersic': 0.5}
upper_limit_default = {'R_sersic': 100, 'amp': 100, 'center_x': 100, 'center_y': 100, 'n_sersic': 8}
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)

class SersicElliptic(smoothing=0.0001, sersic_major_axis=False)[source]

Bases: SersicUtil

This class contains functions to evaluate an elliptical Sersic function.

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

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

param_names = ['amp', 'R_sersic', 'n_sersic', 'e1', 'e2', 'center_x', 'center_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}
upper_limit_default = {'R_sersic': 100, 'amp': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'n_sersic': 8}
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)

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

Bases: SersicUtil

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

param_names = ['amp', 'R_sersic', 'n_sersic', 'q', 'phi', 'center_x', 'center_y']
lower_limit_default = {'R_sersic': 0, 'amp': 0, 'center_x': -100, 'center_y': -100, 'n_sersic': 0.5, 'phi': -3.141592653589793, 'q': 0}
upper_limit_default = {'R_sersic': 100, 'amp': 100, 'center_x': 100, 'center_y': 100, 'n_sersic': 8, 'phi': 3.141592653589793, 'q': 1.0}
__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)

class CoreSersic(smoothing=0.0001, sersic_major_axis=False)[source]

Bases: 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}\).

param_names = ['amp', 'R_sersic', 'Rb', 'n_sersic', 'gamma', 'e1', 'e2', 'center_x', 'center_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}
upper_limit_default = {'Rb': 100, 'amp': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.5, 'e2': 0.5, 'gamma': 10, 'n_sersic': 8}
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)

lenstronomy.LightModel.Profiles.sersic_ellipse_with_flexion module

class SersicEllipseWithFlexion(smoothing=0.0001, sersic_major_axis=False)[source]

Bases: SersicUtil

This class contains functions to evaluate an elliptical Sersic function which contains flexion.

\[I(z) = I_{sersic}(z + az + bz^* + c^*z^2 + 2czz^* + d(z^*)^2)\]

with \(I_{sersic}\) the profile of an elliptical sersic, and \(z = x + iy\), and x, y the coordinates of the point in which we are about to calculate the profile.

param_names = ['amp', 'R_sersic', 'n_sersic', 'e1', 'e2', 'center_x', 'center_y', 'a', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2']
lower_limit_default = {'R_sersic': 0, 'a': -0.5, 'amp': 0, 'b1': -0.5, 'b2': -0.5, 'c1': -0.5, 'c2': -0.5, 'center_x': -100, 'center_y': -100, 'd1': -0.5, 'd2': -0.5, 'e1': -0.5, 'e2': -0.5, 'n_sersic': 0.5}
upper_limit_default = {'R_sersic': 100, 'a': 0.5, 'amp': 100, 'b1': 0.5, 'b2': 0.5, 'c1': 0.5, 'c2': 0.5, 'center_x': 100, 'center_y': 100, 'd1': 0.5, 'd2': 0.5, 'e1': 0.5, 'e2': 0.5, 'n_sersic': 8}
function(x, y, amp, R_sersic, n_sersic, e1, e2, center_x=0, center_y=0, max_R_frac=100.0, a=0, b1=0, b2=0, c1=0, c2=0, d1=0, d2=0)[source]
Parameters:
  • x – x coordinate of the point in which the profile is about to be evaluated

  • y – y coordinate of the point in which the profile is about to be evaluated

  • 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

  • e2 – eccentricity parameter

  • 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)

  • a – real number a in the above formula

  • b1 – real part of the complex number b in the above formula

  • b2 – imaginary part of the complex number b in the above formula

  • c1 – real part of the complex number c in the above formula

  • c2 – imaginary part of the complex number c in the above formula

  • d1 – real part of the complex number d in the above formula

  • d2 – imaginary part of the complex number d in the above formula

Returns:

Sersic flexion profile value at (x, y)

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}({\bf 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}).\]
param_names = ['amp', 'beta', 'n1', 'n2', 'center_x', 'center_y']
lower_limit_default = {'amp': 0, 'beta': 0.01, 'center_x': -100, 'center_y': -100, 'n1': 0, 'n2': 0}
upper_limit_default = {'amp': 100, 'beta': 100, 'center_x': 100, 'center_y': 100, 'n1': 150, 'n2': 150}
__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.

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

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)

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).

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)

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.

param_names = ['amp', 'n_max', 'beta', 'center_x', 'center_y']
lower_limit_default = {'beta': 0.01, 'center_x': -100, 'center_y': -100}
upper_limit_default = {'beta': 100, 'center_x': 100, 'center_y': 100}
__init__()[source]
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

shapelet_basis_2d(num_order, beta, num_pix, delta_pix=1, center_x=0, center_y=0)[source]
Parameters:
  • num_order – max shapelet order

  • beta – shapelet scale

  • num_pix – number of pixel of the grid

Returns:

list of shapelets drawn on pixel grid, centered.

decomposition(image, x, y, n_max, beta, delta_pix, 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:

lenstronomy.LightModel.Profiles.shapelets_ellipse module

class ShapeletSetEllipse[source]

Bases: object

Cartesian shapelets with elliptical axis ratios.

param_names = ['amp', 'n_max', 'beta', 'e1', 'e2', 'center_x', 'center_y']
lower_limit_default = {'beta': 0.01, 'center_x': -100, 'center_y': -100, 'e1': -0.6, 'e2': -0.6}
upper_limit_default = {'beta': 100, 'center_x': 100, 'center_y': 100, 'e1': 0.6, 'e2': 0.6}
__init__()[source]
function(x, y, amp, n_max, beta, e1, e2, 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

  • e1 – eccentricity component 1

  • e2 – eccentricity component 2

  • center_x – shapelet center x

  • center_y – shapelet center y

Returns:

surface brightness of combined shapelet set

function_split(x, y, amp, n_max, beta, e1, e2, 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

  • e1 – eccentricity component 1

  • e2 – eccentricity component 2

  • center_x – shapelet center x

  • center_y – shapelet center y

Returns:

list of individual shapelet basis function responses

lenstronomy.LightModel.Profiles.shapelets_polar module

class ShapeletsPolar[source]

Bases: object

2D polar Shapelets, see Massey & Refregier 2005.

param_names = ['amp', 'beta', 'n', 'm', 'center_x', 'center_y']
param_names_latex = {'$I_0$', '$\\beta$', '$m$', '$n$', '$x_0$', '$y_0$'}
lower_limit_default = {'amp': 0, 'beta': 0, 'center_x': -100, 'center_y': -100, 'm': 0, 'n': 0}
upper_limit_default = {'amp': 100, 'beta': 100, 'center_x': 100, 'center_y': 100, 'm': 150, 'n': 150}
__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

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:

static num_param(n_max)[source]
Parameters:

n_max – maximal polynomial order

Returns:

number of basis components

class ShapeletsPolarExp[source]

Bases: object

2D exponential shapelets, Berge et al.

2019

param_names = ['amp', 'beta', 'n', 'm', 'center_x', 'center_y']
lower_limit_default = {'amp': 0, 'beta': 0, 'center_x': -100, 'center_y': -100, 'm': 0, 'n': 0}
upper_limit_default = {'amp': 100, 'beta': 100, 'center_x': 100, 'center_y': 100, 'm': 150, 'n': 150}
__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)

static num_param(n_max)[source]
Parameters:

n_max – maximal polynomial order

Returns:

number of basis components

index2poly(index)[source]
Parameters:

index

Returns:

static poly2index(n, m, complex_bool)[source]
Parameters:
  • n

  • m

  • complex_bool

Returns:

index convention, integer

class ShapeletSetPolar(exponential=False)[source]

Bases: object

Class to operate on entire shapelet set.

param_names = ['amp', 'n_max', 'beta', 'center_x', 'center_y']
lower_limit_default = {'beta': 0, 'center_x': -100, 'center_y': -100}
upper_limit_default = {'beta': 100, 'center_x': 100, 'center_y': 100}
__init__(exponential=False)[source]
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]
decomposition(image, x, y, n_max, beta, delta_pix, 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:

index2poly(index)[source]
Parameters:

index – index of coefficient in the convention here

Returns:

n, m, complex_bool

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

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'}
lower_limit_default = {'amp': [0], 'center_x': -1000, 'center_y': -1000, 'n_pixels': 5, 'n_scales': 2, 'scale': 1e-09}
upper_limit_default = {'amp': [100000000.0], 'center_x': 1000, 'center_y': 1000, 'n_pixels': 10000000000.0, 'n_scales': 20, 'scale': 10000000000}
__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.

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))

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.

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’

param_names = ['amp']
param_names_latex = {'$I_0$'}
lower_limit_default = {'amp': -100}
upper_limit_default = {'amp': 100}
__init__()[source]
function(x, y, amp)[source]
Parameters:
  • x – x-coordinate

  • y – y-coordinate

  • amp – surface brightness

Returns:

constant flux

Module contents