yaw.Binning#
- class yaw.Binning(edges: ArrayLike, closed: Closed | str = Closed.right)[source]#
Bases:
HdfSerializableContainer 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
leftorright(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
Array containing the edges of all bins, including the rightmost edge.
Indicating which side of the bin edges is a closed interval, see
Closedfor valid options.Array containing the width of the bins.
Array containing the left edges of the bins.
Array containing the centers of the bins.
Array containing the right edges of the bins.
- closed: Closed#
Indicating which side of the bin edges is a closed interval, see
Closedfor valid options.
- 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) Self#
Restore the class instance from a HDF5 file.
- Parameters:
path – Path (
strorpathlib.Path) to HDF5 file to restore from, see alsoto_file().- Returns:
Restored class instance.
- classmethod from_hdf(source: Group) Self[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 (
strorpathlib.Path) to HDF5 file to serialise into, see alsofrom_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().