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

Diode Released!

parent 33d38313
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@ import hp4155a
from interface import *
from help import *
sample = sample_information_interface()
sample,save_plot_button = sample_information_interface()
parameters =parameters_interface()
button = widgets.Button(description ='Start Measurement')
output = widgets.Output()
......@@ -17,10 +17,13 @@ all_widgets = [button]
add_widgets_to_list(sample,all_widgets)
add_widgets_to_list(parameters,all_widgets)
fig = None
device = hp4155a.HP4155a('GPIB0::17::INSTR')
setup(device)
def on_button_clicked(b):
with output:
global fig,file
clear_output(wait = True)
change_state(all_widgets)
area=circle_area(sample['radius'].value)
......@@ -28,12 +31,44 @@ def on_button_clicked(b):
valid = check_values(parameters)
if valid == True:
values = measure(parameters,area,device)
plot_results(values['VS'],values['ABSNOR'])
fig=plot_results(values['VS'],values['ABSNOR'])
filename = f"DIODE_{sample['field'].value}.txt"
file = create_file(filename)
save_to_file(values,sample,parameters,file)
change_state(all_widgets)
save_plot_button.disabled = False
button.on_click(on_button_clicked)
def on_save_plot_button_clicked(b):
with output:
global fig
save_plot_button.disabled = True
change_state(all_widgets)
filename = f"DIODE_{sample['field'].value}.png"
root = tk.Tk()
root.withdraw()
root.lift() #show window above all other applications
root.attributes("-topmost", True)#window stays above all other applications
file = filedialog.asksaveasfilename(defaultextension=".png", filetypes=[("Portable Network Graphics","*.png")],title = "Save Plot",initialfile =filename)
#check if the file path is correct(.txt)
while file.endswith(".png") == False:
#open again filedialog with error message box
answer = tk.messagebox.askyesno(message = "Do you want file operation?")
if answer == True:
file = None
break
file = filedialog.asksaveasfilename(defaultextension=".png", filetypes=[("Portable Network Graphics","*.png")],title = "Save Plot",initialfile =filename)
root.destroy()
if file != None:
fig.savefig(file)
print("Plot Saved Succesfully!")
change_state(all_widgets)
button.on_click(on_button_clicked)
save_plot_button.on_click(on_save_plot_button_clicked)
\ No newline at end of file
%% Cell type:code id:1b607685-438c-466e-9671-140ae6c8d9f9 tags:
``` python
%matplotlib widget
%run diode.py
```
%% Output
%% Cell type:code id:5bc60dda-f423-4cdc-bc39-3404a8cfa1df tags:
``` python
```
......
......@@ -38,7 +38,10 @@ def create_file(filename):
#check if the file path is correct(.txt)
while file.endswith(".txt") == False:
#open again filedialog with error message box
tk.messagebox.showerror(message='invalid filename!')
answer = tk.messagebox.askyesno(message = "Do you want file operation?")
if answer == True:
file = None
break
file = filedialog.asksaveasfilename(defaultextension=".txt", filetypes=[("Text files","*.txt")],title = "save results path",initialfile =filename)
root.destroy()
return file
......@@ -161,24 +164,29 @@ def measure(parameters,area,device):
values = dict([(variable,device.return_values(variable)) for variable in variables_list])
return values
#look at the tool
def plot_results(x,y):
fig, ax1 = plt.subplots()
color = 'tab:red'
ax1.set_xlabel('V/V')
ax1.set_ylabel('$I/A/{cm}^2$', color = color)
ax1.set_xlabel('Voltage (V)')
ax1.set_ylabel('Current density $(A/{cm}^2)$')
ax1.set_yscale('log')
ax1.plot(x,y, color = color)
ax1.tick_params(axis ='y', labelcolor = color)
ax1.grid(True,linestyle = '--',axis = 'y',color ="k",linewidth = 0.5)
ax1.axvline(linestyle='--',color = 'k',linewidth =0.5)
fig.suptitle('Diode Plot', fontweight ="bold")
fig.tight_layout()
fig.show() #interactve Figures
display(fig)
return fig
#also for file
def save_to_file(values,sample,parameters,file):
if file != None:
with open(file,'w') as f:
date = str(datetime.today().replace(microsecond=0))
f.write(f"Diode Measurement at {date}"+"\n")
......
import ipywidgets as widgets
from ipywidgets import GridspecLayout,Layout
from IPython.display import clear_output
from IPython.display import clear_output,display
import sys
import os
......@@ -58,7 +58,7 @@ def sample_information_interface():
for i in range(3):
for j in range(2):
if i ==2 and j == 1:
#information_grid[i,j]=widgets.Dropdown(options=['mA/mm','uA/um'],value='mA/mm',layout=Layout(height=height, width=width))#mind the gap
information_grid[i,j]=widgets.Button(description = "Save Plot",disabled = True)#mind the gap
pass
elif i == 2 and j == 0: #look at the tool for diode area
information_grid[i,j]=widgets.BoundedFloatText(
......@@ -113,5 +113,6 @@ def sample_information_interface():
'field': information_grid[0,1],
'radius': information_grid[2,0],
}
save_plot_button = information_grid[2,1]
return information
return information,save_plot_button
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment