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

selection and saving of ini files as well as a loading of some parameters

parent 4e01dd96
No related branches found
No related tags found
No related merge requests found
......@@ -14,9 +14,9 @@ hyst = SINGle
pcomp = 0.0
[Vds_transfer]
start = 10.0
start = 0.1
step = 0.45
stop = 10.0
stop = 1.0
comp = 0.1
pcomp = 0.0
......@@ -36,7 +36,7 @@ step = 0.1
stop = 15.0
comp = 0.1
hyst = SINGle
pcomp = 0.2
pcomp = 0.0
[Gatediode]
integration = MEDium
......@@ -46,6 +46,6 @@ start = -8.0
step = 0.05
stop = 2.0
comp = 0.02
hyst = SINGle
hyst = DOUBle
pcomp = 0.0
......@@ -227,6 +227,36 @@ def normalization_factor(width):
return factor
def save_as_ini(default_filename):
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=".ini", filetypes=[("Ini files","*.ini")],title = "save as ini",initialfile =default_filename)
#check if the file path is correct(.txt)
while file.endswith(".ini") == False:
#open again filedialog with error message box
tk.messagebox.showerror(message='invalid filename!')
file = filedialog.asksaveasfilename(defaultextension=".ini", filetypes=[("Ini files","*.ini")],title = "save as ini",initialfile =default_filename)
root.destroy()
return file
def load_ini():
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.askopenfilename(filetypes=[("Ini files","*.ini")],title ='Select ini file')
while file.endswith(".ini") == False:
#open again filedialog with error message box
tk.messagebox.showerror(message='invalid filename!')
file = filedialog.askopenfilename(filetypes=[("Ini files","*.ini")],title = "Select ini file")
root.destroy()
return file
\ No newline at end of file
%% Cell type:code id:910776b3-e909-40e6-88b4-586ff7e48285 tags:
``` python
from interface import *
from help import *
import configparser
# Create the grids
#create the information grid
style = {'description_width': 'initial'}
sample = information_grid()
###end of sampling information#######################################
test_contacts=widgets.Checkbox(description = "Test of the Contacts",value = True,indent = False)
display(test_contacts)
print()
#transfer
transfer_check,integration_transfer = header('Transfer Curve')
Vds_transfer = secondary('Vds',0.1,0.45,1,0.1)
Vgs_transfer = primary('Vgs',2,-0.05,-8,0.01)
print()
print()
#output
output_check,integration_output = header('Output Curve')
Vds_output = primary('Vds',0,0.1,15,0.1)
Vgs_output = secondary('Vgs',2,-1,-8,0.01)
print()
print()
#GateDiodde
gatediode_check,integration_gatediode=header('Gatediode')
Vgs_gatediode=primary('Vgs',-8,0.05,2,0.02)
print()
print()
# the button
button = widgets.Button(description ='Start Measurement')
output = widgets.Output()
all_widgets =[button,transfer_check,integration_transfer,output_check,integration_output,gatediode_check,integration_gatediode,test_contacts]
add_widgets_to_list(sample,all_widgets)
add_widgets_to_list(Vds_transfer,all_widgets)
add_widgets_to_list(Vgs_transfer,all_widgets)
add_widgets_to_list(Vds_output,all_widgets)
add_widgets_to_list(Vgs_output,all_widgets)
add_widgets_to_list(Vgs_gatediode,all_widgets)
display(button,output)
export_ini_button = widgets.Button(description = 'Export as ini')
load_ini_button = widgets.Button(description='Load from ini')
line = widgets.HBox([button,load_ini_button,export_ini_button])
display(line,output)
```
%% Output
%% Cell type:code id:c3ff3040-e3fa-4ec6-a02b-81c3f4ec7f35 tags:
``` python
config = configparser.ConfigParser()
with open('ADU.ini','w') as configfile:
config.add_section('ALL VALUES ARE IN SI-UNITS!')
config.add_section('IT IS RECOMMENDED TO CHANGE THE INI FILE FROM THE INTERFACE AND DO NOT CHANGE ANY VALUES MANUALLY')
config.add_section('Transfer')
config.set('Transfer','Integration',integration_transfer.value)
config.add_section("Vgs_transfer")
for parameter,widget in Vgs_transfer.items():
config.set('Vgs_transfer',parameter,str(widget.value))
config.add_section('Vds_transfer')
for parameter,widget in Vds_transfer.items():
config.set('Vds_transfer',parameter,str(widget.value))
config.add_section('Output')
config.set('Output','Integration',integration_output.value)
config.add_section("Vgs_output")
for parameter,widget in Vgs_output.items():
config.set('Vgs_output',parameter,str(widget.value))
config.add_section('Vds_output')
for parameter,widget in Vds_output.items():
config.set('Vds_output',parameter,str(widget.value))
config.add_section('Gatediode')
config.set('Gatediode','Integration',integration_gatediode.value)
config.add_section("Vgs_gatediode")
for parameter,widget in Vgs_gatediode.items():
config.set('Vgs_gatediode',parameter,str(widget.value))
config.write(configfile)
```
%% Cell type:code id:a13c06d4-3cbf-460a-8583-908442e6446b tags:
``` python
#load values to the interface
config.read('ADU.ini')
#read the values from each section
print(config.sections())
print(dict(config.items('Vgs_gatediode')))
#read the values from each section
try:
integration_transfer.value = config.get('Transfer', "integration")
Vgs_gatediode['stop'].value = 50
for parameter,widget in Vgs_transfer.items():
widget.value = config.get('Vgs_transfer',parameter)
print(widget.value)
except Exception as error:
if type(error).__name__ =='NoSectionError':
information_box("Section(header) [section] does not exist. Create a new ini file or compare it with functional ini files!")
elif type(error).__name__=='NoOptionError':
information_box('The variable name before the equal sign is not recognized. Create a new ini file or compare it with functional ini files!')
elif type(error).__name__ == 'TraitError':
information_box('Invalid Parameter Setting. Check if you set an invalid value!')
else:
information_box(f"A {type(error).__name__} has occurred. Create A new ini file")
```
%% Output
['ALL VALUES ARE IN SI-UNITS!', 'IT IS RECOMMENDED TO CHANGE THE INI FILE FROM THE INTERFACE AND DO NOT CHANGE ANY VALUES MANUALLY', 'Transfer', 'Vgs_transfer', 'Vds_transfer', 'Output', 'Vgs_output', 'Vds_output', 'Gatediode', 'Vgs_gatediode']
{'start': '-8.0', 'step': '0.05', 'stop': '2.0', 'comp': '0.02', 'hyst': 'SINGle', 'pcomp': '0.0'}
2.0
-0.05
-8.0
0.01
SINGle
0.0
%% Cell type:code id:3d6041fd-326f-43de-be88-b3fe357238be tags:
%% Cell type:code id:abbb2987-2104-47e1-ab13-671163fe0d03 tags:
``` python
#export as ini
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment