binny.binning.core module#

Generic selection-based tomographic binning.

binny.binning.core.build_bins(z: NDArray[float64], nz: NDArray[float64], edges: NDArray[float64], assignment: Callable[[NDArray[float64], NDArray[float64]], NDArray[float64]], *, selection_kind: Literal['probability', 'weight'] = 'probability', normalize_bins: bool = False, norm_method: Literal['trapezoid', 'simpson'] = 'trapezoid', return_integrals: bool = False) → dict[int, NDArray[float64]] | tuple[dict[int, NDArray[float64]], dict[int, float], float]#

Build tomographic bins using a selection function.

Parameters:
  • z – Parent redshift grid.

  • nz – Parent redshift distribution.

  • edges – Bin edges in the selection coordinate.

  • assignment – Function returning selections of shape (n_bins, n_z).

  • selection_kind – Whether selections are probabilities in [0, 1] or non-negative weights.

  • normalize_bins – Whether to normalize each bin.

  • norm_method – Integration method for normalization and population integrals.

  • return_integrals – Whether to return raw bin integrals and the parent integral.

Returns:

Dictionary of bin distributions, optionally accompanied by bin integrals and the parent integral.

Raises:

ValueError – If the selection type, shape, or values are invalid.