cosmocore.bins module
Multipole binning for power spectrum estimation.
Provides the Bins class for defining multipole bins with configurable widths and weights. Used by QUBE for binned QML estimation, where per-bin derivative matrices replace per-ell derivatives.
When delta_ell=1, each bin contains a single multipole and the binned estimator reduces to the standard per-multipole QML estimator.
- class cosmocore.bins.Bins(lmins, lmaxs, lmin_floor=2)[source]
Bases:
objectMultipole binning specification.
Defines bins by their lower and upper multipole bounds. Both bounds are inclusive: a bin with lmin=2, lmax=4 contains multipoles {2, 3, 4}. Bins must not overlap and must be sorted in ascending order. Gaps between bins are allowed (those multipoles are simply excluded from the analysis).
The binning operator formalism follows Bond, Jaffe & Knox (1998). The implementation is adapted from the xQML package (Vanneste et al. 2018, Phys. Rev. D 98, 103526), extended with input validation, D_ell weighting, covariance binning, and lmin zero-padding support.
- Parameters:
lmins (array_like) – Lower bound of each bin (inclusive). Bins with lmax < 2 are automatically discarded since CMB power spectra start at ell=2.
lmaxs (array_like) – Upper bound of each bin (inclusive). Must satisfy lmaxs[i] >= lmins[i] for each bin.
- lmins
Lower bounds after filtering (ell >= 2).
- Type:
np.ndarray
- lmaxs
Upper bounds after filtering (ell >= 2).
- Type:
np.ndarray
- lbin
Effective multipole for each bin (midpoint).
- Type:
np.ndarray
- dl
Width of each bin (lmaxs - lmins + 1).
- Type:
np.ndarray
Examples
Uniform bins of width 3 from ell=2 to ell=10:
>>> bins = Bins.fromdeltal(2, 10, 3) >>> bins.lmins array([2, 5, 8]) >>> bins.lmaxs array([4, 7, 10])
Custom non-uniform bins:
>>> bins = Bins([2, 5, 10], [4, 9, 20]) >>> bins.dl array([3, 5, 11])
- classmethod fromdeltal(lmin, lmax, delta_ell)[source]
Create uniform bins with constant width.
lmindoubles as the bin floor; values below 2 are honoured (e.g.Bins.fromdeltal(1, 4, 1)includes the dipole).