target.rates#
This module provides utility functions for drawing and computing volumetric rates and redshift distributions.
- skysurvey.target.rates.draw_redshift(size, rate, zmin=0.0, zmax=2.0, zstep=0.0001, cosmology=FlatLambdaCDM(name='Planck18', H0=<Quantity 67.66 km / (Mpc s)>, Om0=0.30966, Tcmb0=<Quantity 2.7255 K>, Neff=3.046, m_nu=<Quantity [0., 0., 0.06] eV>, Ob0=0.04897), rng=None, **kwargs)[source]#
Draw random redshift following the given rate.
- Parameters:
size (int) – Number of target to draw.
rate (float or callable) – If a float is given, it is assumed to be the number of targets per Gpc3. If a callable is given, it is supposed to be a function of z that returns the volumetric rate as a function of redshift.
zmin (float, optional) – Minimum redshift. The default is 0.
zmax (float, optional) – Maximum redshift. The default is 2.
zstep (float, optional) – Sampling of the redshift. The default is 1e-5.
cosmology (astropy.Cosmology, optional) – Cosmology to use to compute volume, as the rate are “volumetric rates”.
rng (None, int, (Bit)Generator, optional) – seed for the random number generator. (doc adapted from numpy’s np.random.default_rng docstring. See that documentation for details.) If None, an unpredictable entropy will be pulled from the OS. If an
int, (>0), it will set the initial BitGenerator state. If a (Bit)Generator, it will be returned as a Generator unaltered.**kwargs – Goes to
get_ntargets_per_shell()->get_rate().
- Returns:
A list of redshifts.
- Return type:
- skysurvey.target.rates.get_rate(z, rate, **kwargs)[source]#
Get the (volumetric) rate as a function of redshift.
- Parameters:
z (array) – Array of redshifts.
rate (float or callable) – If a float is given, it is assumed to be the number of targets per Gpc3. If a callable is given, it is supposed to be a function of z that returns the volumetric rate as a function of redshift.
**kwargs – Rate options if rate is a function. ignored otherwise.
- Returns:
the rate per Gpc, array (if func) or float
- Return type:
- skysurvey.target.rates.get_ntargets_per_shell(zmax, rate, zmin=0, zstep=1e-05, cosmology=FlatLambdaCDM(name='Planck18', H0=<Quantity 67.66 km / (Mpc s)>, Om0=0.30966, Tcmb0=<Quantity 2.7255 K>, Neff=3.046, m_nu=<Quantity [0., 0., 0.06] eV>, Ob0=0.04897), astype='int', **kwargs)[source]#
Get the total number of target expected in the given volume.
- Parameters:
zmax (float) – outter redshift of the volume.
rate (float, array or callable) – If a float is given, it is assumed to be the number of targets per Gpc3. If a callable is given, it is supposed to be a function of z that returns the volumetric rate as a function of redshift. If an array is given, if array broacasts with shell size, then it multiplies shell, if not than an axes is added and pdf is (rates.shape, nbins).
zmin (float) – inner redshift of the volume.
cosmology (astropy.Cosmology, optional) – Cosmology used to get the comoving_volume. The default is Planck18.
zstep (float) – binning of the redshift used for the computation.
astype (bool) – type of the returned number of target per shell.
**kwargs – goes to
get_rate()
- Returns:
zbins (array) – mid value of the redshift corresponding to the shell
pdf (nd-array) – 1d array if rate broadcast with shell, else nd-array with n the rate shape.
- skysurvey.target.rates.get_ntargets(zmax, rate, zmin=0, cosmology=FlatLambdaCDM(name='Planck18', H0=<Quantity 67.66 km / (Mpc s)>, Om0=0.30966, Tcmb0=<Quantity 2.7255 K>, Neff=3.046, m_nu=<Quantity [0., 0., 0.06] eV>, Ob0=0.04897), zstep=1e-05, force_shell=False, astype='int', **kwargs)[source]#
Get the total number of target expected in the given volume.
- Parameters:
zmax (float) – outter redshift of the volume.
rate (float or callable) – If a float is given, it is assumed to be the number of targets per Gpc3. If a callable is given, it is supposed to be a function of z that returns the volumetric rate as a function of redshift.
zmin (float) – inner redshift of the volume.
cosmology (astropy.Cosmology, optional) – Cosmology used to get the comoving_volume. The default is Planck18.
zstep (float) – binning of the redshift used for the computation.
force_shell (bool) – If the input rate is a constant, should this force the use of shell computation ?
astype (bool) – type of the returned value.
- Returns:
ntargets – number(s) of target.
- Return type:
float, array