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

TLM-CTLM programming part 6(end) and evaluation part 1

parent 17ad08ee
Branches
No related tags found
No related merge requests found
{"data":{"layout-restorer:data":{"main":{"dock":{"type":"tab-area","currentIndex":0,"widgets":["terminal:1"]},"current":"terminal:1"},"down":{"size":0,"widgets":[]},"left":{"collapsed":false,"visible":true,"current":"filebrowser","widgets":["filebrowser","running-sessions","@jupyterlab/toc:plugin","extensionmanager.main-view"]},"right":{"collapsed":true,"visible":true,"widgets":["jp-property-inspector","debugger-sidebar"]},"relativeSizes":[0.1416215454032713,0.8583784545967287,0],"top":{"simpleVisibility":true}},"terminal:1":{"data":{"name":"1"}}},"metadata":{"id":"default"}}
\ No newline at end of file
......@@ -180,7 +180,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
"version": "3.11.4"
}
},
"nbformat": 4,
......
......@@ -211,7 +211,7 @@ def setup_TLM(smu1,smu2,smu3,smu4,integration,device):
device.display_variable_min_max('X','MIN',-abs(smu3['VAR1']['comp']))
device.display_variable_min_max('X','MAX',abs(smu3['VAR1']['comp']))
device.display_variable_min_max('Y2','MAX',1000)
device.display_variable_min_max('Y2','MAX',200)
device.display_variable_min_max('Y2','MIN',0)
# Measure TLM
......@@ -336,3 +336,30 @@ def load_ini():
file = filedialog.askopenfilename(filetypes=[("Ini files","*.ini")],title = "Select ini file")
root.destroy()
return file
def select_files():
def valid_files(files):
if len(files)>5:
tk.messagebox.showerror(message='More than 5 files selected!')
return False
for file in files:
if file.endswith(".txt") == False:
#open again filedialog with error message box
tk.messagebox.showerror(message='invalid filename!')
return True
return True
root = tk.Tk()
root.withdraw()
root.lift() #show window above all other applications
root.attributes("-topmost", True)#window stays above all other applications
files = filedialog.askopenfilenames(filetypes=[("Txt files","*.txt")],title ='Select files')
valid = valid_files(files)
while valid == False:
files = filedialog.askopenfilenames(filetypes=[("Txt files","*.txt")],title ='Select files')
valid = valid_files(files)
root.destroy()
return files
\ No newline at end of file
from help import *
import ctlmevaluationlib
#from ctlmevaluationlib import *
#the interface
sample = sample_interface()
......@@ -17,8 +19,9 @@ start_button = widgets.Button(description="Start NEW!")
repeat_button = widgets.Button(description="repeat last")
continue_button = widgets.Button(description="save+continue")
exit_button = widgets.Button(description='exit/abort')
evaluation_button = widgets.Button(description='evaluation')
control_buttons = widgets.HBox([start_button,repeat_button,continue_button,exit_button])
control_buttons = widgets.HBox([start_button,repeat_button,continue_button,exit_button,evaluation_button])
display(control_buttons)
print()
......@@ -40,6 +43,10 @@ all_buttons =[start_button,repeat_button,continue_button,exit_button,import_ini_
first_time_buttons= [repeat_button,continue_button,exit_button]
disable_widgets(first_time_buttons)
#disable evaluation button (for now)
evaluation_button.disabled = True
#connect to the device
device = hp4155a.HP4155a('GPIB0::17::INSTR')
......@@ -72,10 +79,12 @@ const_parameters.update(value=0,comp = 10)
smu2.update(CONS=const_parameters)
smu4.update(CONS=const_parameters)
#list to save the filenames
filenames = []
def on_start_button_clicked(b):
with output:
global V,I,curve,distances,counter,folder
global V,I,curve,distances,counter,folder,filenames
clear_output(wait = True)
#disable all widgets
......@@ -87,6 +96,7 @@ def on_start_button_clicked(b):
if valid == True:
#load parameters,exexute measurement and plot results
filenames = []
#clear the figure
ax.cla()
......@@ -156,7 +166,7 @@ def on_repeat_button_clicked(b):
def on_continue_button_clicked(b):
with output:
global V,I,curve,counter,folder
global V,I,curve,counter,folder,filenames
change_state(first_time_buttons)
clear_output(wait = True)
......@@ -203,6 +213,8 @@ def on_continue_button_clicked(b):
f.write(title_parameters)
f.write(df.to_string())
#append to filenames
filenames.append(path)
#increase counter
counter = counter +1 # this is the value before the next measurement starts
......@@ -307,7 +319,41 @@ def on_import_ini_clicked(b):
enable_widgets(all_buttons)
disable_widgets(first_time_buttons)
def on_evaluation_button_clicked(b):
with output:
#disable all widgets
disable_widgets(input_fields)
disable_widgets(all_buttons)
filenames =select_files()
#retrive distances
distances = [sample[f"d{i}"].value for i in range(1,6)]
if len(filenames)==0:
information_box("No files to evaluate")
else:
measurement = ctlmevaluationlib.CTLMandTLMMeasurement(sample["type"].value, filenames, distances, sample["length"].value,sample["length"].value, True)
origin = True
graphs = True
refine = True
if origin:
measurement.plotclosetozero()
if graphs:
measurement.uigraph(size=(7,5))
measurement.rtgraph(size=(7,5))
if refine:
newrange = (-0.03, 0.03)
measurement.refine_evaluated_range(newrange)
if refine and graphs:
measurement.uigraph(size=(7,5))
measurement.rtgraph(size=(7,5))
print(measurement.R_statistics,"\n")
print(measurement.results,"\n")
enable_widgets(input_fields)
enable_widgets(all_buttons)
start_button.on_click(on_start_button_clicked)
......@@ -316,3 +362,4 @@ repeat_button.on_click(on_repeat_button_clicked)
exit_button.on_click(on_exit_button_clicked)
export_ini_button.on_click(on_export_ini_clicked)
import_ini_button.on_click(on_import_ini_clicked)
evaluation_button.on_click(on_evaluation_button_clicked)
\ No newline at end of file
%% Cell type:code id:1850827a-0811-4a03-9ea4-68a99e240de4 tags:
``` python
%matplotlib widget
%run tlm-ctlm.py
```
%% Output
Controls
Save Parameters in .ini file
%% Cell type:code id:27c5a82a-9d84-4698-be8f-17fb15457fe3 tags:
``` python
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment