This PR allows the user to specify whether "overflow" events are included in the leftmost and rightmost bins when rebinning. Changes the default to not including overflow events since it can lead to confusion (see #334).
The following MWE demonstrates the different functionality:
import numpy as np
import becquerel as bq
counts = 1000 * np.ones(10)
spec = bq.Spectrum(counts=counts)
cal = bq.Calibration("p[0] * x", [1.0])
spec.apply_calibration(cal)
print("Original spectrum:")
print("edges: ", spec.bin_edges_kev)
print("values:", spec.counts_vals)
for edges in [
np.linspace(2, 9, num=8),
np.linspace(2.5, 9.5, num=8),
]:
for method in ["interpolation", "listmode"]:
for include_overflows in [True, False]:
spec2 = spec.rebin(edges, method=method, include_overflows=include_overflows)
print("")
print(f"Rebinned spectrum (method={method}, include_overflows={include_overflows}):")
print("edges: ", spec2.bin_edges_kev)
print("values:", spec2.counts_vals)
This PR allows the user to specify whether "overflow" events are included in the leftmost and rightmost bins when rebinning. Changes the default to not including overflow events since it can lead to confusion (see #334).
The following MWE demonstrates the different functionality:
The output is:
Fixes #334