Skip to content
Snippets Groups Projects
Commit 963c0058 authored by Antonello, Dr. Massimiliano's avatar Antonello, Dr. Massimiliano
Browse files

Some changes to sumlab_auto to save now also a sumlab compatible h5 file

parent 457bb620
No related branches found
No related tags found
No related merge requests found
...@@ -7,3 +7,4 @@ numpy ...@@ -7,3 +7,4 @@ numpy
pandas pandas
scipy scipy
argparse argparse
h5py
\ No newline at end of file
...@@ -2,10 +2,10 @@ import sys ...@@ -2,10 +2,10 @@ import sys
import os import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from PeakOTron import PeakOTron from PeakOTron import PeakOTron
import pandas as pd import h5py
import numpy as np
import argparse import argparse
import numpy as np
import pandas as pd
def float_or_none(value): def float_or_none(value):
return None if value.lower() == 'none' else float(value) return None if value.lower() == 'none' else float(value)
...@@ -69,13 +69,18 @@ print("=======================================\033[0m") ...@@ -69,13 +69,18 @@ print("=======================================\033[0m")
# Loop thorough SORTED files in alphabetical order! # Loop thorough SORTED files in alphabetical order!
files_to_fit = sorted(files_to_fit, key=lambda x: x[0]) files_to_fit = sorted(files_to_fit, key=lambda x: x[0])
G = []; d_G = []; G_prefit = []; d_G_prefit = []
V_bias = []
for i, (file, path) in enumerate(files_to_fit): for i, (file, path) in enumerate(files_to_fit):
V = float(file.split('deg')[1].split('V')[0].replace('_', '.')) V = float(file.split('deg')[1].split('V')[0].replace('_', '.'))
if 'ns' in file: if 'ns' in file:
t_gate = float(file.split('V')[1].split('ns')[0].replace('_', '.')) t_gate = float(file.split('V')[1].split('ns')[0].replace('_', '.'))
print(f"Fitting: \033[95m{file}\033[0m (t_gate = {t_gate} ns)") print(f"Fitting: \033[95m{file}\033[0m (t_gate = {t_gate} ns)")
#items = file.split('_')
#V = float(items[2].replace('V', '').replace('p', '.'))
# f_tau_hmt = f_tau(V, V_bd_hmt, V_0_hmt) # f_tau_hmt = f_tau(V, V_bd_hmt, V_0_hmt)
V_bias.append(V)
# Load files. # Load files.
data = np.loadtxt(path, skiprows=0) data = np.loadtxt(path, skiprows=0)
...@@ -95,7 +100,8 @@ for i, (file, path) in enumerate(files_to_fit): ...@@ -95,7 +100,8 @@ for i, (file, path) in enumerate(files_to_fit):
fit_out = {} fit_out = {}
prefit_val, prefit_err = f_data.GetPrefitResults(bin_units=False) 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: G = {prefit_val.get('G')
} d_G = {prefit_err.get('G')}"+"\033[0m")
for key, value in prefit_val.items(): for key, value in prefit_val.items():
fit_out["prefit_{:s}".format(key)] = value fit_out["prefit_{:s}".format(key)] = value
for key, value in prefit_err.items(): for key, value in prefit_err.items():
...@@ -103,7 +109,8 @@ for i, (file, path) in enumerate(files_to_fit): ...@@ -103,7 +109,8 @@ for i, (file, path) in enumerate(files_to_fit):
if not prefit_only: if not prefit_only:
fit_val, fit_err = f_data.GetFitResults(bin_units=False) 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: G = {fit_val.get('G')
} d_G = {fit_err.get('G')}"+"\033[0m")
for key, value in fit_val.items(): for key, value in fit_val.items():
fit_out["{:s}".format(key)] = value fit_out["{:s}".format(key)] = value
for key, value in fit_err.items(): for key, value in fit_err.items():
...@@ -114,4 +121,26 @@ for i, (file, path) in enumerate(files_to_fit): ...@@ -114,4 +121,26 @@ for i, (file, path) in enumerate(files_to_fit):
df = pd.DataFrame.from_dict([fit_out]) df = pd.DataFrame.from_dict([fit_out])
df.to_csv("{}/fit_results_{:s}.csv".format(folder, file[:-4])) 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:
G.append(fit_out['G'])
d_G.append(fit_out['d_G'])
else:
G.append(0)
d_G.append(0)
G_prefit.append(fit_out['prefit_G'])
d_G_prefit.append(fit_out['prefit_d_G'])
G = np.array(G)
d_G = np.array(d_G)
G_prefit = np.array(G_prefit)
d_G_prefit = np.array(d_G_prefit)
V_bias = np.array(V_bias)
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('G_prefit', data=G_prefit)
f.create_dataset('d_G_prefit', data=d_G_prefit)
f.create_dataset('V_bias', data=V_bias)
print("\033[95m=======================================\033[0m") print("\033[95m=======================================\033[0m")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment