53 Plot the TP channel vs time over threshold scatter plot.
56 tp_data (np.ndarray): Array of TPs.
57 pdf (PdfPages): The PdfPages object that this plot will be appended to.
60 Nothing. Mutates :pdf: with the new plot.
62 Does not have a seconds option. This plot is more informative in the ticks version.
64 plt.figure(figsize=(6, 4), dpi=200)
66 plt.plot(tp_data[
'channel'], tp_data[
'samples_over_threshold'],
'hk', mew=0, alpha=0.4, ms=2, label=
'TP', rasterized=
True)
68 plt.title(
"TP Samples Over Threshold vs Channel")
70 plt.ylabel(
"Samples Over Threshold (Readout Ticks)")
81 Plot the ADC Integral vs ADC Peak.
84 tp_data (np.ndarray): Array of TPs.
85 pdf (PdfPages): The PdfPages object that this plot will be appended to.
86 verbosity (int): Verbose level to print information.
89 Nothing. Mutates :pdf: with the new plot.
93 "Number of ADC Integrals at Signed 16 Limit:",
94 np.sum(tp_data[
'adc_integral'] == np.power(2, 15)-1)
96 print(
"Total number of TPs:", len(tp_data[
'adc_peak']))
97 high_integral_locs = np.where(tp_data[
'adc_integral'] == np.power(2, 15)-1)
98 unity = (np.min(tp_data[
'adc_peak']), np.max(tp_data[
'adc_peak']))
100 plt.figure(figsize=(6, 4), dpi=200)
104 tp_data[
'adc_integral'],
115 tp_data[
'adc_peak'][high_integral_locs],
116 tp_data[
'adc_integral'][high_integral_locs],
132 plt.title(
"ADC Integral vs ADC Peak")
133 plt.xlabel(
"ADC Peak")
134 plt.ylabel(
"ADC Integral")
145 Writes the given summary statistics to :filename:.
148 data (np.ndarray): Array of a TP data member.
149 filename (str): File to append outputs to.
150 title (str): Title of the TP data member.
152 Appends statistics to the given file.
156 if np.all(data == data[0]):
157 print(f
"{title} data member is the same for all TPs. Skipping summary statistics.")
160 summary = stats.describe(data)
161 std = np.sqrt(summary.variance)
162 with open(filename,
'a')
as out:
163 out.write(f
"{title}\n")
164 out.write(f
"Reference Statistics:\n"
165 f
"\tTotal # TPs = {summary.nobs},\n"
166 f
"\tMean = {summary.mean:.2f},\n"
167 f
"\tStd = {std:.2f},\n"
168 f
"\tMin = {summary.minmax[0]},\n"
169 f
"\tMax = {summary.minmax[1]}.\n")
170 std3_count = np.sum(data > summary.mean + 3*std) + np.sum(data < summary.mean - 3*std)
171 std2_count = np.sum(data > summary.mean + 2*std) + np.sum(data < summary.mean - 2*std)
172 out.write(f
"Anomalies:\n"
173 f
"\t# of >3 Sigma TPs = {std3_count},\n"
174 f
"\t# of >2 Sigma TPs = {std2_count}.\n")
243 Drives the processing and plotting.
247 filename = args.filename
248 verbosity = args.verbose
249 start_frag = args.start_frag
250 end_frag = args.end_frag
251 no_anomaly = args.no_anomaly
252 seconds = args.seconds
253 overwrite = args.overwrite
254 batch_mode = args.batch_mode
260 if (
not linear)
and (
not log):
267 if len(data.get_fragment_paths()) == 0:
268 print(
"File doesn't contain any TriggerPrimitive fragments.")
272 if start_frag == 0
and end_frag == -1:
273 data.read_all_fragments()
276 frag_paths = data.get_fragment_paths()[start_frag:]
278 frag_paths = data.get_fragment_paths()[start_frag:end_frag]
280 for path
in frag_paths:
281 data.read_fragment(path)
284 save_name =
find_save_name(data.run_id, data.file_index, overwrite)
286 print(f
"Number of TPs: {data.tp_data.shape[0]}")
291 anomaly_filename = f
"{save_name}.txt"
293 print(f
"Writing descriptive statistics to {anomaly_filename}.")
294 if os.path.isfile(anomaly_filename):
296 os.remove(anomaly_filename)
298 time_label =
"Time (s)" if seconds
else "Time (Ticks)"
303 'title':
"ADC Integral Histogram",
304 'xlabel':
"ADC Integral",
307 'linear_style': dict(color=
'#63ACBE', alpha=0.6, label=
'Linear'),
309 'log_style': dict(color=
'#EE442F', alpha=0.6, label=
'Log')
312 'title':
"ADC Peak Histogram",
313 'xlabel':
"ADC Count",
316 'linear_style': dict(color=
'#63ACBE', alpha=0.6, label=
'Linear'),
318 'log_style': dict(color=
'#EE442F', alpha=0.6, label=
'Log')
325 'title':
"Channel Histogram",
326 'xlabel':
"Channel Number",
329 'linear_style': dict(color=
'#63ACBE', alpha=0.6, label=
'Linear'),
331 'log_style': dict(color=
'#EE442F', alpha=0.6, label=
'Log')
334 'title':
"Detector ID Histogram",
335 'xlabel':
"Detector IDs",
338 'linear_style': dict(color=
'#63ACBE', alpha=0.6, label=
'Linear'),
340 'log_style': dict(color=
'#EE442F', alpha=0.6, label=
'Log'),
341 'use_integer_xticks':
True
344 'title':
"Flag Histogram",
348 'linear_style': dict(color=
'#63ACBE', alpha=0.6, label=
'Linear'),
350 'log_style': dict(color=
'#EE442F', alpha=0.6, label=
'Log'),
351 'use_integer_xticks':
True
353 'samples_over_threshold': {
354 'title':
"Samples Over Threshold Histogram",
355 'xlabel': time_label,
358 'linear_style': dict(color=
'#63ACBE', alpha=0.6, label=
'Linear'),
360 'log_style': dict(color=
'#EE442F', alpha=0.6, label=
'Log')
363 'title':
"Samples To Peak Histogram",
364 'xlabel': time_label,
367 'linear_style': dict(color=
'#63ACBE', alpha=0.6, label=
'Linear'),
369 'log_style': dict(color=
'#EE442F', alpha=0.6, label=
'Log')
372 'title':
"Relative Time Start Histogram",
373 'xlabel': time_label,
376 'linear_style': dict(color=
'#63ACBE', alpha=0.6, label=
'Linear'),
378 'log_style': dict(color=
'#EE442F', alpha=0.6, label=
'Log')
381 'title':
"Version Histogram",
382 'xlabel':
"Versions",
385 'linear_style': dict(color=
'#63ACBE', alpha=0.6, label=
'Linear'),
387 'log_style': dict(color=
'#EE442F', alpha=0.6, label=
'Log'),
388 'use_integer_xticks':
True
392 pdf_plotter = PDFPlotter(save_name)
395 for tp_key
in data.tp_data.dtype.names:
397 time = data.tp_data[tp_key]
399 time = time * TICK_TO_SEC_SCALE
400 min_time = np.min(time)
401 pdf_plotter.plot_histogram(time - min_time, plot_hist_dict[tp_key])
406 pdf_plotter.plot_histogram(data.tp_data[tp_key], plot_hist_dict[tp_key])
410 pdf = pdf_plotter.get_pdf()