Skip to content

split_windows

function grb_trigger.features

grb_trigger.features.split_windows(detector_counts, i, background_bins_number=100, foreground_bins_number=10)

Split a detector time series into foreground and background windows.

The background window holds the background_bins_number bins before bin i; the foreground window holds the foreground_bins_number bins starting at bin i.

Parameters

detector_counts tuple of numpy.ndarray

(low_counts, high_counts), as returned by simulations.detector_counts.

i int

Index of the first foreground bin.

background_bins_number int, default 100

Number of bins in the background window.

foreground_bins_number int, default 10

Number of bins in the foreground window.

Returns

fg_window tuple of numpy.ndarray

(low, high) slices of the foreground window.

bg_window tuple of numpy.ndarray

(low, high) slices of the background window.

Raises

ValueError

If the channels are empty or differ in length, if a window size is not positive, or if there are not enough bins around i.

See Also

Examples

>>> bkg = generate_background(500)
>>> counts = detector_counts(bkg, [{"signal": generate_grb_pulse(50, 80),
... "start_bin": 200, "type": "grb"}])
>>> fg, bg = split_windows(counts, 200)
>>> len(fg[0]), len(bg[0])
(10, 100)