diff --git a/example.py b/example.py deleted file mode 100644 index f763a9b1cbffea5f1bf7011010351a9254839f35..0000000000000000000000000000000000000000 --- a/example.py +++ /dev/null @@ -1,106 +0,0 @@ - -import os -import sys -import numpy as np -import pandas as pd -from PeakOTron import PeakOTron -from joblib import dump -import time - -print("--------------------") -print('EXAMPLE SIPM CALIBRATION RUN') -print("--------------------") - - -out_dict = {} -files_to_fit = [] - -## Find all histograms in directory -for root, dirs, files in os.walk("./data/hamamatsu_pcb6/Light"): - - for file in files: - - if file.endswith(".txt"): - files_to_fit.append([file, os.path.join(root, file)]) - - -## Print files. -print("Files to fit:") -for i, (file, _) in enumerate(files_to_fit): - print('File {0}: {1}'.format(i, file)) - - - -SiPM = "PM1125NS_SBO" - - -## Loop thorough files -for i, (file, path) in enumerate(files_to_fit): - items = file.split('_') - - V = float(items[2].replace('V', '').replace('p', '.')) - - print("\n\n") - print("===============================================================") - print("FIT {:d} - {:s}".format(i, file)) - print("===============================================================") - print("\n\n") - - - ## Load files. - data = np.loadtxt(path, skiprows=8) - - ## Create a PeakOTron Fit Object. - f_data = PeakOTron(verbose=True) - - ## Perform fit. - time_start = time.time() - f_data.Fit(data, - tau=21.953, #SLOW PULSE COMPONENT TIME CONSTANT (ns) - t_gate=104, #GATE LENGTH (ns) - t_0 = 64, #INTEGRATION TIME BEFORE GATE (ns) - tau_R=21.953, - truncate_nG=0.333 - - ) #BINNING RULE "knuth", "freedman", "scott" - use bw= #### to override. it is still required for DCR calculation. - time_end = time.time() - print("\n") - print("Fit took {:3.3f} s".format(time_end - time_start)) - print("\n") - - f_data.PlotFit(xlabel="ADC", display=False, save_directory="./Results/{0}_fit.png".format(os.path.splitext(file)[0])) - - - - dump(f_data, "./Results/{0}".format(os.path.splitext(file)[0])) - - - - fit_out = {} - fit_val, fit_err = f_data.GetFitResults() - for key, val in fit_val.items(): - print("{:s} : {:3.3E}".format(key, val)) - - fit_out["SiPM"] = SiPM - fit_out["V"] = V - - for key, value in fit_err.items(): - fit_out["d_{:s}".format(key)] = value - - fit_out.update(fit_val) - out_dict.update() - if out_dict == {}: - for key in fit_out.keys(): - out_dict[key] = [] - - for key in fit_out.keys(): - out_dict[key].append(fit_out[key]) - - print("===============================================================") - print("\n\n") - - - - -df = pd.DataFrame.from_dict(out_dict) -df.to_csv("./fit_results_{:s}.csv".format(SiPM))