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 (
Union[int,ndarray[tuple[Any,...],dtype[int64]],Array,Array]) – Number of redshifts to sample. If an array is given, the results are concatenated.w (
RadialWindow) – Radial window function.rng (
Union[Generator,Generator,Generator,None]) – Random number generator. If not given, a default RNG is used.
- Returns:
Random redshifts following the radial window function.
- Return type:
Union[ndarray[tuple[Any,...],dtype[float64]],Array,Array]
- glass.redshifts_from_bins(bins, z, nz_dict, *, rng=None)[source]¶
Sample redshifts for a catalogue of redshift bins.
This function samples redshifts from a catalogue of tomographic redshift bin labels bins according to a dictionary nz_dict of redshift distributions \(n(z)\).
- Parameters:
bins (
Union[ndarray[tuple[Any,...],dtype[Any]],Array,Array]) – Array of tomographic bin labels. Each value must correspond to a key in nz_dict.z (
Union[ndarray[tuple[Any,...],dtype[float64]],Array,Array]) – Redshift values for the distributions in nz_dict.nz_dict (
Mapping[Any,Union[ndarray[tuple[Any,...],dtype[float64]],Array,Array]]) – Dictionary of redshift distribution values for each tomographic bin label.rng (
Union[Generator,Generator,Generator,None]) – Random number generator. If not given, a default RNG is used.
- Returns:
Random redshifts following the given redshift distribution for each tomographic bin label.
- Return type:
Union[ndarray[tuple[Any,...],dtype[float64]],Array,Array]
- 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 (
Union[int,ndarray[tuple[Any,...],dtype[float64]],Array,Array]) – Number of redshifts to sample. If an array is given, its shape is broadcast against the leading axes of z and nz.z (
Union[ndarray[tuple[Any,...],dtype[float64]],Array,Array]) – Source distribution. Leading axes are broadcast against the shape of count.nz (
Union[ndarray[tuple[Any,...],dtype[float64]],Array,Array]) – Source distribution. Leading axes are broadcast against the shape of count.rng (
Union[Generator,Generator,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:
Union[ndarray[tuple[Any,...],dtype[float64]],Array,Array]
- 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 (
Union[float,ndarray[tuple[Any,...],dtype[float64]],Array,Array]) – True redshifts.sigma_0 (
Union[float,ndarray[tuple[Any,...],dtype[float64]],Array,Array]) – Redshift error in the tomographic binning at zero redshift.lower (
Union[float,ndarray[tuple[Any,...],dtype[float64]],Array,Array,None]) – Bounds for the returned photometric redshifts.upper (
Union[float,ndarray[tuple[Any,...],dtype[float64]],Array,Array,None]) – Bounds for the returned photometric redshifts.rng (
Union[Generator,Generator,Generator,None]) – Random number generator. If not given, a default RNG is used.xp (
Optional[ModuleType]) – 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:
Union[ndarray[tuple[Any,...],dtype[float64]],Array,Array]
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.