lib.catalog.utils.RedshiftDensityInterpolator¶
- class lib.catalog.utils.RedshiftDensityInterpolator(redshifts, weights=None, bins=None, fsky=1.0, radial_distance=None, interp_order=1)¶
Bases:
cosmopipe.lib.utils.ScatteredBaseClassClass that computes and interpolates a redshift density histogram \(n(z)\) from an array of redshift and optionally weights. Adapted from: https://github.com/bccp/nbodykit/blob/master/nbodykit/algorithms/zhist.py
Initialize
RedshiftDensityInterpolator.- Parameters
redshifts (array) – Array of redshifts.
weights (array, default=None) – Array of weights, same shape as
redshifts. Defaults to 1.bins (int, array, string, default=None) – If bins is an integer, it defines the number of equal-width bins in the given range. If bins is a sequence, it defines the bin edges, including the rightmost edge, allowing for non-uniform bin widths. If ‘scott’, Scott’s rule is used to estimate the optimal bin width from the input data. Defaults to ‘scott’.
fsky (float, default=1) – The sky area fraction, which is used in the volume calculation when normalizing \(n(z)\).
1corresponds to full-sky: \(4 \pi\) or \(\simeq 41253\; \mathrm{deg}^{2}\).radial_distance (callable, default=None) – Radial distance to use when converting redshifts into comoving distance. If
None,redshiftsand optionallybinsare assumed to be in distance units.interp_order (int, default=1) – Interpolation order, e.g.
1for linear interpolation,3for cubic splines.
Methods
Return shallow copy of
self.deepcopyInstantiate and initalize class with state dictionary.
is_mpi_broadcastis_mpi_gatheredis_mpi_rootis_mpi_scatteredLoad class in numpy binary format from disk.
log_criticallog_debuglog_errorlog_infolog_warningmpi_broadcastReturn new instance corresponding to
selfon largermpicomm.Return new instance corresponding to
selfon smallermpicomm.mpi_gathermpi_recvmpi_scattermpi_sendReturn instance, changing current MPI state to
mpistate.Save class to disk.
Attributes
loggerMPI attributes
mpistate- __call__(z)¶
Return density at redshift
z(scalar or array).
- copy()¶
Return shallow copy of
self.
- classmethod from_state(state, mpistate=1, mpiroot=0, mpicomm=None)¶
Instantiate and initalize class with state dictionary.
- classmethod load(filename, mpiroot=0, mpistate=1, mpicomm=None)¶
Load class in numpy binary format from disk. If the loaded state contains
__class__and that exists incls._registry, return instance ofcls._registry[__class__](instead ofcls).
- classmethod mpi_collect(self=None, sources=None, mpicomm=None)¶
Return new instance corresponding to
selfon largermpicomm.- Parameters
self (object, None) – Instance to spread on
mpicomm.sources (list, None) – Ranks of processes of
mpicommwhereselflives. IfNone, takes the ranks of processes whereselfis notNone.mpicomm (MPI communicator) – New mpi communicator.
- Returns
new
- Return type
object
- mpi_distribute(dests, mpicomm=None)¶
Return new instance corresponding to
selfon smallermpicomm.- Parameters
self (object, None) – Instance to concentrate on
mpicomm.dests (list, None) – Ranks of processes of
mpicommwhere to sendselflives. IfNone, takes the ranks of processes whereselfis notNone.mpicomm (MPI communicator) – New mpi communicator.
- Returns
new
- Return type
object, None
- mpi_to_state(mpistate)¶
Return instance, changing current MPI state to
mpistate.
- property mpiattrs¶
MPI attributes
- save(filename)¶
Save class to disk.