clenspy.utils.BinCollection

class clenspy.utils.BinCollection(bins)[source]

Bases: Sequence

An ordered set of RichnessBin, addressable by (i_lam, i_z).

Behaves as a sequence, so for b in bins and bins[k] work in the flat order the bins were supplied. bins.at(i, j) addresses a bin by its paper indices, which is how results are labelled.

Parameters:

bins (Iterable[RichnessBin])

__init__(bins)[source]
Parameters:

bins (Iterable[RichnessBin])

Return type:

None

Methods

__init__(bins)

at(i_lam, i_z)

The bin with paper indices \((i, j)\).

count(value)

from_edges(lam_edges, z_edges[, sigma_z])

Build the full outer product of richness and redshift edges.

index(value, [start, [stop]])

Raises ValueError if the value is not present.

reshape(flat)

Fold a flat per-bin result into (n_lam, n_z, ...).

Attributes

n_lam

Number of distinct richness bins.

n_z

Number of distinct redshift bins.

classmethod from_edges(lam_edges, z_edges, sigma_z=None)[source]

Build the full outer product of richness and redshift edges.

Parameters:
  • lam_edges (sequence of float, length n_lam + 1) – Monotonic richness bin edges.

  • z_edges (sequence of float, length n_z + 1) – Monotonic redshift bin edges.

  • sigma_z (float or sequence of float, optional) – Photo-z scatter. A scalar applies to every bin; a sequence must have length n_lam, since \(\sigma_z\) depends on the richness bin.

Returns:

BinCollection – n_lam * n_z bins in row-major (richness-outer) order.

Return type:

BinCollection

at(i_lam, i_z)[source]

The bin with paper indices \((i, j)\).

Parameters:
Return type:

RichnessBin

property n_lam: int

Number of distinct richness bins.

property n_z: int

Number of distinct redshift bins.

reshape(flat)[source]

Fold a flat per-bin result into (n_lam, n_z, ...).

The inverse of iterating this collection: a stage that returns one value per bin in sequence order gets its \(N_{ij}\) matrix back.

Return type:

ndarray