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

debugging part 3 software plots work

parent 66202602
Branches
No related tags found
No related merge requests found
%% Cell type:code id:51b012d0-95b0-41c2-81bb-2205f3c53be2 tags:
``` python
%run double_gate_ADU.py
```
%% Output
%% Cell type:code id:1a0e956e-9d25-481e-b1ec-b03babcb4c19 tags:
%% Cell type:code id:40d5f341-bc61-4698-8bdd-f99e94f4e325 tags:
``` python
```
......
......@@ -204,7 +204,7 @@ def graph_tool(params,device):
device.delete_axis("Y2")
device.del_user_functions()
device.error()
device.clear_error_stack()
# How to define user functions correctly and not multiple times
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
......@@ -227,27 +227,76 @@ def graph_tool(params,device):
# Now send the parameters in the tool
device.display_variable('X',params["PLOT"]["x"])
device.axis_scale('X',params["PLOT"]["x_scale"])
device.error_occured()
device.axis_scale('X','LIN')
device.error_occured()
device.display_variable_min_max('X','MIN',params["PLOT"]["x_min"])
device.error_occured()
device.display_variable_min_max('X','MAX',params["PLOT"]["x_max"])
device.error_occured()
if params["PLOT"]["y1_scale"]=='LOG':
device.display_variable('Y1',"A"+params["PLOT"]["y1"])
else:
device.display_variable('Y1',params["PLOT"]["y1"])
device.error_occured()
device.axis_scale('Y1',params["PLOT"]["y1_scale"])
device.error_occured()
device.display_variable_min_max('Y1','MIN',params["PLOT"]["y1_min"])
device.error_occured()
device.display_variable_min_max('Y1','MAX',params["PLOT"]["y1_max"])
device.error_occured()
if params["PLOT"]["y2"]!= "None":
if params["PLOT"]["y2_scale"]=='LOG':
device.display_variable('Y2',"A"+params["PLOT"]["y2"])
else:
device.display_variable('Y2',params["PLOT"]["y2"])
device.error_occured()
device.axis_scale('Y2',params["PLOT"]["y2_scale"])
device.error_occured()
device.display_variable_min_max('Y2','MIN',params["PLOT"]["y2_min"])
device.display_variable_min_max('Y2','MAX',params["PLOT"]["y2_max"])
device.error_occured()
#plot software functions
def values_to_plot(params,device):
#plotted variables as they are named in the tool
#return the plotted data for easier configuration
plotted_variables = {'X':device.get_axis_variable('X'),'Y1': device.get_axis_variable('Y1')}
if params["PLOT"]["y2"]!= "None":
plotted_variables['Y2']= device.get_axis_variable('Y2')
plot_values ={}
for axis,variable in plotted_variables.items():
plot_values.setdefault(axis,np.array(device.return_values(variable)))
return plot_values
def set_axes_labels(plot_list):
axes_labels=[]
# define the axes labels similarly to the user functions
for element in plot_list:
if element != "None": #only the last one
if element.startswith("V"):
label = f"{element} (V)"
elif element.startswith('I') and element.endswith('mm'):
label = f"{element[:-2]} (uA/um)"
else: # regular I
label = f"{element} (A)"
axes_labels.append(label)
return axes_labels
......@@ -26,7 +26,7 @@ def Transfer_VTG(device,params):
norm = normalization_factor(params["SAMPLE"]["width"])
points = params["VAR2"]["points"]
try:
device.setup_smu(params["MAP"]['TG'],params["SMU_T"])
device.setup_smu(params["MAP"]['D'],params["SMU_D"])
device.setup_smu(params["MAP"]['BG'],params["SMU_B"])
......@@ -40,85 +40,30 @@ def Transfer_VTG(device,params):
variables_list =["VTG","ITG","VDS","ID"]
device.variables_to_save(variables_list)
try:
plotted_variables = graph_tool(params,device)
except Exception as e:
error_box(e)
return
device.single_measurement()
while device.operation_completed()==False:
pass
device.autoscaling()
device.error_occured()
values = dict([(variable,device.return_values(variable)) for variable in variables_list])
df = get_dataframe_from_results(values)
except Exception as e:
error_box(e)
return
# Append the normalized current
df["IDmm/uA/um"]= (df["ID/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
df["ITGmm/uA/um"]= (df["ITG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
#plotted variables as they are named in the tool
#return the plotted data for easier configuration
plotted_variables = {'X':device.get_axis_variable('X'),'Y1': device.get_axis_variable('Y1')}
if params["PLOT"]["y2"]!= "None":
plotted_variables['Y2']= device.get_axis_variable('Y2')
plot_values ={}
for axis,variable in plotted_variables.items():
plot_values.setdefault(axis,np.array(device.return_values(variable)))
# Plot user specified results
fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
scale_list = [params["PLOT"]["x_scale"],params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
axes_labels = []
if scale_list[0] == 'LOG':
ax1.set_xscale('log')
if scale_list[1]=='LOG':
ax1.set_yscale('log')
# define the axes labels similarly to the user functions
for element in plot_list:
if element != "None": #only the last one
if element.startswith("V"):
label = f"{element} (V)"
elif element.startswith('I') and element.endswith('mm'):
label = f"{element[:-2]} (uA/(um))"
else: # regular I
label = f"{element} (A)"
axes_labels.append(label)
#now set the labels
ax1.set_xlabel(axes_labels[0])
ax1.set_ylabel(axes_labels[1])
x = np.split(plot_values['X'],points)
y1 = np.split(plot_values['Y1'],points)
labels =np.mean(np.array_split(df["VDS/V"],points),axis = 1) # VDS values for labels
for i in range(points):
ax1.plot(x[i],y1[i],label = f"VDS:{round(labels[i],3)} (V)")
#add the second axis if applicable
if plot_list[2]!= "None":
ax2 = ax1.twinx()
y2 = np.split(plot_values['Y2'],points)
if scale_list[2]=='LOG':
ax1.set_yscale('log')
ax2.set_ylabel(axes_labels[2])
for i in range(points):
ax2.plot(x[i],y2[i])
# Adding title
fig.suptitle('Transfer Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
# Save the results
default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_TOP_GATE_U.txt"
......@@ -166,13 +111,67 @@ def Transfer_VTG(device,params):
df.to_csv(file,sep=" ",mode='a')
plot_values = values_to_plot(params,device)
# Plot user specified results
fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
scale_list =['LIN',params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
axes_labels = set_axes_labels(plot_list)
if scale_list[1]=='LOG':
ax1.set_yscale('log')
#now set the labels
ax1.set_xlabel(axes_labels[0])
ax1.set_ylabel(axes_labels[1])
x = np.split(plot_values['X'],points)
y1 = np.split(plot_values['Y1'],points)
labels =np.mean(np.array_split(df["VDS/V"],points),axis = 1) # VDS values for labels
for i in range(points):
ax1.plot(x[i],y1[i],label = f"VDS:{round(labels[i],3)} (V)")
# Adding title
fig.suptitle('Transfer Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
#save plot if checked
if params["SAMPLE"]['save_fig'] == True:
filename= os.path.splitext(file)[0]
fig.savefig(filename+'_Y1.png')
#add the second axis if applicable
if plot_list[2]!= "None":
fig,ax2=plt.subplots(figsize=(10,6),layout='constrained')
y2 = np.split(plot_values['Y2'],points)
if scale_list[2]=='LOG':
ax2.set_yscale('log')
ax2.set_xlabel(axes_labels[0])
ax2.set_ylabel(axes_labels[2])
for i in range(points):
ax2.plot(x[i],y2[i],label = f"VDS:{round(labels[i],3)} (V)")
# Adding title
fig.suptitle('Transfer Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
#save plot if checked
if params["SAMPLE"]['save_fig'] == True:
filename= os.path.splitext(file)[0]
fig.savefig(filename+'.png')
fig.savefig(filename+'_Y2.png')
# Transfer only VBG
def Transfer_VBG(device,params):
try:
device.setup_smu(params["MAP"]['TG'],params["SMU_T"])
device.setup_smu(params["MAP"]['D'],params["SMU_D"])
device.setup_smu(params["MAP"]['BG'],params["SMU_B"])
......@@ -187,17 +186,24 @@ def Transfer_VBG(device,params):
variables_list =["VBG","IBG","VDS","ID"]
device.variables_to_save(variables_list)
try:
plotted_variables = graph_tool(params,device)
except Exception as e:
error_box(e)
return
device.single_measurement()
while device.operation_completed()==False:
pass
device.autoscaling()
device.error_occured()
values = dict([(variable,device.return_values(variable)) for variable in variables_list])
df = get_dataframe_from_results(values)
except Exception as e:
error_box(e)
return
# calculate normalization factor
norm = normalization_factor(params["SAMPLE"]["width"])
points = params["VAR2"]["points"]
......@@ -206,70 +212,6 @@ def Transfer_VBG(device,params):
df["IDmm/uA/um"]= (df["ID/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
df["IBGmm/uA/um"]= (df["IBG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
#plotted variables as they are named in the tool
#return the plotted data for easier configuration
plotted_variables = {'X':device.get_axis_variable('X'),'Y1': device.get_axis_variable('Y1')}
if params["PLOT"]["y2"]!= "None":
plotted_variables['Y2']= device.get_axis_variable('Y2')
plot_values ={}
for axis,variable in plotted_variables.items():
plot_values.setdefault(axis,np.array(device.return_values(variable)))
# Plot user specified results
fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
scale_list = [params["PLOT"]["x_scale"],params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
axes_labels = []
if scale_list[0] == 'LOG':
ax1.set_xscale('log')
if scale_list[1]=='LOG':
ax1.set_yscale('log')
# define the axes labels similarly to the user functions
for element in plot_list:
if element != "None": #only the last one
if element.startswith("V"):
label = f"{element} (V)"
elif element.startswith('I') and element.endswith('mm'):
label = f"{element[:-2]} (uA/(um))"
else: # regular I
label = f"{element} (A)"
axes_labels.append(label)
#now set the labels
ax1.set_xlabel(axes_labels[0])
ax1.set_ylabel(axes_labels[1])
x = np.split(plot_values['X'],points)
y1 = np.split(plot_values['Y1'],points)
labels =np.mean(np.array_split(df["VDS/V"],points),axis = 1) # VDS values for labels
for i in range(points):
ax1.plot(x[i],y1[i],label = f"VDS:{round(labels[i],3)} (V)")
#add the second axis if applicable
if plot_list[2]!= "None":
ax2 = ax1.twinx()
y2 = np.split(plot_values['Y2'],points)
if scale_list[2]=='LOG':
ax1.set_yscale('log')
ax2.set_ylabel(axes_labels[2])
for i in range(points):
ax2.plot(x[i],y2[i])
# Adding title
fig.suptitle('Transfer Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
# Save the results
default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_BACK_GATE_U.txt"
......@@ -321,11 +263,66 @@ def Transfer_VBG(device,params):
df.to_csv(file,sep=" ",mode='a')
if params["SAMPLE"]["save_fig"] == True:
plot_values = values_to_plot(params,device)
# Plot user specified results
fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
scale_list =['LIN',params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
axes_labels = set_axes_labels(plot_list)
if scale_list[1]=='LOG':
ax1.set_yscale('log')
#now set the labels
ax1.set_xlabel(axes_labels[0])
ax1.set_ylabel(axes_labels[1])
x = np.split(plot_values['X'],points)
y1 = np.split(plot_values['Y1'],points)
labels =np.mean(np.array_split(df["VDS/V"],points),axis = 1) # VDS values for labels
for i in range(points):
ax1.plot(x[i],y1[i],label = f"VDS:{round(labels[i],3)} (V)")
# Adding title
fig.suptitle('Transfer Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
#save plot if checked
if params["SAMPLE"]['save_fig'] == True:
filename= os.path.splitext(file)[0]
fig.savefig(filename+'_Y1.png')
#add the second axis if applicable
if plot_list[2]!= "None":
fig,ax2=plt.subplots(figsize=(10,6),layout='constrained')
y2 = np.split(plot_values['Y2'],points)
if scale_list[2]=='LOG':
ax2.set_yscale('log')
ax2.set_xlabel(axes_labels[0])
ax2.set_ylabel(axes_labels[2])
for i in range(points):
ax2.plot(x[i],y2[i],label = f"VDS:{round(labels[i],3)} (V)")
# Adding title
fig.suptitle('Transfer Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
#save plot if checked
if params["SAMPLE"]['save_fig'] == True:
filename= os.path.splitext(file)[0]
fig.savefig(filename+'.png')
fig.savefig(filename+'_Y2.png')
def Transfer_BOTH(device,params):
try:
smu_t = device.smu_dict()
smu_t.update(vname = 'VTG',iname='ITG',mode = 'V',func='VAR1')
......@@ -347,16 +344,25 @@ def Transfer_BOTH(device,params):
variables_list =["VBG","IBG","VDS","ID","VTG","ITG"]
device.variables_to_save(variables_list)
try:
plotted_variables = graph_tool(params,device)
except Exception as e:
error_box(e)
return
device.single_measurement()
while device.operation_completed()==False:
pass
device.autoscaling()
device.error_occured()
values = dict([(variable,device.return_values(variable)) for variable in variables_list])
df = get_dataframe_from_results(values)
except Exception as e:
error_box(e)
return
# calculate normalization factor
norm = normalization_factor(params["SAMPLE"]["width"])
......@@ -368,70 +374,6 @@ def Transfer_BOTH(device,params):
df["ITGmm/uA/um"]= (df["ITG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
#plotted variables as they are named in the tool
#return the plotted data for easier configuration
plotted_variables = {'X':device.get_axis_variable('X'),'Y1': device.get_axis_variable('Y1')}
if params["PLOT"]["y2"]!= "None":
plotted_variables['Y2']= device.get_axis_variable('Y2')
plot_values ={}
for axis,variable in plotted_variables.items():
plot_values.setdefault(axis,device.return_values(variable))
# Plot user specified results
fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
scale_list = [params["PLOT"]["x_scale"],params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
axes_labels = []
if scale_list[0] == 'LOG':
ax1.set_xscale('log')
if scale_list[1]=='LOG':
ax1.set_yscale('log')
# define the axes labels similarly to the user functions
for element in plot_list:
if element != "None": #only the last one
if element.startswith("V"):
label = f"{element} (V)"
elif element.startswith('I') and element.endswith('mm'):
label = f"{element[:-2]} (uA/(um))"
else: # regular I
label = f"{element} (A)"
axes_labels.append(label)
#now set the labels
ax1.set_xlabel(axes_labels[0])
ax1.set_ylabel(axes_labels[1])
x = np.split(plot_values['X'],points)
y1 = np.split(plot_values['Y1'],points)
labels =np.mean(np.array_split(df["VDS/V"],points),axis = 1) # VDS values for labels
for i in range(points):
ax1.plot(x[i],y1[i],label = f"VDS:{round(labels[i],3)} (V)")
#add the second axis if applicable
if plot_list[2]!= "None":
ax2 = ax1.twinx()
y2 = np.split(plot_values['Y2'],points)
if scale_list[2]=='LOG':
ax1.set_yscale('log')
ax2.set_ylabel(axes_labels[2])
for i in range(points):
ax2.plot(x[i],y2[i])
# Adding title
fig.suptitle('Transfer Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
# Save the results
default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_BOTH_GATES_U.txt"
......@@ -488,112 +430,109 @@ def Transfer_BOTH(device,params):
f.write("\nResults\n")
df.to_csv(file,sep=" ",mode='a')
if params["SAMPLE"]["save_fig"] == True:
filename= os.path.splitext(file)[0]
fig.savefig(filename+'.png')
plot_values = values_to_plot(params,device)
# Output with VTG
def Output_VTG(device,params):
device.setup_smu(params['MAP']['TG'],params["SMU_T"])
device.setup_smu(params['MAP']['D'],params["SMU_D"])
device.setup_smu(params['MAP']['BG'],params["SMU_B"])
device.setup_smu(params['MAP']['S'],params["SMU_S"])
# Plot user specified results
fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
device.setup_var1(params["VAR1"])
device.setup_var2(params["VAR2"])
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
scale_list =['LIN',params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
axes_labels = set_axes_labels(plot_list)
device.integration_time(params["INTEGRATION"])
if scale_list[1]=='LOG':
ax1.set_yscale('log')
variables_list = ['VDS','ID','VTG','ITG']
device.variables_to_save(variables_list)
#now set the labels
ax1.set_xlabel(axes_labels[0])
ax1.set_ylabel(axes_labels[1])
plotted_variables = graph_tool(params,device)
x = np.split(plot_values['X'],points)
y1 = np.split(plot_values['Y1'],points)
labels =np.mean(np.array_split(df["VDS/V"],points),axis = 1) # VDS values for labels
device.single_measurement()
for i in range(points):
ax1.plot(x[i],y1[i],label = f"VDS:{round(labels[i],3)} (V)")
while device.operation_completed()==False:
pass
# Adding title
fig.suptitle('Transfer Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
device.autoscaling()
display(fig)
#save plot if checked
if params["SAMPLE"]['save_fig'] == True:
filename= os.path.splitext(file)[0]
fig.savefig(filename+'_Y1.png')
values = dict([(variable,device.return_values(variable)) for variable in variables_list])
df = get_dataframe_from_results(values)
# plot results
# calculate normalization factor
norm = normalization_factor(params['SAMPLE']["width"])
points = params["VAR2"]["points"]
#add the second axis if applicable
if plot_list[2]!= "None":
fig,ax2=plt.subplots(figsize=(10,6),layout='constrained')
y2 = np.split(plot_values['Y2'],points)
# Append the normalized current
df["IDmm/uA/um"]= (df["ID/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
df["ITGmm/uA/um"]= (df["ITG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
if scale_list[2]=='LOG':
ax2.set_yscale('log')
#plotted variables as they are named in the tool
#return the plotted data for easier configuration
plotted_variables = {'X':device.get_axis_variable('X'),'Y1': device.get_axis_variable('Y1')}
ax2.set_xlabel(axes_labels[0])
if params["PLOT"]["y2"]!= "None":
plotted_variables['Y2']= device.get_axis_variable('Y2')
ax2.set_ylabel(axes_labels[2])
for i in range(points):
ax2.plot(x[i],y2[i],label = f"VDS:{round(labels[i],3)} (V)")
plot_values ={}
for axis,variable in plotted_variables.items():
plot_values.setdefault(axis,np.array(device.return_values(variable)))
# Adding title
fig.suptitle('Transfer Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
# Plot user specified results
fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
display(fig)
#save plot if checked
if params["SAMPLE"]['save_fig'] == True:
filename= os.path.splitext(file)[0]
fig.savefig(filename+'Y2.png')
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
scale_list = [params["PLOT"]["x_scale"],params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
axes_labels = []
# Output with VTG
def Output_VTG(device,params):
try:
device.setup_smu(params['MAP']['TG'],params["SMU_T"])
device.setup_smu(params['MAP']['D'],params["SMU_D"])
device.setup_smu(params['MAP']['BG'],params["SMU_B"])
device.setup_smu(params['MAP']['S'],params["SMU_S"])
if scale_list[0] == 'LOG':
ax1.set_xscale('log')
device.setup_var1(params["VAR1"])
device.setup_var2(params["VAR2"])
if scale_list[1]=='LOG':
ax1.set_yscale('log')
device.integration_time(params["INTEGRATION"])
# define the axes labels similarly to the user functions
for element in plot_list:
if element != "None": #only the last one
if element.startswith("V"):
label = f"{element} (V)"
elif element.startswith('I') and element.endswith('mm'):
label = f"{element[:-2]} (uA/(um))"
else: # regular I
label = f"{element} (A)"
axes_labels.append(label)
variables_list = ['VDS','ID','VTG','ITG']
device.variables_to_save(variables_list)
#now set the labels
ax1.set_xlabel(axes_labels[0])
ax1.set_ylabel(axes_labels[1])
try:
plotted_variables = graph_tool(params,device)
except Exception as e:
error_box(e)
return
x = np.split(plot_values['X'],points)
y1 = np.split(plot_values['Y1'],points)
labels =np.mean(np.array_split(df["VTG/V"],points),axis = 1) # VDS values for labels
device.single_measurement()
for i in range(points):
ax1.plot(x[i],y1[i],label = f"VTG:{round(labels[i],3)} (V)")
while device.operation_completed()==False:
pass
#add the second axis if applicable
if plot_list[2]!= "None":
ax2 = ax1.twinx()
y2 = np.split(plot_values['Y2'],points)
device.autoscaling()
device.error_occured()
if scale_list[2]=='LOG':
ax1.set_yscale('log')
values = dict([(variable,device.return_values(variable)) for variable in variables_list])
df = get_dataframe_from_results(values)
except Exception as e:
error_box(e)
return
ax2.set_ylabel(axes_labels[2])
for i in range(points):
ax2.plot(x[i],y2[i])
# Adding title
fig.suptitle('Output Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
# plot results
# calculate normalization factor
norm = normalization_factor(params['SAMPLE']["width"])
points = params["VAR2"]["points"]
display(fig)
# Append the normalized current
df["IDmm/uA/um"]= (df["ID/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
df["ITGmm/uA/um"]= (df["ITG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
#save Results
# Save the results
default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_TOP_GATE_A.txt"
......@@ -643,12 +582,68 @@ def Output_VTG(device,params):
f.write("\nResults\n")
df.to_csv(file,sep=" ",mode='a')
if params["SAMPLE"]["save_fig"] == True:
plot_values = values_to_plot(params,device)
# Plot user specified results
fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
scale_list =['LIN',params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
axes_labels = set_axes_labels(plot_list)
if scale_list[1]=='LOG':
ax1.set_yscale('log')
#now set the labels
ax1.set_xlabel(axes_labels[0])
ax1.set_ylabel(axes_labels[1])
x = np.split(plot_values['X'],points)
y1 = np.split(plot_values['Y1'],points)
labels =np.mean(np.array_split(df["VTG/V"],points),axis = 1) # VDS values for labels
for i in range(points):
ax1.plot(x[i],y1[i],label = f"VTG:{round(labels[i],3)} (V)")
# Adding title
fig.suptitle('Output Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
#save plot if checked
if params["SAMPLE"]['save_fig'] == True:
filename= os.path.splitext(file)[0]
fig.savefig(filename+'_Y1.png')
#add the second axis if applicable
if plot_list[2]!= "None":
fig,ax2=plt.subplots(figsize=(10,6),layout='constrained')
y2 = np.split(plot_values['Y2'],points)
if scale_list[2]=='LOG':
ax2.set_yscale('log')
ax2.set_xlabel(axes_labels[0])
ax2.set_ylabel(axes_labels[2])
for i in range(points):
ax2.plot(x[i],y2[i],label = f"VTG:{round(labels[i],3)} (V)")
# Adding title
fig.suptitle('Output Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
#save plot if checked
if params["SAMPLE"]['save_fig'] == True:
filename= os.path.splitext(file)[0]
fig.savefig(filename+'.png')
fig.savefig(filename+'Y2.png')
#Output VBG
def Output_VBG(device,params):
try:
device.setup_smu(params["MAP"]['TG'],params["SMU_T"])
device.setup_smu(params["MAP"]['D'],params["SMU_D"])
device.setup_smu(params["MAP"]['BG'],params["SMU_B"])
......@@ -663,7 +658,12 @@ def Output_VBG(device,params):
variables_list = ['VDS','ID','VBG','IBG']
device.variables_to_save(variables_list)
try:
plotted_variables = graph_tool(params,device)
except Exception as e:
error_box(e)
return
device.single_measurement()
......@@ -671,8 +671,13 @@ def Output_VBG(device,params):
pass
device.autoscaling()
device.error_occured()
values = dict([(variable,device.return_values(variable)) for variable in variables_list])
df = get_dataframe_from_results(values)
except Exception as e:
error_box(e)
return
# plot results
......@@ -684,71 +689,6 @@ def Output_VBG(device,params):
df["IDmm/uA/um"]= (df["ID/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
df["IBGmm/uA/um"]= (df["IBG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
#plotted variables as they are named in the tool
#return the plotted data for easier configuration
plotted_variables = {'X':device.get_axis_variable('X'),'Y1': device.get_axis_variable('Y1')}
if params["PLOT"]["y2"]!= "None":
plotted_variables['Y2']= device.get_axis_variable('Y2')
plot_values ={}
for axis,variable in plotted_variables.items():
plot_values.setdefault(axis,np.array(device.return_values(variable)))
# Plot user specified results
fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
scale_list = [params["PLOT"]["x_scale"],params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
axes_labels = []
if scale_list[0] == 'LOG':
ax1.set_xscale('log')
if scale_list[1]=='LOG':
ax1.set_yscale('log')
# define the axes labels similarly to the user functions
for element in plot_list:
if element != "None": #only the last one
if element.startswith("V"):
label = f"{element} (V)"
elif element.startswith('I') and element.endswith('mm'):
label = f"{element[:-2]} (uA/(um))"
else: # regular I
label = f"{element} (A)"
axes_labels.append(label)
#now set the labels
ax1.set_xlabel(axes_labels[0])
ax1.set_ylabel(axes_labels[1])
x = np.split(plot_values['X'],points)
y1 = np.split(plot_values['Y1'],points)
labels =np.mean(np.array_split(df["VBG/V"],points),axis = 1) # VDS values for labels
for i in range(points):
ax1.plot(x[i],y1[i],label = f"VBG:{round(labels[i],3)} (V)")
#add the second axis if applicable
if plot_list[2]!= "None":
ax2 = ax1.twinx()
y2 = np.split(plot_values['Y2'],points)
if scale_list[2]=='LOG':
ax1.set_yscale('log')
ax2.set_ylabel(axes_labels[2])
for i in range(points):
ax2.plot(x[i],y2[i])
# Adding title
fig.suptitle('Output Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
# Save the results
default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_BACK_GATE_A.txt"
......@@ -797,13 +737,67 @@ def Output_VBG(device,params):
f.write("\nResults\n")
df.to_csv(file,sep=" ",mode='a')
if params["SAMPLE"]["save_fig"] == True:
plot_values = values_to_plot(params,device)
# Plot user specified results
fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
scale_list =['LIN',params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
axes_labels = set_axes_labels(plot_list)
if scale_list[1]=='LOG':
ax1.set_yscale('log')
#now set the labels
ax1.set_xlabel(axes_labels[0])
ax1.set_ylabel(axes_labels[1])
x = np.split(plot_values['X'],points)
y1 = np.split(plot_values['Y1'],points)
labels =np.mean(np.array_split(df["VBG/V"],points),axis = 1) # VDS values for labels
for i in range(points):
ax1.plot(x[i],y1[i],label = f"VBG:{round(labels[i],3)} (V)")
# Adding title
fig.suptitle('Output Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
#save plot if checked
if params["SAMPLE"]['save_fig'] == True:
filename= os.path.splitext(file)[0]
fig.savefig(filename+'.png')
fig.savefig(filename+'_Y1.png')
#add the second axis if applicable
if plot_list[2]!= "None":
fig,ax2=plt.subplots(figsize=(10,6),layout='constrained')
y2 = np.split(plot_values['Y2'],points)
if scale_list[2]=='LOG':
ax2.set_yscale('log')
ax2.set_xlabel(axes_labels[0])
ax2.set_ylabel(axes_labels[2])
for i in range(points):
ax2.plot(x[i],y2[i],label = f"VBG:{round(labels[i],3)} (V)")
# Adding title
fig.suptitle('Output Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
#save plot if checked
if params["SAMPLE"]['save_fig'] == True:
filename= os.path.splitext(file)[0]
fig.savefig(filename+'Y2.png')
# Output both
def Output_BOTH(device,params):
try:
device.setup_smu(params["MAP"]['TG'],params["SMU_T"])
device.setup_smu(params["MAP"]['D'],params["SMU_D"])
device.setup_smu(params["MAP"]['BG'],params["SMU_B"])
......@@ -815,7 +809,12 @@ def Output_BOTH(device,params):
device.integration_time(params["INTEGRATION"])
try:
plotted_variables = graph_tool(params,device)
except Exception as e:
error_box(e)
return
variables_list = ['VDS','ID','VBG','IBG','VTG','ITG']
......@@ -834,9 +833,13 @@ def Output_BOTH(device,params):
while device.operation_completed()==False:
pass
device.autoscaling()
device.error_occured()
values = dict([(variable,device.return_values(variable)) for variable in variables_list])
df = get_dataframe_from_results(values)
except Exception as e:
error_box(e)
return
# plot results
points = params["VAR2"]['points']*params["VAR3"]["points"] # number of curves
......@@ -849,70 +852,6 @@ def Output_BOTH(device,params):
df["IBGmm/uA/um"]= (df["IBG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
df["ITGmm/uA/um"]= (df["ITG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
#plotted variables as they are named in the tool
#return the plotted data for easier configuration
plotted_variables = {'X':device.get_axis_variable('X'),'Y1': device.get_axis_variable('Y1')}
if params["PLOT"]["y2"]!= "None":
plotted_variables['Y2']= device.get_axis_variable('Y2')
plot_values ={}
for axis,variable in plotted_variables.items():
plot_values.setdefault(axis,np.array(device.return_values(variable)))
# Plot user specified results
fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
scale_list = [params["PLOT"]["x_scale"],params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
axes_labels = []
if scale_list[0] == 'LOG':
ax1.set_xscale('log')
if scale_list[1]=='LOG':
ax1.set_yscale('log')
# define the axes labels similarly to the user functions
for element in plot_list:
if element != "None": #only the last one
if element.startswith("V"):
label = f"{element} (V)"
elif element.startswith('I') and element.endswith('mm'):
label = f"{element[:-2]} (uA/(um))"
else: # regular I
label = f"{element} (A)"
axes_labels.append(label)
#now set the labels
ax1.set_xlabel(axes_labels[0])
ax1.set_ylabel(axes_labels[1])
x = np.split(plot_values['X'],points)
y1 = np.split(plot_values['Y1'],points)
labels_VBG =np.mean(np.array_split(df["VBG/V"],points),axis = 1) # VBG values for labels
labels_VTG = np.mean(np.array_split(df["VTG/V"],points),axis = 1)
for i in range(points):
ax1.plot(x[i],y1[i],label = f"VBG:{round(labels_VBG[i],3)} V , VTG:{round(labels_VTG[i],3)} V")
#add the second axis if applicable
if plot_list[2]!= "None":
ax2 = ax1.twinx()
y2 = np.split(plot_values['Y2'],points)
if scale_list[2]=='LOG':
ax1.set_yscale('log')
ax2.set_ylabel(axes_labels[2])
for i in range(points):
ax2.plot(x[i],y2[i])
# Adding title
fig.suptitle('Output Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
# Save the results
default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_BOTH_GATES_A.txt"
......@@ -967,11 +906,68 @@ def Output_BOTH(device,params):
f.write("\nResults\n")
df.to_csv(file,sep=" ",mode='a')
if params["SAMPLE"]["save_fig"] == True:
plot_values = values_to_plot(params,device)
# Plot user specified results
fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
scale_list =['LIN',params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
axes_labels = set_axes_labels(plot_list)
if scale_list[1]=='LOG':
ax1.set_yscale('log')
#now set the labels
ax1.set_xlabel(axes_labels[0])
ax1.set_ylabel(axes_labels[1])
x = np.split(plot_values['X'],points)
y1 = np.split(plot_values['Y1'],points)
labels_VTG =np.mean(np.array_split(df["VTG/V"],points),axis = 1) # VTG values for labels
labels_VBG = np.mean(np.array_split(df["VBG/V"],points),axis = 1) # VBG values for labels
for i in range(points):
ax1.plot(x[i],y1[i],label = f"VTG:{round(labels_VTG[i],3)} (V) , VBG:{round(labels_VBG[i],3)} (V)")
# Adding title
fig.suptitle('Output Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
#save plot if checked
if params["SAMPLE"]['save_fig'] == True:
filename= os.path.splitext(file)[0]
fig.savefig(filename+'.png')
fig.savefig(filename+'_Y1.png')
#add the second axis if applicable
if plot_list[2]!= "None":
fig,ax2=plt.subplots(figsize=(10,6),layout='constrained')
y2 = np.split(plot_values['Y2'],points)
if scale_list[2]=='LOG':
ax2.set_yscale('log')
ax2.set_xlabel(axes_labels[0])
ax2.set_ylabel(axes_labels[2])
for i in range(points):
ax2.plot(x[i],y2[i],label = f"VTG:{round(labels_VTG[i],3)} (V) , VBG:{round(labels_VBG[i],3)} (V)")
# Adding title
fig.suptitle('Output Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
#save plot if checked
if params["SAMPLE"]['save_fig'] == True:
filename= os.path.splitext(file)[0]
fig.savefig(filename+'_Y2.png')
def Gatediode_VTG(device,params):
try:
device.setup_smu(params["MAP"]['TG'],params["SMU_T"])
device.smu_disable(params["MAP"]['BG'])
device.setup_smu(params["MAP"]['S'],params["SMU_S"])
......@@ -982,16 +978,25 @@ def Gatediode_VTG(device,params):
variables_list = ['VTG','ITG']
device.variables_to_save(variables_list)
try:
plotted_variables = graph_tool(params,device)
except Exception as e:
error_box(e)
return
device.single_measurement()
while device.operation_completed()==False:
pass
device.autoscaling()
device.error_occured()
values = dict([(variable,device.return_values(variable)) for variable in variables_list])
df = get_dataframe_from_results(values)
except Exception as e:
error_box(e)
return
# calculate normalization factor
norm = normalization_factor(params['SAMPLE']["width"])
......@@ -999,67 +1004,6 @@ def Gatediode_VTG(device,params):
# Append the normalized current
df["ITGmm/uA/um"]= (df["ITG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
#plotted variables as they are named in the tool
#return the plotted data for easier configuration
plotted_variables = {'X':device.get_axis_variable('X'),'Y1': device.get_axis_variable('Y1')}
if params["PLOT"]["y2"]!= "None":
plotted_variables['Y2']= device.get_axis_variable('Y2')
plot_values ={}
for axis,variable in plotted_variables.items():
plot_values.setdefault(axis,device.return_values(variable))
# Plot user specified results
fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
scale_list = [params["PLOT"]["x_scale"],params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
axes_labels = []
if scale_list[0] == 'LOG':
ax1.set_xscale('log')
if scale_list[1]=='LOG':
ax1.set_yscale('log')
# define the axes labels similarly to the user functions
for element in plot_list:
if element != "None": #only the last one
if element.startswith("V"):
label = f"{element} (V)"
elif element.startswith('I') and element.endswith('mm'):
label = f"{element[:-2]} (uA/(um))"
else: # regular I
label = f"{element} (A)"
axes_labels.append(label)
#now set the labels
ax1.set_xlabel(axes_labels[0])
ax1.set_ylabel(axes_labels[1])
x = plot_values['X']
y1 = plot_values['Y1']
ax1.plot(x,y1)
#add the second axis if applicable
if plot_list[2]!= "None":
ax2 = ax1.twinx()
y2 = plot_values['Y2']
if scale_list[2]=='LOG':
ax1.set_yscale('log')
ax2.set_ylabel(axes_labels[2])
ax2.plot(x,y2)
# Adding title
fig.suptitle('Gatediode Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
# Save the results
default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_TOP_GATE_D.txt"
......@@ -1103,11 +1047,59 @@ def Gatediode_VTG(device,params):
f.write("\nResults\n")
df.to_csv(file,sep=" ",mode='a')
plot_values = values_to_plot(params,device)
# Plot user specified results
fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
scale_list =['LIN',params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
axes_labels =set_axes_labels(plot_list)
if scale_list[1]=='LOG':
ax1.set_yscale('log')
#now set the labels
ax1.set_xlabel(axes_labels[0])
ax1.set_ylabel(axes_labels[1])
x = plot_values['X']
y1 = plot_values['Y1']
ax1.plot(x,y1)
fig.suptitle('Gatediode Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
if params["SAMPLE"]["save_fig"] == True:
filename= os.path.splitext(file)[0]
fig.savefig(filename+'.png')
fig.savefig(filename+'_Y1.png')
#add the second axis if applicable
if plot_list[2]!= "None":
fig,ax2=plt.subplots(figsize=(10,6),layout='constrained')
y2 = plot_values['Y2']
if scale_list[2]=='LOG':
ax2.set_yscale('log')
ax2.set_xlabel(axes_labels[0])
ax2.set_ylabel(axes_labels[2])
ax2.plot(x,y2)
fig.suptitle('Gatediode Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
if params["SAMPLE"]["save_fig"] == True:
filename= os.path.splitext(file)[0]
fig.savefig(filename+'_Y2.png')
def Gatediode_VBG(device,params):
try:
device.setup_smu(params["MAP"]['BG'],params["SMU_B"])
device.smu_disable(params["MAP"]['TG'])
device.setup_smu(params["MAP"]['S'],params["SMU_S"])
......@@ -1119,17 +1111,25 @@ def Gatediode_VBG(device,params):
variables_list = ['VBG','IBG']
device.variables_to_save(variables_list)
try:
plotted_variables = graph_tool(params,device)
except Exception as e:
error_box(e)
return
device.single_measurement()
while device.operation_completed()==False:
pass
device.autoscaling()
device.error_occured()
values = dict([(variable,device.return_values(variable)) for variable in variables_list])
df = get_dataframe_from_results(values)
except Exception as e:
error_box(e)
return
# plot results
......@@ -1139,68 +1139,6 @@ def Gatediode_VBG(device,params):
# Append the normalized current
df["IBGmm/uA/um"]= (df["IBG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float')
#plotted variables as they are named in the tool
#return the plotted data for easier configuration
plotted_variables = {'X':device.get_axis_variable('X'),'Y1': device.get_axis_variable('Y1')}
if params["PLOT"]["y2"]!= "None":
plotted_variables['Y2']= device.get_axis_variable('Y2')
plot_values ={}
for axis,variable in plotted_variables.items():
plot_values.setdefault(axis,device.return_values(variable))
# Plot user specified results
fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
scale_list = [params["PLOT"]["x_scale"],params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
axes_labels = []
if scale_list[0] == 'LOG':
ax1.set_xscale('log')
if scale_list[1]=='LOG':
ax1.set_yscale('log')
# define the axes labels similarly to the user functions
for element in plot_list:
if element != "None": #only the last one
if element.startswith("V"):
label = f"{element} (V)"
elif element.startswith('I') and element.endswith('mm'):
label = f"{element[:-2]} (uA/(um))"
else: # regular I
label = f"{element} (A)"
axes_labels.append(label)
#now set the labels
ax1.set_xlabel(axes_labels[0])
ax1.set_ylabel(axes_labels[1])
x = plot_values['X']
y1 = plot_values['Y1']
ax1.plot(x,y1)
#add the second axis if applicable
if plot_list[2]!= "None":
ax2 = ax1.twinx()
y2 = plot_values['Y2']
if scale_list[2]=='LOG':
ax1.set_yscale('log')
ax2.set_ylabel(axes_labels[2])
ax2.plot(x,y2)
# Adding title
fig.suptitle('Gatediode Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
# Save the results
default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_BACK_GATE_D.txt"
......@@ -1244,6 +1182,52 @@ def Gatediode_VBG(device,params):
f.write("\nResults\n")
df.to_csv(file,sep=" ",mode='a')
plot_values = values_to_plot(params,device)
# Plot user specified results
fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
scale_list =['LIN',params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]]
axes_labels =set_axes_labels(plot_list)
if scale_list[1]=='LOG':
ax1.set_yscale('log')
#now set the labels
ax1.set_xlabel(axes_labels[0])
ax1.set_ylabel(axes_labels[1])
x = plot_values['X']
y1 = plot_values['Y1']
ax1.plot(x,y1)
fig.suptitle('Gatediode Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
if params["SAMPLE"]["save_fig"] == True:
filename= os.path.splitext(file)[0]
fig.savefig(filename+'_Y1.png')
#add the second axis if applicable
if plot_list[2]!= "None":
fig,ax2=plt.subplots(figsize=(10,6),layout='constrained')
y2 = plot_values['Y2']
if scale_list[2]=='LOG':
ax2.set_yscale('log')
ax2.set_xlabel(axes_labels[0])
ax2.set_ylabel(axes_labels[2])
ax2.plot(x,y2)
fig.suptitle('Gatediode Curve', fontweight ="bold")
fig.legend(loc='outside right upper')
display(fig)
if params["SAMPLE"]["save_fig"] == True:
filename= os.path.splitext(file)[0]
fig.savefig(filename+'.png')
\ No newline at end of file
fig.savefig(filename+'_Y2.png')
\ No newline at end of file
......@@ -45,7 +45,20 @@ class HP4155a(object):
self.inst.write(":PAGE:STR")
def error(self):
return self.inst.query(":SYST:ERR?")
error = self.inst.query(":SYST:ERR?")
error_code = int(error.split(',',1)[0])
error_message = error.split(',',1)[1]
return error_code,error_message
def error_occured(self):
code,message = self.error()
if code != 0:
raise Exception(message)
def clear_error_stack(self):
code,_ = self.error()
while code != 0:
code,_ = self.error()
def operation_completed(self):
text = self.inst.query('*OPC?')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment