Galaxies

The following functions provide functionality for simulating galaxies as typically observed in a cosmological galaxy survey.

Functions

glass.redshifts(n, w, *, rng=None)[source]

Sample redshifts from a radial window function.

This function samples n redshifts from a distribution that follows the given radial window function w.

Parameters:
  • n (int | ndarray[Any, dtype[float64]]) – Number of redshifts to sample. If an array is given, the results are concatenated.

  • w (RadialWindow) – Radial window function.

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

Returns:

Random redshifts following the radial window function.

Return type:

ndarray[Any, dtype[float64]]

glass.redshifts_from_nz(count, z, nz, *, rng=None, warn=True)[source]

Generate galaxy redshifts from a source distribution.

The function supports sampling from multiple populations of redshifts if count is an array or if there are additional axes in the z or nz arrays. In this case, the shape of count and the leading dimensions of z and nz are broadcast to a common shape, and redshifts are sampled independently for each extra dimension. The results are concatenated into a flat array.

Parameters:
  • count (int | ndarray[Any, dtype[float64]]) – Number of redshifts to sample. If an array is given, its shape is broadcast against the leading axes of z and nz.

  • z (ndarray[Any, dtype[float64]]) – Source distribution. Leading axes are broadcast against the shape of count.

  • nz (ndarray[Any, dtype[float64]]) – Source distribution. Leading axes are broadcast against the shape of count.

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

  • warn (bool) – Throw relevant warnings.

Returns:

Redshifts sampled from the given source distribution. For inputs with extra dimensions, returns a flattened 1-D array of samples from all populations.

Return type:

ndarray[Any, dtype[float64]]

glass.galaxy_shear(lon, lat, eps, kappa, gamma1, gamma2, *, reduced_shear=True)[source]

Observed galaxy shears from weak lensing.

Takes lensing maps for convergence and shear and produces a lensed ellipticity (shear) for each intrinsic galaxy ellipticity.

Parameters:
  • lon (ndarray[Any, dtype[float64]]) – Array for galaxy longitudes.

  • lat (ndarray[Any, dtype[float64]]) – Array for galaxy latitudes.

  • eps (ndarray[Any, dtype[float64]]) – Array of galaxy ellipticity.

  • kappa (ndarray[Any, dtype[float64]]) – HEALPix map for convergence.

  • gamma1 (ndarray[Any, dtype[float64]]) – HEALPix maps for a component of shear.

  • gamma2 (ndarray[Any, dtype[float64]]) – HEALPix maps for a component of shear.

  • reduced_shear (bool) – If False, galaxy shears are not reduced by the convergence. Default is True.

Returns:

An array of complex-valued observed galaxy shears (lensed ellipticities).

Return type:

ndarray[Any, dtype[float64]]

glass.gaussian_phz(z, sigma_0, *, lower=None, upper=None, rng=None)[source]

Photometric redshifts assuming a Gaussian error.

A simple toy model of photometric redshift errors that assumes a Gaussian error with redshift-dependent standard deviation \(\sigma(z) = (1 + z) \sigma_0\) [1].

Parameters:
Returns:

Photometric redshifts assuming Gaussian errors, of the same shape as z.

Raises:

ValueError – If the bounds are not consistent.

Return type:

float | ndarray[Any, dtype[float64]]

Warning

The lower and upper bounds are implemented using plain rejection sampling from the non-truncated normal distribution. If bounds are used, they should always contain significant probability mass.

See also

glass.tomo_nz_gausserr

Create tomographic redshift distributions assuming the same model.

References

  • [1] Amara A., Réfrégier A., 2007, MNRAS, 381, 1018.

    doi:10.1111/j.1365-2966.2007.12271.x

Examples

See the Photometric redshifts example.