Skip to content
Snippets Groups Projects
Commit 1ff321a1 authored by Jack Christopher Hutchinson Rolph's avatar Jack Christopher Hutchinson Rolph
Browse files

Update PeakOTron.py

parent 109ab810
Branches
Tags
No related merge requests found
......@@ -1352,15 +1352,19 @@ class PeakOTron:
ppf = self.EmpiricalPPF(data_s)
if(bin_method == "knuth"):
bw_s, bins_s = knuth_bin_width(data_s[data_s<ppf(alpha)], return_bins=True)
bw_s = knuth_bin_width(data_s[data_s<ppf(alpha)])
elif(bin_method=="freedman"):
bw_s, bins_s = freedman_bin_width(data_s[data_s<ppf(alpha)], return_bins=True)
bw_s = freedman_bin_width(data_s[data_s<ppf(alpha)])
elif(bin_method=="scott"):
bw_s, bins_s = scott_bin_width(data_s[data_s<ppf(alpha)], return_bins=True)
bw_s = scott_bin_width(data_s[data_s<ppf(alpha)])
else:
raise Exception ("Please specify a bin width by setting 'bw' or choose a method from 'knuth', 'freedman' or 'scott'")
nbins_s = len(bins_s)
nbins_s = np.ceil((data_s.max() - data_s.min()) / bw_s)
nbins_s = max(1, nbins_s)
bins_s = data_s.min() + bw_s * np.arange(nbins_s + 1)
bw = bw_s*self.scaler.scale_[0]
nbins = np.ceil((data.max() - data.min()) / bw)
......@@ -1381,6 +1385,19 @@ class PeakOTron:
bins_s = data_s.min() + bw_s * np.arange(nbins_s + 1)
else:
bw_s = bw/self.scaler.scale_[0]
nbins = np.ceil((data.max() - data.min()) / bw)
nbins = max(1, nbins)
bins = data.min() + bw * np.arange(nbins + 1)
nbins_s = np.ceil((data_s.max() - data_s.min()) / bw_s)
nbins_s = max(1, nbins_s)
bins_s = data_s.min() + bw_s * np.arange(nbins_s + 1)
if(nbins<50):
......@@ -1471,27 +1488,27 @@ class PeakOTron:
pedestal = pedestal_s*self.scaler.scale_[0] + self.scaler.center_[0]
est_gain = est_gain_s*self.scaler.scale_[0]
cond_ped_kde_s = (x_kde_s>pedestal_s - est_gain_s/2)
cond_ped_s = (x_s>pedestal_s - est_gain_s/2)
cond_ped = (x>pedestal - est_gain/2)
cond_ped_peaks = (x_peaks_s>pedestal_s - est_gain_s/2)
# cond_ped_kde_s = (x_kde_s>pedestal_s - est_gain_s/2)
# cond_ped_s = (x_s>pedestal_s - est_gain_s/2)
# cond_ped = (x>pedestal - est_gain/2)
# cond_ped_peaks = (x_peaks_s>pedestal_s - est_gain_s/2)
x_kde_s = x_kde_s[cond_ped_kde_s]
y_kde_s = y_kde_s[cond_ped_kde_s]
y_kde_err_s = y_kde_err_s[cond_ped_kde_s]
# x_kde_s = x_kde_s[cond_ped_kde_s]
# y_kde_s = y_kde_s[cond_ped_kde_s]
# y_kde_err_s = y_kde_err_s[cond_ped_kde_s]
x_s = x_s[cond_ped_s]
y_s = y_s[cond_ped_s]
y_err_s = y_err_s[cond_ped_s]
# x_s = x_s[cond_ped_s]
# y_s = y_s[cond_ped_s]
# y_err_s = y_err_s[cond_ped_s]
x_peaks_s = x_peaks_s[cond_ped_peaks]
y_peaks_s = y_peaks_s[cond_ped_peaks]
y_peaks_err_s = y_peaks_err_s[cond_ped_peaks]
x_widths_s = x_widths_s[cond_ped_peaks]
# x_peaks_s = x_peaks_s[cond_ped_peaks]
# y_peaks_s = y_peaks_s[cond_ped_peaks]
# y_peaks_err_s = y_peaks_err_s[cond_ped_peaks]
# x_widths_s = x_widths_s[cond_ped_peaks]
x = x[cond_ped]
y = y[cond_ped]
y_err = y_err[cond_ped]
# x = x[cond_ped]
# y = y[cond_ped]
# y_err = y_err[cond_ped]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment