def bin_by_bayesian_blocks(self, start, stop, p0, use_background=False): events = self._arrival_times[np.logical_and( self._arrival_times >= start, self._arrival_times <= stop)] #self._temporal_binner = TemporalBinner(events) if use_background: integral_background = lambda t: self.get_total_poly_count(start, t) self._temporal_binner = TemporalBinner.bin_by_bayesian_blocks( events, p0, bkg_integral_distribution=integral_background) else: self._temporal_binner = TemporalBinner.bin_by_bayesian_blocks( events, p0)
def bin_by_custom(self, start, stop): """ Interface to temporal binner's custom bin mode :param start: start times of the bins :param stop: stop times of the bins :return: """ self._temporal_binner = TemporalBinner.bin_by_custom(start, stop)
def bin_by_constant(self, start, stop, dt=1): """ Interface to the temporal binner's constant binning mode :param start: start time of the bins :param stop: stop time of the bins :param dt: temporal spacing of the bins :return: """ events = self._arrival_times[np.logical_and(self._arrival_times >= start, self._arrival_times <= stop)] self._temporal_binner = TemporalBinner.bin_by_constant(events, dt)
def bin_by_significance(self, start, stop, sigma, mask=None, min_counts=1): """ Interface to the temporal binner's significance binning model :param start: start of the interval to bin on :param stop: stop of the interval ot bin on :param sigma: sigma-level of the bins :param mask: (bool) use the energy mask to decide on ,significance :param min_counts: minimum number of counts per bin :return: """ if mask is not None: # create phas to check phas = np.arange(self._first_channel, self._n_channels)[mask] this_mask = np.zeros_like(self._arrival_times, dtype=bool) for channel in phas: this_mask = np.logical_or(this_mask, self._measurement == channel) events = self._arrival_times[this_mask] else: events = copy.copy(self._arrival_times) events = events[np.logical_and(events <= stop, events >= start)] def tmp_bkg_getter(a, b): return self.get_total_poly_count(a, b, mask) def tmp_err_getter(a, b): return self.get_total_poly_error(a, b, mask) # self._temporal_binner.bin_by_significance(tmp_bkg_getter, # background_error_getter=tmp_err_getter, # sigma_level=sigma, # min_counts=min_counts) self._temporal_binner = TemporalBinner.bin_by_significance( events, tmp_bkg_getter, background_error_getter=tmp_err_getter, sigma_level=sigma, min_counts=min_counts, )