jaxtronomy.LightModel.Profiles package

Submodules

jaxtronomy.LightModel.Profiles.core_sersic module

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 = {'R_sersic': 0, '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 = {'R_sersic': 100, '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)

jaxtronomy.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]
static 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)

static 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

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

static 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

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

static 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

static 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

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

static 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

static 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

static 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

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

jaxtronomy.LightModel.Profiles.sersic_ellipse module

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(smoothing=0.0001, sersic_major_axis=False)[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}
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)

jaxtronomy.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]
Parameters:
  • interpolation – boolean; False in jaxtronomy

  • 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 – 1d 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 jax.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 phi_n(x) and phi_n(y) for a given x-array and y-array for the full order in the polynomials.

Parameters:
  • x – float or 1d array of x-coordinates

  • y – float or 1d array of y-coordinates

  • beta – shapelet scale

  • n_order – order of shapelets

  • center_x – shapelet center

  • center_y – shapelet center

Returns:

jnp.arrays of phi_n(x) and phi_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.

This class is not compatible with linear solver.

param_names = ['amp', 'n_max', 'beta', 'center_x', 'center_y']
lower_limit_default = {'amp': 0, 'beta': 0.01, 'center_x': -100, 'center_y': -100, 'n_max': 1}
upper_limit_default = {'amp': 100, 'beta': 100, 'center_x': 100, 'center_y': 100, 'n_max': 20}
__init__()[source]
function(x, y, amp, n_max, beta, center_x=0, center_y=0)[source]

NOTE: The number of loops is determined based off of len(amp) instead of n_max for autodifferentiation to work. As long as len(amp) equals (n_max + 1) * (n_max + 2) / 2, this function will work correctly and identically to lenstronomy. However if there is any user error, the behaviour of this function will differ from lenstronomy. For performance reasons, we do not include any runtime checks of len(amp) and n_max.

Parameters:
  • x – float or 1d array of x-coordinates

  • y – float or 1d array of y-coordinates

  • amp – 1d array of amplitudes in pre-defined order of shapelet basis functions amp[0] corresponds to (n1, n2) = (0, 0), amp[1] corresponds to (n1, n2) = (1, 0) amp[2] corresponds to (n1, n2) = (0, 1), amp[3] corresponds to (n1, n2) = (2, 0) amp[4] corresponds to (n1, n2) = (1, 1), amp[5] corresponds to (n1, n2) = (0, 2) amp[6] corresponds to (n1, n2) = (3, 0), etc len(amp) should be equal to (n_max + 1) * (n_max + 2) / 2

  • beta – shapelet scale

  • n_max – int, maximum order in Hermite polynomial. Although this argument is unused here, inonsistencies with len(amp) can lead to incorrect behaviour in e.g. Lightparam and Param classes.

  • center_x – shapelet center

  • center_y – shapelet center

Returns:

surface brightness of combined shapelet set

class ShapeletSetStatic(n_max)[source]

Bases: object

Same as ShapeletSet, but n_max is declared at initialization.

This is required to use the linear solver. NOTE: To use a new value of n_max, a new instance of the class needs to be created. Changing self.n_max will not work.

param_names = ['amp', 'n_max', 'beta', 'center_x', 'center_y']
lower_limit_default = {'amp': 0, 'beta': 0.01, 'center_x': -100, 'center_y': -100, 'n_max': 1}
upper_limit_default = {'amp': 100, 'beta': 100, 'center_x': 100, 'center_y': 100, 'n_max': 20}
__init__(n_max)[source]
function(x, y, amp, beta, center_x=0, center_y=0, *args, **kwargs)[source]

NOTE: The number of loops is determined based off of len(amp) instead of n_max for autodifferentiation to work. As long as len(amp) equals (n_max + 1) * (n_max + 2) / 2, this function will work correctly and identically to lenstronomy. However if there is any user error, the behaviour of this function will differ from lenstronomy. For performance reasons, we do not include any runtime checks of len(amp) and n_max.

Parameters:
  • x – float or 1d array of x-coordinates

  • y – float or 1d array of y-coordinates

  • amp – 1d array of amplitudes in pre-defined order of shapelet basis functions amp[0] corresponds to (n1, n2) = (0, 0), amp[1] corresponds to (n1, n2) = (1, 0) amp[2] corresponds to (n1, n2) = (0, 1), amp[3] corresponds to (n1, n2) = (2, 0) amp[4] corresponds to (n1, n2) = (1, 1), amp[5] corresponds to (n1, n2) = (0, 2) amp[6] corresponds to (n1, n2) = (3, 0), etc len(amp) should be equal to (n_max + 1) * (n_max + 2) / 2

  • beta – shapelet scale

  • center_x – shapelet center

  • center_y – shapelet center

Returns:

surface brightness of combined shapelet set

function_split(x, y, amp, beta, center_x=0, center_y=0, *args, **kwargs)[source]
Parameters:
  • x – float or 1d array of x-coordinates

  • y – float or 1d array of y-coordinates

  • amp – 1d array of amplitudes in pre-defined order of shapelet basis functions amp[0] corresponds to (n1, n2) = (0, 0), amp[1] corresponds to (n1, n2) = (1, 0) amp[2] corresponds to (n1, n2) = (0, 1), amp[3] corresponds to (n1, n2) = (2, 0) amp[4] corresponds to (n1, n2) = (1, 1), amp[5] corresponds to (n1, n2) = (0, 2) amp[6] corresponds to (n1, n2) = (3, 0), etc len(amp) should be equal to (n_max + 1) * (n_max + 2) / 2

  • beta – shapelet scale

  • center_x – shapelet center

  • center_y – shapelet center

Returns:

list of surface brightnesses of each shapelet in the set

Module contents