Weak Lensing¶

Shear¶

class jax_galsim.Shear(*args, **kwargs)[source]¶

Bases: object

A class to represent shears in a variety of ways.

LAX-backend implementation of galsim.shear.Shear().

🔪 JAX-GalSim - The Sharp Bits 🔪

The jax_galsim implementation of Shear does not perform range checking of the shear (e.g., |g| <= 1) upon construction.

Original GalSim Documentation

The Shear object can be initialized in a variety of ways to represent shape distortions. A shear is an operation that transforms a circle into an ellipse with minor-to-major axis ratio b/a, with position angle beta, while conserving the area (see below for a discussion of the implications of this choice). Given the multiple definitions of ellipticity, we have multiple definitions of shear:

reduced shear

\(|g| = \frac{a - b}{a + b}\)

distortion

\(|e| = \frac{a^2 - b^2}{a^2 + b^2}\)

conformal shear

\(\eta = \log(b/a)\)

minor-to-major axis ratio

\(q = \frac{b}{a}\)

These can be thought of as a magnitude and a real-space position angle \(\beta\), or as two components, e.g., \(g_1\) and \(g_2\), with:

\[\begin{split}g_1 &= |g| \cos(2 \beta) \\ g_2 &= |g| \sin(2 \beta)\end{split}\]

Note: \(\beta\) is _not_ the phase of a complex valued shear. Rather, the complex shear is \(g_1 + i g_2 = g \exp(2 i \beta)\). Likewise for \(\eta\) or \(e\). The phase of the complex value is \(2 \beta\).

The following are all examples of valid calls to initialize a Shear object:

>>> s = galsim.Shear()                    # empty constructor sets ellipticity/shear to zero
>>> s = galsim.Shear(g1=0.05, g2=0.05)
>>> s = galsim.Shear(g1=0.05)             # assumes g2=0
>>> s = galsim.Shear(e1=0.05, e2=0.05)
>>> s = galsim.Shear(e2=0.05)             # assumes e1=0
>>> s = galsim.Shear(eta1=0.07, eta2=-0.1)
>>> s = galsim.Shear(eta=0.05, beta=45.0*galsim.degrees)
>>> s = galsim.Shear(g=0.05, beta=0.25*numpy.pi*galsim.radians)
>>> s = galsim.Shear(e=0.3, beta=30.0*galsim.degrees)
>>> s = galsim.Shear(q=0.5, beta=0.0*galsim.radians)
>>> s = galsim.Shear(0.05 + 0.03j)        # Uses the g1,g2 reduced shear definition

There can be no mixing and matching, e.g., specifying g1 and e2. It is permissible to only specify one of two components, with the other assumed to be zero. If a magnitude such as e, g, eta, or q is specified, then beta is also required to be specified. It is possible to initialize a Shear with zero reduced shear by specifying no args or kwargs, i.e. galsim.Shear().

In addition, for use cases where extreme efficiency is required, you can skip all the normal sanity checks and branches in the regular Shear constructor by using a leading underscore with the complex shear g1 + 1j * g2:

>>> s = galsim._Shear(0.05 + 0.03j)  # Equivalent to galsim.Shear(g1=0.05, g2=0.03)

Analagous to the construction options, one can access the shear in the same variety of definitions.

Attributes:

g1: The first component of the shear in the “reduced shear” definition. g2: The second component of the shear in the “reduced shear” definition. g: The magnitude of the shear in the “reduced shear” definition. e1: The first component of the shear in the “distortion” definition. e2: The second component of the shear in the “distortion” definition. e: The magnitude of the shear in the “distortion” definition. eta1: The first component of the shear in the “conformal shear” definition. eta2: The second component of the shear in the “conformal shear” definition. eta: The magnitude of the shear in the “conformal shear” definition. q: The minor-to-major axis ratio beta: The position angle as an Angle instance shear: The reduced shear as a complex number g1 + 1j * g2.

Note

Since we have defined a Shear as a transformation that preserves area, this means that it is not a precise description of what happens during the process of weak lensing.

The coordinate transformation that occurs during the actual weak lensing process is such that if a galaxy is sheared by some \((\gamma_1, \gamma_2)\), and then sheared by \((-\gamma_1, -\gamma_2)`\), it will in the end return to its original shape, but will have changed in area due to the magnification,

\[\mu = \frac{1}{(1-\kappa)^2 - (\gamma_1^2 + \gamma_2^2)}\]

which is not equal to 1 for non-zero shear even for convergence \(\kappa=0\).

Application of a Shear using the GSObject.shear method does not include this area change. To properly incorporate the effective change in area due to shear, it is necessary to either:

  1. define the Shear object, use the GSObject.shear method, and separately use the GSObject.magnify method, or

  2. use the GSObject.lens method that simultaneously magnifies and shears.

property g1¶

The first component of the shear in the “reduced shear” definition.

LAX-backend implementation of g1().

property g2¶

The second component of the shear in the “reduced shear” definition.

LAX-backend implementation of g2().

property g¶

The magnitude of the shear in the “reduced shear” definition.

LAX-backend implementation of g().

property beta¶

The position angle as an Angle instance

LAX-backend implementation of beta().

property shear¶

The reduced shear as a complex number g1 + 1j * g2.

LAX-backend implementation of shear().

property e1¶

The first component of the shear in the “distortion” definition.

LAX-backend implementation of e1().

property e2¶

The second component of the shear in the “distortion” definition.

LAX-backend implementation of e2().

property e¶

The magnitude of the shear in the “distortion” definition.

LAX-backend implementation of e().

property esq¶

The square of the magnitude of the shear in the “distortion” definition.

LAX-backend implementation of esq().

property eta1¶

The first component of the shear in the “conformal shear” definition.

LAX-backend implementation of eta1().

property eta2¶

The second component of the shear in the “conformal shear” definition.

LAX-backend implementation of eta2().

property eta¶

The magnitude of the shear in the “conformal shear” definition.

LAX-backend implementation of eta().

property q¶

The minor-to-major axis ratio

LAX-backend implementation of q().

getMatrix()[source]¶

Return the matrix that tells how this shear acts on a position vector:

LAX-backend implementation of galsim.shear.getMatrix().

Original GalSim Documentation

If a field is sheared by some shear, s, then the position (x,y) -> (x’,y’) according to:

\[\begin{split}\left( \begin{array}{c} x^\prime \\ y^\prime \end{array} \right) = S \left( \begin{array}{c} x \\ y \end{array} \right)\end{split}\]

and \(S\) is the return value of this function S = shear.getMatrix().

Specifically, the matrix is

\[\begin{split}S = \frac{1}{\sqrt{1-g^2}} \left( \begin{array}{cc} 1+g_1 & g_2 \\ g_2 & 1-g_1 \end{array} \right)\end{split}\]
rotationWith(other)[source]¶

Return the rotation angle associated with the addition of two shears.

LAX-backend implementation of galsim.shear.rotationWith().

Original GalSim Documentation

The effect of two shears is not just a single net shear. There is also a rotation associated with it. This is easiest to understand in terms of the matrix representations:

If shear3 = shear1 + shear2 is a sum of two shears, and the corresponding shear matrices are \(S_1\), \(S_2\), and \(S_3\), then \(S_3 R = S_1 S_2\), where \(R\) is a rotation matrix:

\[\begin{split}R = \left( \begin{array}{cc} cos(\theta) & -sin(\theta) \\ sin(\theta) & cos(\theta) \end{array} \right)\end{split}\]

and \(\theta\) is the return value (as a galsim.Angle) from shear1.rotationWith(shear2).

tree_flatten()[source]¶
classmethod tree_unflatten(aux_data, children)[source]¶

Recreates an instance of the class from flatten representation

classmethod from_galsim(galsim_shear)[source]¶

Create a jax_galsim Shear from a galsim.Shear object.

to_galsim()[source]¶

Create a galsim Shear from a jax_galsim.Shear object.