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 | FloatArray) – Number of redshifts to sample. If an array is given, the results are concatenated.
w (glass.shells.RadialWindow) – Radial window function.
rng (UnifiedGenerator | None) – Random number generator. If not given, a default RNG is used.
- Returns:
Random redshifts following the radial window function.
- Return type:
FloatArray
- 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 | FloatArray) – Number of redshifts to sample. If an array is given, its shape is broadcast against the leading axes of z and nz.
z (FloatArray) – Source distribution. Leading axes are broadcast against the shape of count.
nz (FloatArray) – Source distribution. Leading axes are broadcast against the shape of count.
rng (UnifiedGenerator | 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:
FloatArray
- 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 (
Union[ndarray[tuple[Any,...],dtype[float64]],Array,Array]) – Array for galaxy longitudes.lat (
Union[ndarray[tuple[Any,...],dtype[float64]],Array,Array]) – Array for galaxy latitudes.eps (
Union[ndarray[tuple[Any,...],dtype[float64]],Array,Array]) – Array of galaxy ellipticity.kappa (
Union[ndarray[tuple[Any,...],dtype[float64]],Array,Array]) – HEALPix map for convergence.gamma1 (
Union[ndarray[tuple[Any,...],dtype[float64]],Array,Array]) – HEALPix maps for a component of shear.gamma2 (
Union[ndarray[tuple[Any,...],dtype[float64]],Array,Array]) – HEALPix maps for a component of shear.reduced_shear (
bool) – IfFalse, galaxy shears are not reduced by the convergence. Default isTrue.
- Returns:
An array of complex-valued observed galaxy shears (lensed ellipticities).
- Return type:
Union[ndarray[tuple[Any,...],dtype[float64]],Array,Array]
- glass.gaussian_phz(z, sigma_0, *, lower=None, upper=None, rng=None, xp=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\) [Amara07].
- Parameters:
z (float | FloatArray) – True redshifts.
sigma_0 (float | FloatArray) – Redshift error in the tomographic binning at zero redshift.
lower (float | FloatArray | None) – Bounds for the returned photometric redshifts.
upper (float | FloatArray | None) – Bounds for the returned photometric redshifts.
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:
Photometric redshifts assuming Gaussian errors, of the same shape as z.
- Raises:
ValueError – If the bounds are not consistent.
- Return type:
FloatArray
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_gausserrCreate tomographic redshift distributions assuming the same model.
Examples
See the Photometric redshifts example.