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.ScatteredBaseClass

Class 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)\). 1 corresponds 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, redshifts and optionally bins are assumed to be in distance units.

  • interp_order (int, default=1) – Interpolation order, e.g. 1 for linear interpolation, 3 for cubic splines.

Methods

copy

Return shallow copy of self.

deepcopy

from_state

Instantiate and initalize class with state dictionary.

is_mpi_broadcast

is_mpi_gathered

is_mpi_root

is_mpi_scattered

load

Load class in numpy binary format from disk.

log_critical

log_debug

log_error

log_info

log_warning

mpi_broadcast

mpi_collect

Return new instance corresponding to self on larger mpicomm.

mpi_distribute

Return new instance corresponding to self on smaller mpicomm.

mpi_gather

mpi_recv

mpi_scatter

mpi_send

mpi_to_state

Return instance, changing current MPI state to mpistate.

save

Save class to disk.

Attributes

logger

mpiattrs

MPI 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 in cls._registry, return instance of cls._registry[__class__] (instead of cls).

classmethod mpi_collect(self=None, sources=None, mpicomm=None)

Return new instance corresponding to self on larger mpicomm.

Parameters
  • self (object, None) – Instance to spread on mpicomm.

  • sources (list, None) – Ranks of processes of mpicomm where self lives. If None, takes the ranks of processes where self is not None.

  • mpicomm (MPI communicator) – New mpi communicator.

Returns

new

Return type

object

mpi_distribute(dests, mpicomm=None)

Return new instance corresponding to self on smaller mpicomm.

Parameters
  • self (object, None) – Instance to concentrate on mpicomm.

  • dests (list, None) – Ranks of processes of mpicomm where to send self lives. If None, takes the ranks of processes where self is not None.

  • 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.