lenstronomy.LensModel.Util package — lenstronomy 1.9.1 documentation

# lenstronomy.LensModel.Util package

## Submodules

## lenstronomy.LensModel.Util.epl_util module

lenstronomy.LensModel.Util.epl_util.brentq_inline(f, xa, xb, xtol=2e-14, rtol=3.552713678800501e-15, maxiter=100, args=())

  A numba-compatible implementation of brentq (largely copied from scipy.optimize.brentq). Unfortunately, the scipy verison is not compatible with numba, hence this reimplementation :( :param f: function to optimize :param xa: left bound :param xb: right bound :param xtol: x-coord root tolerance :param rtol: x-coord relative tolerance :param maxiter: maximum num of iterations :param args: additional arguments to pass to function in the form f(x, args) :param verbose: do some more diagnostic output :return:

lenstronomy.LensModel.Util.epl_util.brentq_nojit(f, xa, xb, xtol=2e-14, rtol=3.552713678800501e-15, maxiter=100, args=())

  A numba-compatible implementation of brentq (largely copied from scipy.optimize.brentq). Unfortunately, the scipy verison is not compatible with numba, hence this reimplementation :( :param f: function to optimize :param xa: left bound :param xb: right bound :param xtol: x-coord root tolerance :param rtol: x-coord relative tolerance :param maxiter: maximum num of iterations :param args: additional arguments to pass to function in the form f(x, args) :param verbose: do some more diagnostic output :return:

lenstronomy.LensModel.Util.epl_util.cart_to_pol(x, y)

  Convert from cartesian to polar :param x: x-coordinate :param y: y-coordinate :return: tuple of (r, theta)

lenstronomy.LensModel.Util.epl_util.cdot(a, b)

  Calculates some complex dot-product that simplifies the math :param a: complex number :param b: complex number :return: dot-product

lenstronomy.LensModel.Util.epl_util.ell_to_pol(rell, theta, q)

  Converts from elliptical to polar coordinates

lenstronomy.LensModel.Util.epl_util.geomlinspace(a, b, N)

  Constructs a geomspace from a to b, with a linspace prepended to it from 0 to a, with the same spacing as the geomspace would have at a

lenstronomy.LensModel.Util.epl_util.min_approx(x1, x2, x3, y1, y2, y3)

  Get the x-value of the minimum of the parabola through the points (x1,y1), … :param x1: x-coordinate point 1 :param x2: x-coordinate point 2 :param x3: x-coordinate point 3 :param y1: y-coordinate point 1 :param y2: y-coordinate point 2 :param y3: y-coordinate point 3 :return: x-location of the minimum

lenstronomy.LensModel.Util.epl_util.pol_to_cart(r, th)

  Convert from polar to cartesian :param r: r-coordinate :param th: theta-coordinate :return: tuple of (x,y)

lenstronomy.LensModel.Util.epl_util.pol_to_ell(r, theta, q)

  Converts from polar to elliptical coordinates

lenstronomy.LensModel.Util.epl_util.ps(x, p)

  A regularized power-law that gets rid of singularities, abs(x)**p*sign(x) :param x: x :param p: p :return:

lenstronomy.LensModel.Util.epl_util.rotmat(th)

  Calculates the rotation matrix :param th: angle :return: rotation matrix

lenstronomy.LensModel.Util.epl_util.solvequadeq(a, b, c)

  Solves a quadratic equation. Care is taken for the numerics, see also https://en.wikipedia.org/wiki/Loss_of_significance :param a: a :param b: b :param c: c :return: tuple of two solutions

## Module contents