Observed shapes (glass.shapes)#

The glass.shapes module provides functionality for simulating the observed shapes of objects, such as e.g. galaxies.

Ellipticity#

glass.shapes.ellipticity_gaussian(size, sigma, *, rng=None)#

Sample Gaussian galaxy ellipticities.

The ellipticities are sampled from a normal distribution with standard deviation sigma for each component. Samples where the ellipticity is larger than unity are discarded. Hence, do not use this function with too large values of sigma, or the sampling will become inefficient.

Parameters:
sizeint

Number of ellipticities to be sampled.

sigmaarray_like

Standard deviation in each component.

rngGenerator, optional

Random number generator. If not given, a default RNG will be used.

Returns:
epsarray_like

Array of galaxy ellipticity.

glass.shapes.ellipticity_intnorm(size, sigma, *, rng=None)#

Sample galaxy ellipticities with intrinsic normal distribution.

The ellipticities are sampled from an intrinsic normal distribution with standard deviation sigma for each component.

Parameters:
sizeint

Number of ellipticities to sample.

sigmaarray_like

Standard deviation of the ellipticity in each component.

rngGenerator, optional

Random number generator. If not given, a default RNG will be used.

Returns:
epsarray_like

Array of galaxy ellipticity.

glass.shapes.ellipticity_ryden04(mu, sigma, gamma, sigma_gamma, size=None, *, rng=None)#

ellipticity distribution following Ryden (2004)

The ellipticities are sampled by randomly projecting a 3D ellipsoid with principal axes \(A > B > C\) [1]. The distribution of \(\log(1 - B/A)\) is normal with mean \(\mu\) and standard deviation \(\sigma\). The distribution of \(1 - C/B\) is normal with mean \(\gamma\) and standard deviation \(\sigma_\gamma\) [2]. Both distributions are truncated to produce ratios in the range 0 to 1 using rejection sampling.

Parameters:
muarray_like

Mean of the truncated normal for \(\log(1 - B/A)\).

sigmaarray_like

Standard deviation for \(\log(1 - B/A)\).

gammaarray_like

Mean of the truncated normal for \(1 - C/B\).

sigma_gammaarray_like

Standard deviation for \(1 - C/B\).

sizeint or tuple of ints or None

Sample size. If None, the size is inferred from the parameters.

rngGenerator, optional

Random number generator. If not given, a default RNG will be used.

Returns:
epsarray_like

Array of ellipticity from projected axis ratios.

References

[1]

Ryden B. S., 2004, ApJ, 601, 214.

[2]

Padilla N. D., Strauss M. A., 2008, MNRAS, 388, 1321.

Utilities#

glass.shapes.triaxial_axis_ratio(zeta, xi, size=None, *, rng=None)#

axis ratio of a randomly projected triaxial ellipsoid

Given the two axis ratios 1 >= zeta >= xi of a randomly oriented triaxial ellipsoid, computes the axis ratio q of the projection.

Parameters:
zetaarray_like

Axis ratio of intermediate and major axis.

xiarray_like

Axis ratio of minor and major axis.

sizetuple of int or None

Size of the random draw. If None is given, size is inferred from other inputs.

rngGenerator, optional

Random number generator. If not given, a default RNG will be used.

Returns:
qarray_like

Axis ratio of the randomly projected ellipsoid.

Notes

See equations (11) and (12) in [1] for details.

References

[1]

Binney J., 1985, MNRAS, 212, 767. doi:10.1093/mnras/212.4.767