yaw.Binning#

class yaw.Binning(edges: ArrayLike, closed: Closed | str = Closed.right)[source]#

Bases: HdfSerializable

Container for a redshift binning.

Provides convenience methods to access attributes like edges, centers, and bin widths. Additionally implements len(), comparison with ==, addition with +/-, iteration over redshift bins, and pickling.

Parameters:

edges – Sequence of bin edges that are non-overlapping, monotonically increasing, and can be broadcasted to a numpy array.

Keyword Arguments:

closed – Indicating which side of the bin edges is a closed interval, must be left or right (default).

Methods

__init__(edges[, closed])

copy()

Create a copy of this instance.

from_file(path)

Restore the class instance from a HDF5 file.

from_hdf(source)

Restore the class instance from a specific HDF5-file group.

to_file(path)

Serialise the class instances into a HDF5 file.

to_hdf(dest)

Serialise the class instances into a specific HDF5-file group.

Attributes

edges

Array containing the edges of all bins, including the rightmost edge.

closed

Indicating which side of the bin edges is a closed interval, see Closed for valid options.

dz

Array containing the width of the bins.

left

Array containing the left edges of the bins.

mids

Array containing the centers of the bins.

right

Array containing the right edges of the bins.

closed: Closed#

Indicating which side of the bin edges is a closed interval, see Closed for valid options.

copy() TypeBinning[source]#

Create a copy of this instance.

property dz: NDArray#

Array containing the width of the bins.

edges: NDArray#

Array containing the edges of all bins, including the rightmost edge.

classmethod from_file(path: Path | str) TypeHdfSerializable#

Restore the class instance from a HDF5 file.

Parameters:

path – Path (str or pathlib.Path) to HDF5 file to restore from, see also to_file().

Returns:

Restored class instance.

classmethod from_hdf(source: Group) TypeBinning[source]#

Restore the class instance from a specific HDF5-file group.

Parameters:

source – HDF5-file group to restore from, see also to_hdf().

Returns:

Restored class instance.

property left: NDArray#

Array containing the left edges of the bins.

property mids: NDArray#

Array containing the centers of the bins.

property right: NDArray#

Array containing the right edges of the bins.

to_file(path: Path | str) None#

Serialise the class instances into a HDF5 file.

Parameters:

path – Path (str or pathlib.Path) to HDF5 file to serialise into, see also from_file().

to_hdf(dest: Group) None[source]#

Serialise the class instances into a specific HDF5-file group.

Parameters:

dest – HDF5-file group to serialise into, see also from_hdf().