From 2d5d4c1c5b6b92e65f4726585ecd3e8b37f40117 Mon Sep 17 00:00:00 2001 From: unknown <asoalexandros@gmail.com> Date: Mon, 21 Oct 2024 13:00:12 +0200 Subject: [PATCH] debugging part 3 software plots work --- .../double_gate_ADU_interface.ipynb | 12 +- .../lib/help.py | 53 +- .../lib/measurements.py | 1238 ++++++++--------- hp4155/hp4155a.py | 15 +- 4 files changed, 682 insertions(+), 636 deletions(-) diff --git a/hp4155/ADU for double gate devices-test/double_gate_ADU_interface.ipynb b/hp4155/ADU for double gate devices-test/double_gate_ADU_interface.ipynb index faa3625..22cd01e 100644 --- a/hp4155/ADU for double gate devices-test/double_gate_ADU_interface.ipynb +++ b/hp4155/ADU for double gate devices-test/double_gate_ADU_interface.ipynb @@ -9,7 +9,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "3cf0faebf88c45f49e903b375a7612b4", + "model_id": "9700a16182f3422a84b473ab09c2baff", "version_major": 2, "version_minor": 0 }, @@ -23,7 +23,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "e0c490c25be140d78098258f89fe2c7c", + "model_id": "350565f5a66047899593abab5701193e", "version_major": 2, "version_minor": 0 }, @@ -37,7 +37,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "c2beee9304734535a652146df18f2fb1", + "model_id": "e493c1fbe9174d9fa4e053e02fb8a0e1", "version_major": 2, "version_minor": 0 }, @@ -51,7 +51,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "17d7289741454a9f9f701f7b47ac38ce", + "model_id": "bb7847e53b864cbd9f4086ca613e5d13", "version_major": 2, "version_minor": 0 }, @@ -65,7 +65,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "55e13e645e6e429dade45a3f97226e0b", + "model_id": "40bc192190b5448caded4711d9d5e267", "version_major": 2, "version_minor": 0 }, @@ -84,7 +84,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1a0e956e-9d25-481e-b1ec-b03babcb4c19", + "id": "40d5f341-bc61-4698-8bdd-f99e94f4e325", "metadata": {}, "outputs": [], "source": [] diff --git a/hp4155/ADU for double gate devices-test/lib/help.py b/hp4155/ADU for double gate devices-test/lib/help.py index 0723fd3..265b43f 100644 --- a/hp4155/ADU for double gate devices-test/lib/help.py +++ b/hp4155/ADU for double gate devices-test/lib/help.py @@ -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 + + + + + diff --git a/hp4155/ADU for double gate devices-test/lib/measurements.py b/hp4155/ADU for double gate devices-test/lib/measurements.py index 214ebdc..b32e486 100644 --- a/hp4155/ADU for double gate devices-test/lib/measurements.py +++ b/hp4155/ADU for double gate devices-test/lib/measurements.py @@ -26,99 +26,44 @@ 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"]) + device.setup_smu(params["MAP"]['S'],params["SMU_S"]) - 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"]) - - device.setup_var1(params["VAR1"]) - device.setup_var2(params["VAR2"]) - - device.integration_time(params["INTEGRATION"]) - - variables_list =["VTG","ITG","VDS","ID"] - device.variables_to_save(variables_list) - - plotted_variables = graph_tool(params,device) - - device.single_measurement() - while device.operation_completed()==False: - pass - - device.autoscaling() - - values = dict([(variable,device.return_values(variable)) for variable in variables_list]) - df = get_dataframe_from_results(values) + device.setup_var1(params["VAR1"]) + device.setup_var2(params["VAR2"]) + + device.integration_time(params["INTEGRATION"]) + + 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,81 +111,18 @@ def Transfer_VTG(device,params): df.to_csv(file,sep=" ",mode='a') - #save plot if checked - if params["SAMPLE"]['save_fig'] == True: - filename= os.path.splitext(file)[0] - fig.savefig(filename+'.png') - -# Transfer only VBG -def Transfer_VBG(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"]) - - - device.setup_var1(params["VAR1"]) - device.setup_var2(params["VAR2"]) - - device.integration_time(params["INTEGRATION"]) - - - variables_list =["VBG","IBG","VDS","ID"] - device.variables_to_save(variables_list) - - plotted_variables = graph_tool(params,device) - - device.single_measurement() - while device.operation_completed()==False: - pass - device.autoscaling() - - values = dict([(variable,device.return_values(variable)) for variable in variables_list]) - df = get_dataframe_from_results(values) - - # calculate normalization factor - norm = normalization_factor(params["SAMPLE"]["width"]) - points = params["VAR2"]["points"] - - # Append the normalized current - 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 = values_to_plot(params,device) - 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') + 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') - # 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]) @@ -251,26 +133,86 @@ def Transfer_VBG(device,params): 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": - ax2 = ax1.twinx() + fig,ax2=plt.subplots(figsize=(10,6),layout='constrained') y2 = np.split(plot_values['Y2'],points) if scale_list[2]=='LOG': - ax1.set_yscale('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]) + 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+'_Y2.png') - # Adding title - fig.suptitle('Transfer Curve', fontweight ="bold") - fig.legend(loc='outside right upper') - display(fig) +# 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"]) + device.setup_smu(params["MAP"]['S'],params["SMU_S"]) + + + device.setup_var1(params["VAR1"]) + device.setup_var2(params["VAR2"]) + + device.integration_time(params["INTEGRATION"]) + + + 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"] - # Save the results + # Append the normalized current + 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') + + # Save the results default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_BACK_GATE_U.txt" root = tk.Tk() @@ -321,88 +263,18 @@ def Transfer_VBG(device,params): df.to_csv(file,sep=" ",mode='a') - if params["SAMPLE"]["save_fig"] == True: - filename= os.path.splitext(file)[0] - fig.savefig(filename+'.png') - -def Transfer_BOTH(device,params): - smu_t = device.smu_dict() - smu_t.update(vname = 'VTG',iname='ITG',mode = 'V',func='VAR1') - - smu_b = device.smu_dict() - smu_b.update(vname = 'VBG',iname='IBG',mode = 'V',func = 'VARD') - - 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"]) - - - device.setup_var1(params["VAR1"]) - device.setup_var2(params["VAR2"]) - device.setup_vard(params["VARD"]) - - device.integration_time(params["INTEGRATION"]) - - variables_list =["VBG","IBG","VDS","ID","VTG","ITG"] - device.variables_to_save(variables_list) - - plotted_variables = graph_tool(params,device) - - device.single_measurement() - while device.operation_completed()==False: - pass - - device.autoscaling() - - values = dict([(variable,device.return_values(variable)) for variable in variables_list]) - df = get_dataframe_from_results(values) - - # calculate normalization factor - norm = normalization_factor(params["SAMPLE"]["width"]) - points = params["VAR2"]["points"] - - # Append the normalized current - 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') - 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 = values_to_plot(params,device) - 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') + 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') - # 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]) @@ -413,24 +285,94 @@ def Transfer_BOTH(device,params): 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": - ax2 = ax1.twinx() + fig,ax2=plt.subplots(figsize=(10,6),layout='constrained') y2 = np.split(plot_values['Y2'],points) if scale_list[2]=='LOG': - ax1.set_yscale('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]) + 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+'_Y2.png') - # Adding title - fig.suptitle('Transfer Curve', fontweight ="bold") - fig.legend(loc='outside right upper') + +def Transfer_BOTH(device,params): + try: + smu_t = device.smu_dict() + smu_t.update(vname = 'VTG',iname='ITG',mode = 'V',func='VAR1') + + smu_b = device.smu_dict() + smu_b.update(vname = 'VBG',iname='IBG',mode = 'V',func = 'VARD') + + 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"]) + + + device.setup_var1(params["VAR1"]) + device.setup_var2(params["VAR2"]) + device.setup_vard(params["VARD"]) + + device.integration_time(params["INTEGRATION"]) + + 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"]) + points = params["VAR2"]["points"] + + # Append the normalized current + 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') + df["ITGmm/uA/um"]= (df["ITG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float') - 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') - -# 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"]) - - device.setup_var1(params["VAR1"]) - device.setup_var2(params["VAR2"]) - - device.integration_time(params["INTEGRATION"]) - - variables_list = ['VDS','ID','VTG','ITG'] - device.variables_to_save(variables_list) - - plotted_variables = graph_tool(params,device) - - device.single_measurement() - - while device.operation_completed()==False: - pass - - device.autoscaling() + plot_values = values_to_plot(params,device) - 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"] - - # 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') + 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') - # 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["VTG/V"],points),axis = 1) # VDS values for labels + 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"VTG:{round(labels[i],3)} (V)") + 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": - ax2 = ax1.twinx() + fig,ax2=plt.subplots(figsize=(10,6),layout='constrained') y2 = np.split(plot_values['Y2'],points) if scale_list[2]=='LOG': - ax1.set_yscale('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]) + 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+'Y2.png') - # Adding title - fig.suptitle('Output Curve', fontweight ="bold") - fig.legend(loc='outside right upper') +# 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"]) + + device.setup_var1(params["VAR1"]) + device.setup_var2(params["VAR2"]) + + device.integration_time(params["INTEGRATION"]) + + variables_list = ['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 - display(fig) - #save Results + # plot results + # calculate normalization factor + norm = normalization_factor(params['SAMPLE']["width"]) + points = params["VAR2"]["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') + # Save the results default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_TOP_GATE_A.txt" @@ -643,112 +582,113 @@ def Output_VTG(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') - -#Output VBG -def Output_VBG(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"]) - - - device.setup_var1(params["VAR1"]) - device.setup_var2(params["VAR2"]) - - device.integration_time(params["INTEGRATION"]) - - variables_list = ['VDS','ID','VBG','IBG'] - device.variables_to_save(variables_list) - - plotted_variables = graph_tool(params,device) - - device.single_measurement() - - while device.operation_completed()==False: - pass - - device.autoscaling() - 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"] - - # Append the normalized current - 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') + plot_values = 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))) - # 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') + 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') - # 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 + 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"VBG:{round(labels[i],3)} (V)") + 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": - ax2 = ax1.twinx() + fig,ax2=plt.subplots(figsize=(10,6),layout='constrained') 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]) + 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+'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"]) + device.setup_smu(params["MAP"]['S'],params["SMU_S"]) + + + device.setup_var1(params["VAR1"]) + device.setup_var2(params["VAR2"]) + + device.integration_time(params["INTEGRATION"]) + + 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() + + 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 - # 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"] + + # Append the normalized current + 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') - display(fig) - # Save the results default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_BACK_GATE_A.txt" @@ -797,123 +737,122 @@ def Output_VBG(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') - -# Output both -def Output_BOTH(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"]) - - - device.setup_var1(params["VAR1"]) - device.setup_var2(params["VAR2"]) - - - device.integration_time(params["INTEGRATION"]) - plotted_variables = graph_tool(params,device) - - - variables_list = ['VDS','ID','VBG','IBG','VTG','ITG'] - device.variables_to_save(variables_list) - for i , value in enumerate(params["VAR3"]['values']): - cons = device.cons_smu_dict() - cons.update(comp = params['VAR3']['comp'],value = value) - device.setup_cons_smu(params['MAP']['BG'],cons) + plot_values = values_to_plot(params,device) - if i == 0: - device.single_measurement() - else: - device.append_measurement() - - while device.operation_completed()==False: - pass - device.autoscaling() - - values = dict([(variable,device.return_values(variable)) for variable in variables_list]) - df = get_dataframe_from_results(values) - - # plot results - points = params["VAR2"]['points']*params["VAR3"]["points"] # number of curves - - # calculate normalization factor - norm = normalization_factor(params["SAMPLE"]["width"]) - - # Append the normalized current - 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') - 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') + 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') - # 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) + 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_VBG[i],3)} V , VTG:{round(labels_VTG[i],3)} V") + 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+'_Y1.png') + #add the second axis if applicable if plot_list[2]!= "None": - ax2 = ax1.twinx() + fig,ax2=plt.subplots(figsize=(10,6),layout='constrained') y2 = np.split(plot_values['Y2'],points) if scale_list[2]=='LOG': - ax1.set_yscale('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]) + 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"]) + device.setup_smu(params["MAP"]['S'],params["SMU_S"]) + + + device.setup_var1(params["VAR1"]) + device.setup_var2(params["VAR2"]) + + + 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'] + device.variables_to_save(variables_list) + + for i , value in enumerate(params["VAR3"]['values']): + cons = device.cons_smu_dict() + cons.update(comp = params['VAR3']['comp'],value = value) + device.setup_cons_smu(params['MAP']['BG'],cons) + + if i == 0: + device.single_measurement() + else: + device.append_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 - # Adding title - fig.suptitle('Output Curve', fontweight ="bold") - fig.legend(loc='outside right upper') + # plot results + points = params["VAR2"]['points']*params["VAR3"]["points"] # number of curves - display(fig) - # Save the results + # calculate normalization factor + norm = normalization_factor(params["SAMPLE"]["width"]) + + # Append the normalized current + 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') + df["ITGmm/uA/um"]= (df["ITG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float') + + # Save the results default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_BOTH_GATES_A.txt" root = tk.Tk() @@ -967,100 +906,105 @@ def Output_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') - -def Gatediode_VTG(device,params): - device.setup_smu(params["MAP"]['TG'],params["SMU_T"]) - device.smu_disable(params["MAP"]['BG']) - device.setup_smu(params["MAP"]['S'],params["SMU_S"]) - - device.setup_var1(params["VAR1"]) - - device.integration_time(params["INTEGRATION"]) - - variables_list = ['VTG','ITG'] - device.variables_to_save(variables_list) - plotted_variables = graph_tool(params,device) - - device.single_measurement() - - while device.operation_completed()==False: - pass - device.autoscaling() - - values = dict([(variable,device.return_values(variable)) for variable in variables_list]) - df = get_dataframe_from_results(values) - - # calculate normalization factor - norm = normalization_factor(params['SAMPLE']["width"]) - - # 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')} + plot_values = values_to_plot(params,device) - 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') + 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') - # 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'] + 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 - ax1.plot(x,y1) + 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+'_Y1.png') + #add the second axis if applicable if plot_list[2]!= "None": - ax2 = ax1.twinx() - y2 = plot_values['Y2'] + fig,ax2=plt.subplots(figsize=(10,6),layout='constrained') + y2 = np.split(plot_values['Y2'],points) if scale_list[2]=='LOG': - ax1.set_yscale('log') + ax2.set_yscale('log') + + ax2.set_xlabel(axes_labels[0]) ax2.set_ylabel(axes_labels[2]) - ax2.plot(x,y2) + 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') + - # Adding title - fig.suptitle('Gatediode Curve', fontweight ="bold") - fig.legend(loc='outside right upper') +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"]) + + device.setup_var1(params["VAR1"]) + + device.integration_time(params["INTEGRATION"]) + + 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 - display(fig) + # calculate normalization factor + norm = normalization_factor(params['SAMPLE']["width"]) - # Save the results + # Append the normalized current + df["ITGmm/uA/um"]= (df["ITG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float') + + # Save the results default_filename = f"{params['SAMPLE']['sample']}_{params['SAMPLE']['field']}_{params['SAMPLE']['device']}_TOP_GATE_D.txt" root = tk.Tk() @@ -1103,77 +1047,18 @@ def Gatediode_VTG(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') - -def Gatediode_VBG(device,params): - device.setup_smu(params["MAP"]['BG'],params["SMU_B"]) - device.smu_disable(params["MAP"]['TG']) - device.setup_smu(params["MAP"]['S'],params["SMU_S"]) - - device.setup_var1(params["VAR1"]) - - device.integration_time(params["INTEGRATION"]) - - variables_list = ['VBG','IBG'] - device.variables_to_save(variables_list) - - - plotted_variables = graph_tool(params,device) - - device.single_measurement() - while device.operation_completed()==False: - pass - - device.autoscaling() - - 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"]) - - # 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 + 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 = [params["PLOT"]["x_scale"],params["PLOT"]["y1_scale"],params["PLOT"]["y2_scale"]] - axes_labels = [] - - if scale_list[0] == 'LOG': - ax1.set_xscale('log') + 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') - # 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]) @@ -1183,23 +1068,76 @@ def Gatediode_VBG(device,params): 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": - ax2 = ax1.twinx() + fig,ax2=plt.subplots(figsize=(10,6),layout='constrained') y2 = plot_values['Y2'] if scale_list[2]=='LOG': - ax1.set_yscale('log') - + ax2.set_yscale('log') + + ax2.set_xlabel(axes_labels[0]) ax2.set_ylabel(axes_labels[2]) ax2.plot(x,y2) - # Adding title - fig.suptitle('Gatediode Curve', fontweight ="bold") - fig.legend(loc='outside right upper') + fig.suptitle('Gatediode Curve', fontweight ="bold") + fig.legend(loc='outside right upper') + display(fig) - 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"]) + + device.setup_var1(params["VAR1"]) + + device.integration_time(params["INTEGRATION"]) + + 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 + + # calculate normalization factor + norm = normalization_factor(params["SAMPLE"]["width"]) + + # Append the normalized current + df["IBGmm/uA/um"]= (df["IBG/A"].apply(lambda x: Decimal(str(x))*Decimal(str(norm)))).astype('float') # 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+'.png') \ No newline at end of file + 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') \ No newline at end of file diff --git a/hp4155/hp4155a.py b/hp4155/hp4155a.py index e925ca7..e6d32d1 100644 --- a/hp4155/hp4155a.py +++ b/hp4155/hp4155a.py @@ -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?') -- GitLab