calculate_bin_indices
- pyirf.binning.calculate_bin_indices(data, bins)[source]
Calculate bin indices for given data array and bins. Underflow will be UNDERFLOW_INDEX and overflow OVERFLOW_INDEX.
If the bins already include underflow / overflow bins, e.g. bins[0] = -np.inf and bins[-1] = np.inf, using the result of this function will always be a valid index into the resulting histogram.
- Parameters:
- data: ``~np.ndarray`` or ``~astropy.units.Quantity``
Array with the data
- bins: ``~np.ndarray`` or ``~astropy.units.Quantity``
Array or Quantity of bin edges. Must have the same unit as
data
if a Quantity.
- Returns:
- bin_index: np.ndarray[int]
Indices of the histogram bin the values in data belong to. Under- and overflown values will have values of UNDERFLOW_INDEX and OVERFLOW_INDEX respectively.