Skip to content
Snippets Groups Projects
Commit d51716de authored by Alexandros Asonitis's avatar Alexandros Asonitis
Browse files

cleaner code

parent c489c53a
No related branches found
No related tags found
No related merge requests found
......@@ -198,7 +198,7 @@ def sweep(start,stop,step,comp,integration,device): #step cannot be negative
#sampling check
def sampling_check(voltage,device):
# red color code red = '\033[91m'
parameters ={
'mode' : 'LIN',
'hold': 0,
......@@ -252,6 +252,11 @@ def sampling_check(voltage,device):
R = np.array(R)
R_mean = np.average(R)
device.del_user_functions()
if np.max(R)/np.min(R)>10:
# red color code red = '\033[91m'
red = '\033[91m'
print()
return R_mean
......@@ -321,7 +326,6 @@ def retention(voltage,period,duration,device):
#plot sweep results
def plot_sweep(x,y,title):
#plot results
plt.figure().clear()
fig, (ax1, ax2) = plt.subplots(2,sharex=True,figsize=(8,6)) #the plots share the same x axis
fig.suptitle(title)
ax1.set_title('Linear I')
......@@ -332,8 +336,8 @@ def plot_sweep(x,y,title):
ax1.plot(x,y)
ax2.plot(x,np.absolute(y))
plt.tight_layout()
plt.show()
fig.tight_layout()
display(fig)
def plot_retention(x,y):
fig, ax = plt.subplots()
......@@ -341,14 +345,14 @@ def plot_retention(x,y):
ax.set(xlabel='time(s)',ylabel='Resistance(Ohm)')
ax.set_yscale('log')
ax.set_xscale('linear')
plt.plot(x,y)
plt.show()
ax.plot(x,y)
display(fig)
def create_data_frame(x,y):
header = ['V(V)','ABSV(V)',"I(A)",'ABSI(A)',"R(Ohm)"]
data = {header[0]:x,header[1]:np.absolute(x),header[2]:y,header[3]:np.absolute(y),header[4]:np.divide(x,y)}
df = pd.DataFrame(data)
#print(df)
return df
def create_retention_data_frame(x,y):
......@@ -474,21 +478,12 @@ def choose_folder():
return folder
#write the header
def write_header(file,sample_series,field,DUT):
date = str(datetime.today().replace(microsecond=0))
with open(file,'a') as f:
title = f"Memristor Measurement"+"\n\n"+f"Sample series:{sample_series.value}" +"\n"+f"field:{field.value}"+"\n"+f"DUT:{DUT.value}"+"\n"+f"Date:{date}"+"\n\n"
f.write(title)
def upload_results(source_file,target_file,target_file_dir):
"""
New function (UPLOAD RESULTS)
IMPORTANT FOR ALL MEASUREMENTS
THE RESULTS ARE MOVED FROM SOURCE FILE TO TARGET FILE EVEN LOCALLY
"""
def upload_results(source_file,target_file,target_file_dir):
while True:
try:
with (open(source_file,'r') as source,open(target_file,'a') as target):
......
......@@ -130,7 +130,7 @@ def plot_sweep_pulse(values):
fig.suptitle("Sweep Pulse Measurement Results")
plt.show()
display(fig)
def save_sweep(folder,sample_dict,values,times,sweep_dict):
filename = f"{sample_dict['series'].value}_{sample_dict['field'].value}_{sample_dict['dut'].value}.txt"
......@@ -273,7 +273,7 @@ def plot_constant_pulse(values):
fig.suptitle("Constant Pulse Measurement Results")
ax1.set_title("Voltage:"+str(min(values[0]))+"V")
plt.show()
display(fig)
def save_constant(folder,sample_dict,values,times,cons_dict):
filename = f"{sample_dict['series'].value}_{sample_dict['field'].value}_{sample_dict['dut'].value}.txt"
......
......@@ -402,6 +402,7 @@ def on_full_button_clicked(b):
add_hotkey("esc",break_loop)
#execute number of measurements
for i in range(number.value):#here it is easier to implement the sampling checks
clear_output(wait = True)
if sampling.value == True: #before set(100mv)
R_mean_init = sampling_check(-0.01,device)
resistances.append(R_mean_init)
......@@ -457,9 +458,7 @@ def on_full_button_clicked(b):
fig.tight_layout()
#update plot
clear_output()
display(fig)
#plt.show()
display(df)
#check for loop termination
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment