Skip to content
Snippets Groups Projects
Commit 47b58c39 authored by Katjana Neumann's avatar Katjana Neumann
Browse files

sumlab_auto: add as output of peakotron mean

parent ffe7052a
No related branches found
No related tags found
No related merge requests found
......@@ -69,7 +69,7 @@ print("=======================================\033[0m")
# Loop thorough SORTED files in alphabetical order!
files_to_fit = sorted(files_to_fit, key=lambda x: x[0])
G = []; d_G = []; G_prefit = []; d_G_prefit = []
G = []; d_G = []; mu=[]; d_mu=[]; G_prefit = []; d_G_prefit = []; mu_prefit=[]; d_mu_prefit=[]
V_bias = []
t_gates=[]
for i, (file, path) in enumerate(files_to_fit):
......@@ -102,6 +102,8 @@ for i, (file, path) in enumerate(files_to_fit):
prefit_val, prefit_err = f_data.GetPrefitResults(bin_units=False)
print("\033[95m"+rf"Prefit: G = {prefit_val.get('G')
} d_G = {prefit_err.get('G')}"+"\033[0m")
print("\033[95m"+rf"Prefit: mu = {prefit_val.get('mu')
} d_mu = {prefit_err.get('mu')}"+"\033[0m")
for key, value in prefit_val.items():
fit_out["prefit_{:s}".format(key)] = value
for key, value in prefit_err.items():
......@@ -111,6 +113,8 @@ for i, (file, path) in enumerate(files_to_fit):
fit_val, fit_err = f_data.GetFitResults(bin_units=False)
print("\033[95m"+rf"Fit: G = {fit_val.get('G')
} d_G = {fit_err.get('G')}"+"\033[0m")
print("\033[95m"+rf"Fit: mu = {fit_val.get('mu')
} d_mu = {fit_err.get('mu')}"+"\033[0m")
for key, value in fit_val.items():
fit_out["{:s}".format(key)] = value
for key, value in fit_err.items():
......@@ -121,27 +125,42 @@ for i, (file, path) in enumerate(files_to_fit):
df = pd.DataFrame.from_dict([fit_out])
df.to_csv("{}/fit_results_{:s}.csv".format(folder, file[:-4]))
if not prefit_only and 'G' in fit_out and 'd_G' in fit_out:
if not prefit_only and 'G' in fit_out and 'd_G' in fit_out and 'mu' in fit_out and 'd_mu' in fit_out:
G.append(fit_out['G'])
d_G.append(fit_out['d_G'])
mu.append(fit_out['mu'])
d_mu.append(fit_out['d_mu'])
else:
G.append(0)
d_G.append(0)
mu.append(0)
d_mu.append(0)
G_prefit.append(fit_out['prefit_G'])
d_G_prefit.append(fit_out['prefit_d_G'])
mu_prefit.append(fit_out['prefit_mu'])
d_mu_prefit.append(fit_out['prefit_d_mu'])
G = np.array(G)
d_G = np.array(d_G)
mu=np.array(mu)
d_mu= np.array(d_mu)
G_prefit = np.array(G_prefit)
d_G_prefit = np.array(d_G_prefit)
mu_prefit=np.array(mu_prefit)
d_mu_prefit=np.array(d_mu_prefit)
V_bias = np.array(V_bias)
t_gates = np.array(t_gates)
with h5py.File(f"{folder}/{os.path.basename(folder)}.h5", 'w') as f:
f.create_dataset('G', data=G)
f.create_dataset('d_G', data=d_G)
f.create_dataset('mu',data=mu)
f.create_dataset('d_mu',data=d_mu)
f.create_dataset('G_prefit', data=G_prefit)
f.create_dataset('d_G_prefit', data=d_G_prefit)
f.create_dataset('mu_prefit', data=mu_prefit)
f.create_dataset('d_mu_prefit', data=d_mu_prefit)
f.create_dataset('V_bias', data=V_bias)
f.create_dataset('integral_length', data=t_gates)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment