Observed shapes

The following functions provide functionality for simulating the observed shapes of objects, such as e.g. galaxies.

Ellipticity

glass.ellipticity_gaussian(count, sigma, *, rng=None, xp=None)[source]

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:
  • count (int | IntArray) – Number of ellipticities to be sampled.

  • sigma (float | FloatArray) – Standard deviation in each component.

  • rng (UnifiedGenerator | None) – Random number generator. If not given, a default RNG is used.

  • xp (ModuleType | None) – The array library backend to use for array operations. If this is not specified, the backend will be determined from the input arrays.

Returns:

An array of galaxy ellipticity.

Return type:

ComplexArray

glass.ellipticity_intnorm(count, sigma, *, rng=None, xp=None)[source]

Sample galaxy ellipticities with intrinsic normal distribution.

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

Parameters:
  • count (int | IntArray) – Number of ellipticities to sample.

  • sigma (float | FloatArray) – Standard deviation of the ellipticity in each component.

  • rng (UnifiedGenerator | None) – Random number generator. If not given, a default RNG is used.

  • xp (ModuleType | None) – The array library backend to use for array operations. If this is not specified, the backend will be determined from the input arrays.

Returns:

An array of galaxy ellipticity.

Raises:

ValueError – If the standard deviation is not in the range [0, sqrt(0.5)].

Return type:

ComplexArray

glass.ellipticity_ryden04(mu, sigma, gamma, sigma_gamma, size=None, *, rng=None, xp=None)[source]

Ellipticity distribution following Ryden (2004).

The ellipticities are sampled by randomly projecting a 3D ellipsoid with principal axes \(A > B > C\) [Ryden04]. 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\) [Padilla08]. Both distributions are truncated to produce ratios in the range 0 to 1 using rejection sampling.

Parameters:
  • mu (float | FloatArray) – Mean of the truncated normal for \(\log(1 - B/A)\).

  • sigma (float | FloatArray) – Standard deviation for \(\log(1 - B/A)\).

  • gamma (float | FloatArray) – Mean of the truncated normal for \(1 - C/B\).

  • sigma_gamma (float | FloatArray) – Standard deviation for \(1 - C/B\).

  • size (int | tuple[int, …] | None) – Sample size.

  • rng (UnifiedGenerator | None) – Random number generator. If not given, a default RNG is used.

  • xp (ModuleType | None) – The array library backend to use for array operations. If this is not specified, the backend will be determined from the input arrays.

Returns:

An array of ellipticity from projected axis ratios.

Return type:

FloatArray

Utilities

glass.triaxial_axis_ratio(zeta, xi, size=None, *, rng=None, xp=None)[source]

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:
  • zeta (float | FloatArray) – Axis ratio of intermediate and major axis.

  • xi (float | FloatArray) – Axis ratio of minor and major axis.

  • size (int | tuple[int, …] | None) – Size of the random draw.

  • rng (UnifiedGenerator | None) – Random number generator. If not given, a default RNG is used.

  • xp (ModuleType | None) – The array library backend to use for array operations. If this is not specified, the backend will be determined from the input arrays.

Returns:

The axis ratio of the randomly projected ellipsoid.

Return type:

FloatArray

Notes

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