diff --git a/modules/util/util.py b/modules/util/util.py index 3823a37ac7b24fddfbc2790cd4ad622413f27b8f..bca827668643e06b0e799990eb7ddcca5f786fc8 100644 --- a/modules/util/util.py +++ b/modules/util/util.py @@ -109,6 +109,17 @@ def bin_data_by(a, b, bin_ranges): return binned_data +def bin_data_by_edges(a, b, edges): + nbins = len(edges) - 1 + binned_data = [] + + for i in range(nbins): + idxs = (b >= edges[i]) & (b < edges[i+1]) + binned_data.append(a[idxs]) + + return binned_data + + def get_bin_ranges(lop, hip, bin_size=100): bin_ranges = [] delp = hip - lop