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

plot configurations can be sent to the tool- sync is hard

parent b62e4e72
Branches
No related tags found
No related merge requests found
......@@ -8,7 +8,6 @@ from help import *
from measurements import *
import configparser
# Create the grids
#create the information grid
style = {'description_width': 'initial'}
......@@ -53,11 +52,9 @@ Vg_gatediode_widgets,Vg_gatediode=primary('VG',-5,0.05,5,1e-3)
plot_gatediode_widgets,plot_gatediode = plot_config(3)
gatediode_box = widgets.VBox([integration_gatediode,terminal,Vg_gatediode_widgets,plot_gatediode_widgets])
#replot
replot_widgets,replot= replot("Replot from file")
#the tab widget
children = [transfer_box,output_box,gatediode_box,replot_widgets]
titles = ["Transfer","Output","Gatediode","Replot"]
children = [transfer_box,output_box,gatediode_box]
titles = ["Transfer","Output","Gatediode"]
tab = widgets.Tab()
tab.children = children
tab.titles = titles
......@@ -69,7 +66,6 @@ output = widgets.Output()
export_ini_button = widgets.Button(description = 'Export as ini')
import_ini_button = widgets.Button(description='Import from ini')
replot_button = widgets.Button(description = 'Replot',disabled = True)
all_widgets =[transfer_gates,output_gates,button,transfer_check,integration_transfer,output_check,integration_output,gatediode_check,integration_gatediode,terminal,export_ini_button,import_ini_button]
......@@ -83,7 +79,7 @@ add_widgets_to_list(Vtg_output,all_widgets)
add_widgets_to_list(Vbg_output,all_widgets)
add_widgets_to_list(Vg_gatediode,all_widgets)
line = widgets.HBox([button,import_ini_button,export_ini_button,replot_button])
line = widgets.HBox([button,import_ini_button,export_ini_button])
display(line,output)
device = hp4155a.HP4155a('GPIB0::17::INSTR')
......@@ -91,7 +87,6 @@ device = hp4155a.HP4155a('GPIB0::17::INSTR')
def on_start_clicked(b):
with output:
clear_output()
replot_button.disabled = True
#disable all widgets
disable_widgets(all_widgets)
......@@ -456,7 +451,6 @@ def on_start_clicked(b):
information_box("Measurement finished!")
enable_widgets(all_widgets)
replot_button.disabled = False
def on_export_ini_clicked(b):
......@@ -570,31 +564,11 @@ def on_import_ini_clicked(b):
information_box(f"A {type(error).__name__} has occurred. Create A new ini file")
enable_widgets(all_widgets)
def on_replot_button_clicked(b):
with output:
global df_transfer,df_output,df_gatediode,points_transfer,points_output
clear_output()
disable_widgets(all_widgets)
replot_button.disabled = True
# plot transfer
replot_results(replot_transfer,df_transfer,points_transfer,'Transfer Results')
#plot output
replot_results(replot_output,df_output,points_output,'Output Results')
# plot gatediode
replot_results(replot_gatediode,df_gatediode,1,'Gatediode Results')
enable_widgets(all_widgets)
replot_button.disabled = False
button.on_click(on_start_clicked)
import_ini_button.on_click(on_import_ini_clicked)
export_ini_button.on_click(on_export_ini_clicked)
replot_button.on_click(on_replot_button_clicked)
......
......@@ -180,49 +180,6 @@ def calculate_line(VTG,VBG):
return ratio,offset
# replot results
def replot_results(replot_dict,df,points,title):
try:
if len(df.columns.tolist())!=0 and replot_dict['check'].value==True: # Measurement is done
fig,ax = plt.subplots(figsize=(10,6))
#Retrieve the columns
x_col = replot_dict['x_variable'].value
y_col = replot_dict['y_variable'].value
#Scale and Absolute Values
if replot_dict['x_scale'].value=='linear':
x = np.array_split(df[x_col],points)
else:
x = np.array_split(df[x_col].abs(),points)
ax.set_xscale('log')
if replot_dict['y_scale'].value=='linear':
y = np.array_split(df[y_col],points)
else:
y = np.array_split(df[y_col].abs(),points)
ax.set_yscale('log')
# check auto limits
if replot_dict['x_auto'].value== False and replot_dict['x_max'].value > replot_dict['x_min'].value:
ax.set_xlim([replot_dict['x_min'].value,replot_dict['x_max'].value])
if replot_dict['y_auto'].value== False and replot_dict['y_max'].value > replot_dict['y_min'].value:
ax.set_ylim([replot_dict['y_min'].value,replot_dict['y_max'].value])
# Now set the label
ax.set_xlabel(x_col)
ax.set_ylabel(y_col)
#And Plot
for i in range(points):
ax.plot(x[i],y[i])
fig.suptitle(title, fontweight ="bold")
fig.show() # Do this interactively to save the figures
except:
information_box("reploting failed please try again")
#check if smu configuration has a double value
def check_configuration(smu_map:dict):
......@@ -266,26 +223,108 @@ def graph_tool(params):
# How to define user functions correctly and not multiple times
plot_list = [params["PLOT"]["x"],params["PLOT"]["y1"],params["PLOT"]["y2"]]
plot_set= set(plot_list)
#define the no values
for element in plot_set:
if element.endswith("mm"):
if element.endswith("mm"): #only I values
#define the respective user function
device.user_function(element,"mA/mm",f"{element[:-2]}*{normalization_factor(params['SAMPLE']["width"])}") #max 3
#define the absolute(A to indicate absolute) always 3 (max 6!)
if element.startswith("V"):
device.user_function('A'+element,"V",f"ABS({element})")
elif element.startswith('I') and element.endswith('mm'):
device.user_function('A'+element,"mA/mm",f"ABS({element})")
else: # regular I
device.user_function('A'+element,"A",f"ABS({element})")
if params["PLOT"]["x"]!= None:
# Now send the parameters in the tool
if params["PLOT"]["x_scale"]=='LOG':
device.display_variable('X',"A"+params["PLOT"]["x"])
else:
device.display_variable('X',params["PLOT"]["x"])
device.axis_scale('X',params["PLOT"]["x_scale"])
device.display_variable_min_max('X','MIN',params["PLOT"]["x_min"])
device.display_variable_min_max('X','MAX',params["PLOT"]["x_max"])
if params["PLOT"]["y1"]!= None:
if params["PLOT"]["y1_scale"]=='LOG':
device.display_variable('Y1',"A"+params["PLOT"]["y1"])
else:
device.display_variable('Y1',params["PLOT"]["y1"])
device.axis_scale('Y1',params["PLOT"]["y1_scale"])
device.display_variable_min_max('Y1','MIN',params["PLOT"]["y1_min"])
device.display_variable_min_max('Y1','MAX',params["PLOT"]["y1_max"])
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.axis_scale('X',params["PLOT"]["y2_scale"])
device.display_variable_min_max('X','MIN',params["PLOT"]["y2_min"])
device.display_variable_min_max('X','MAX',params["PLOT"]["y2_max"])
device.axis_scale('Y2',params["PLOT"]["y2_scale"])
device.display_variable_min_max('Y2','MIN',params["PLOT"]["y2_min"])
device.display_variable_min_max('Y2','MAX',params["PLOT"]["y2_max"])
check_error(device)
#Send the the graph from the tool in the software
def graph_software(params,meas):
#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_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 = []
fig,ax1= plt.subplots(figsize=(10,6),layout='constrained')
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])
#plot scatter
ax1.scatter(plot_values["X"],plot_values["Y1"],color ='y')
#add the second axis if applicable
if plot_list[2]! = None:
ax2 = ax1.twinx()
if scale_list[2]=='LOG':
ax1.set_yscale('log')
ax2.set_ylabel(axes_labels[2])
ax2.scatter(plot_values["X"],plot_values["Y2 "],color ='b')
\ No newline at end of file
......@@ -239,66 +239,6 @@ def additional_secondary(name,start,step,stop,comp):
}
return secondary_grid,parameters
def replot(title):
replot_grid = GridspecLayout(7,2)
replot_grid[0,0]= widgets.Label(
title,
style = style,
)
replot_grid[1,0] = widgets.Label('X-axis',layout=Layout(height='auto', width='auto'))
replot_grid[1,1] = widgets.Label('Y-axis',layout=Layout(height='auto', width='auto'))
for i in range(2):
replot_grid[2,i]= widgets.Dropdown(
options = [],
description = "Variable:",
layout=Layout(height='auto', width=floatbox_width),
)
replot_grid[3,i] = widgets.FloatText(
value = None,
description = 'min:',
layout=Layout(height='auto', width=floatbox_width),
)
replot_grid[4,i] = widgets.FloatText(
value = None,
description = 'max:',
layout=Layout(height='auto', width=floatbox_width),
)
replot_grid[5,i] = widgets.Dropdown(
description = 'scale:',
options =['linear','log'],
value = 'linear',
layout=Layout(height='auto', width=floatbox_width),
)
replot_grid[6,i]= widgets.Checkbox(
description = "Autolimits",
value = True,
style = style,
)
replot_dict ={
'x_variable':replot_grid[2,0],
'x_min':replot_grid[3,0],
'x_max':replot_grid[4,0],
'x_scale':replot_grid[5,0],
'x_auto':replot_grid[6,0],
'y_variable': replot_grid[2,1],
'y_min':replot_grid[3,1],
'y_max':replot_grid[4,1],
'y_scale':replot_grid[5,1],
'y_auto':replot_grid[6,1],
'button': replot_grid[0,0]
}
return replot_grid, replot_dict
def plot_config(meas): #meas = 1,2,3 for transfer,output,gatediode
config_grid = GridspecLayout(6,4)
......@@ -353,8 +293,9 @@ def plot_config(meas): #meas = 1,2,3 for transfer,output,gatediode
config_grid[5,0] = widgets.Label('MAX',layout=Layout(height='auto', width='auto'))
#iterate through the second line (NAME)
config_grid[2,1]=widgets.Dropdown(layout=Layout(height='auto', width='auto'),options = options,value = x_name)
config_grid[2,2]=widgets.Dropdown(layout=Layout(height='auto', width='auto'),options = options,value = y1_name)
must_options = [x for x in options if x is not None]
config_grid[2,1]=widgets.Dropdown(layout=Layout(height='auto', width='auto'),options = must_options,value = x_name)
config_grid[2,2]=widgets.Dropdown(layout=Layout(height='auto', width='auto'),options = must_options,value = y1_name)
config_grid[2,3]=widgets.Dropdown(layout=Layout(height='auto', width='auto'),options = options,value = None)
#Iterate through the third line (scale)
......
......@@ -37,11 +37,11 @@ def Transfer_VTG(device,params):
device.integration_time(params["INTEGRATION"])
variables_list =["VTG","ITG","VDS","ID"]
device.variables_to_save(variables_list)
plotted_variables = graph_tool(params)
device.single_measurement()
while device.operation_completed()==False:
pass
......
%% Cell type:code id:81f37cac-ea14-4540-8bc9-78bee248dfbb tags:
``` python
import sys
sys.path.insert(0, './lib')
sys.path.insert(0, '..') #append parent directory
from interface import *
from help import *
```
%% Cell type:code id:731635ba-6f97-4a65-ad78-ae90b277544b tags:
``` python
# Create the grids
#create the information grid
style = {'description_width': 'initial'}
sample,smu_map = information_box_new()
###end of sampling information#######################################
# move checkboxes outside of the tabs
transfer_check,integration_transfer,transfer_gates = header('Transfer Curve',"MEDium")
output_check,integration_output,output_gates = header('Output Curve',"SHORt")
gatediode_check,integration_gatediode,_=header('Gatediode',"MEDium")
checkboxes = widgets.HBox([transfer_check,output_check,gatediode_check])
display(checkboxes)
#transfer
Vds_transfer_widgets,Vds_transfer = secondary('VDS',0.05,0.95,1,1e-2)
Vtg_transfer_widgets,Vtg_transfer = primary('VTG',-5,0.01,5,1e-3)
Vbg_transfer_widgets,Vbg_transfer = synchronous('VBG',-15,0.1,15,1e-3)
plot_transfer_widgets,plot_transfer = plot_config(1)
transfer_box = widgets.VBox([integration_transfer,transfer_gates,Vds_transfer_widgets,Vtg_transfer_widgets,Vbg_transfer_widgets,plot_transfer_widgets])
#output
Vds_output_widgets,Vds_output = primary('VDS',0,0.01,5,1e-2)
Vtg_output_widgets,Vtg_output = secondary('VTG',-5,2,5,1e-3)
Vbg_output_widgets,Vbg_output = additional_secondary('VBG',-15,5,15,1e-3)
plot_output_widgets,plot_output = plot_config(2)
output_box = widgets.VBox([integration_output,output_gates,Vds_output_widgets,Vtg_output_widgets,Vbg_output_widgets,plot_output_widgets])
#GateDiodde
terminal = widgets.Dropdown(
options = ['VTG','VBG'],
description = 'Selected Gate:',
value ='VTG',
style= {'description_width': 'initial'}
)
Vg_gatediode_widgets,Vg_gatediode=primary('VG',-5,0.05,5,1e-3)
plot_gatediode_widgets,plot_gatediode = plot_config(3)
gatediode_box = widgets.VBox([integration_gatediode,terminal,Vg_gatediode_widgets,plot_gatediode_widgets])
#replot
replot_transfer_widgets,replot_transfer= replot("Transfer")
#the tab widget
children = [transfer_box,output_box,gatediode_box,replot_transfer_widgets]
titles = ["Transfer","Output","Gatediode","Replot"]
children = [transfer_box,output_box,gatediode_box]
titles = ["Transfer","Output","Gatediode"]
tab = widgets.Tab()
tab.children = children
tab.titles = titles
display(tab)
button = widgets.Button(description ='Start Measurement')
output = widgets.Output()
export_ini_button = widgets.Button(description = 'Export as ini')
import_ini_button = widgets.Button(description='Import from ini')
replot_button = widgets.Button(description = 'Replot',disabled = True)
all_widgets =[transfer_gates,output_gates,button,transfer_check,integration_transfer,output_check,integration_output,gatediode_check,integration_gatediode,terminal,export_ini_button,import_ini_button]
add_widgets_to_list(sample,all_widgets)
add_widgets_to_list(smu_map,all_widgets)
add_widgets_to_list(Vds_transfer,all_widgets)
add_widgets_to_list(Vtg_transfer,all_widgets)
add_widgets_to_list(Vbg_transfer,all_widgets)
add_widgets_to_list(Vds_output,all_widgets)
add_widgets_to_list(Vtg_output,all_widgets)
add_widgets_to_list(Vbg_output,all_widgets)
add_widgets_to_list(Vg_gatediode,all_widgets)
line = widgets.HBox([button,import_ini_button,export_ini_button,replot_button])
line = widgets.HBox([button,import_ini_button,export_ini_button])
display(line,output)
```
%% Output
%% Cell type:code id:eee00bdc-55e5-466c-89e9-b5836087b1ed tags:
%% Cell type:code id:9f36a6dc-eb0b-4fef-ac27-b6e3a074ec44 tags:
``` python
```
......
......@@ -162,6 +162,10 @@ class HP4155a(object):
command = f":PAGE:DISP:GRAP:{axis}:{extremum} {value}"
self.inst.write(command)
def get_axis_variable(axis):
command = f":PAGE:DISP:GRAP:{axis}:NAME?"
return self.inst.query(command)
def autoscaling(self):
self.inst.write(":PAGE:GLIS:SCAL:AUTO ONCE")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment