Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
labcode
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CST
labcode
Commits
374296ca
Commit
374296ca
authored
Jun 6, 2024
by
Alexandros Asonitis
Browse files
Options
Downloads
Patches
Plain Diff
TLM-CTLM programming part 4 (files)
parent
711b29a3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
hp4155/TLM-CTLM/help.py
+56
-1
56 additions, 1 deletion
hp4155/TLM-CTLM/help.py
hp4155/TLM-CTLM/tlm-ctlm.py
+52
-7
52 additions, 7 deletions
hp4155/TLM-CTLM/tlm-ctlm.py
hp4155/TLM-CTLM/tlm-ctlm_interface.ipynb
+7
-7
7 additions, 7 deletions
hp4155/TLM-CTLM/tlm-ctlm_interface.ipynb
with
115 additions
and
15 deletions
hp4155/TLM-CTLM/help.py
+
56
−
1
View file @
374296ca
...
...
@@ -12,6 +12,10 @@ import tkinter.messagebox
import
time
import
matplotlib.pyplot
as
plt
import
os
from
datetime
import
datetime
import
pandas
as
pd
# Interface to collect information about the sample
def
sample_interface
():
...
...
@@ -245,3 +249,54 @@ def information_box(information):
#display meaagebox
tkinter
.
messagebox
.
showinfo
(
message
=
information
)
root
.
destroy
()
#check if a folder is writable
def
check_writable
(
folder
):
filename
=
"
test.txt
"
file
=
os
.
path
.
join
(
folder
,
filename
)
#protection against removing existing file in python
i
=
1
while
os
.
path
.
exists
(
file
):
filename
=
f
"
test
{
i
}
.txt
"
file
=
os
.
path
.
join
(
folder
,
filename
)
try
:
with
open
(
file
,
'
a
'
):
writable
=
True
os
.
remove
(
file
)
except
:
writable
=
False
information_box
(
f
"
{
folder
}
is not writable!
"
)
return
writable
#choose directory for saving the results
def
choose_folder
():
root
=
tk
.
Tk
()
root
.
withdraw
()
root
.
lift
()
#show window above all other applications
root
.
attributes
(
"
-topmost
"
,
True
)
#window stays above all other applications
#choose nonemty folder
folder
=
tk
.
filedialog
.
askdirectory
()
while
folder
==
''
:
folder
=
tk
.
filedialog
.
askdirectory
()
#check if writable in a while loop
writable
=
check_writable
(
folder
)
while
writable
==
False
:
#choose a correct folder
folder
=
tk
.
filedialog
.
askdirectory
()
while
folder
==
''
:
folder
=
tk
.
filedialog
.
askdirectory
()
#check writable if not repeat
writable
=
check_writable
(
folder
)
root
.
destroy
()
return
folder
This diff is collapsed.
Click to expand it.
hp4155/TLM-CTLM/tlm-ctlm.py
+
52
−
7
View file @
374296ca
...
...
@@ -51,6 +51,7 @@ curve = 0
V
=
0
I
=
0
distances
=
[]
folder
=
None
#initialize smus (empty)
smu1
=
device
.
smu_dict
()
...
...
@@ -74,28 +75,31 @@ smu4.update(CONS=const_parameters)
def
on_start_button_clicked
(
b
):
with
output
:
global
V
,
I
,
curve
,
distances
,
counter
global
V
,
I
,
curve
,
distances
,
counter
,
folder
clear_output
(
wait
=
True
)
#disable all widgets
disable_widgets
(
input_fields
)
disable_widgets
(
all_buttons
)
#clear the figure
ax
.
cla
()
#check if values are correct
valid
=
check_values
(
start
=
parameters
[
'
start
'
],
stop
=
parameters
[
'
stop
'
],
step
=
parameters
[
'
step
'
])
if
valid
==
True
:
#load parameters,exexute measurement and plot results
#clear the figure
ax
.
cla
()
#first reset counter
counter
=
0
#retrive distances
distances
=
[
sample
[
f
"
d
{
i
}
"
].
value
for
i
in
range
(
1
,
6
)]
#choose folder
folder
=
choose_folder
()
#load parameters
#update the dictionary var1
var1
.
update
(
...
...
@@ -152,12 +156,53 @@ def on_repeat_button_clicked(b):
def
on_continue_button_clicked
(
b
):
with
output
:
global
V
,
I
,
curve
,
counter
global
V
,
I
,
curve
,
counter
,
folder
change_state
(
first_time_buttons
)
clear_output
(
wait
=
True
)
#save results(counter = 0,1,2,3,4)
# fstrings are problematic extract values
field
=
sample
[
"
field
"
].
value
type
=
sample
[
"
type
"
].
value
date
=
str
(
datetime
.
today
().
replace
(
microsecond
=
0
))
processing_number
=
sample
[
"
processing_number
"
].
value
sample_series
=
sample
[
"
sample_series
"
].
value
length
=
sample
[
"
length
"
].
value
width
=
sample
[
"
width
"
].
value
start
=
parameters
[
"
start
"
].
value
stop
=
parameters
[
"
stop
"
].
value
step
=
parameters
[
"
step
"
].
value
comp
=
parameters
[
"
comp
"
].
value
integration
=
parameters
[
"
integration
"
].
value
filename
=
f
"
{
field
}
_
{
type
}
_
{
counter
+
1
}
.txt
"
path
=
os
.
path
.
join
(
folder
,
filename
)
#check if filename exists
i
=
1
while
os
.
path
.
exists
(
path
):
filename
=
f
"
{
field
}
_
{
type
}
_
{
counter
+
1
}
(
{
i
}
).txt
"
path
=
os
.
path
.
join
(
folder
,
filename
)
i
=
i
+
1
#write to file
title_sample
=
f
"
{
type
}
Measurement at
{
date
}
"
+
"
\n
"
+
f
"
Processing Number:
{
processing_number
}
"
+
"
\n
"
+
f
"
Sample Series:
{
sample_series
}
"
+
"
\n
"
+
f
"
Field:
{
field
}
"
+
"
\n
"
+
f
"
Contanctlength|Innen Radius/um:
{
length
}
"
+
"
\n
"
+
f
"
Width/um:
{
width
}
"
+
"
\n
"
+
f
"
Distance/um:
{
distances
[
counter
]
}
"
+
"
\n\n
"
title_parameters
=
f
"
Current/A:
{
start
}
to
{
stop
}
with step
{
step
}
"
+
"
\n
"
+
f
"
Compliance/V:
{
comp
}
"
+
"
\n
"
+
f
"
Integration Time:
{
integration
}
"
+
"
\n\n
"
#create the dataframe
header
=
[
'
V / V
'
,
'
I / A
'
]
data
=
{
header
[
0
]:
V
,
header
[
1
]:
I
}
df
=
pd
.
DataFrame
(
data
)
with
open
(
path
,
"
w
"
)
as
f
:
f
.
write
(
title_sample
)
f
.
write
(
title_parameters
)
f
.
write
(
df
.
to_string
())
#increase counter
counter
=
counter
+
1
# this is the value before the next measurement starts
...
...
This diff is collapsed.
Click to expand it.
hp4155/TLM-CTLM/tlm-ctlm_interface.ipynb
+
7
−
7
View file @
374296ca
...
...
@@ -9,7 +9,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
7512f74f392c41278639ec5238181959
",
"model_id": "
c4927643bdd241a986420e6a0cfe3e5a
",
"version_major": 2,
"version_minor": 0
},
...
...
@@ -30,7 +30,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
166ab0a86dba4a3d9a4f79ee3f04b88c
",
"model_id": "
2e3a2b26b98949e7ac131a4c8f7d7027
",
"version_major": 2,
"version_minor": 0
},
...
...
@@ -44,7 +44,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
cac249685be04ae38c61c79d7d701126
",
"model_id": "
be86978739cc49c48962a277f8a82c78
",
"version_major": 2,
"version_minor": 0
},
...
...
@@ -66,7 +66,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
a9a9957cf167415e95df8457a94e1a3b
",
"model_id": "
ecfa05065df648cc8a143c1804ebec12
",
"version_major": 2,
"version_minor": 0
},
...
...
@@ -88,7 +88,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1
4e511574d2342ab9c19d7b5a4e09c9a
",
"model_id": "1
149d141b84346c3ada4e0b3f551e1b0
",
"version_major": 2,
"version_minor": 0
},
...
...
@@ -102,7 +102,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
d9d92353ebea438f91e032a7d7f354ad
",
"model_id": "
96ca019415384e4bac88b47577f5010b
",
"version_major": 2,
"version_minor": 0
},
...
...
@@ -122,7 +122,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
bea7cae7-2f79-4bcf-88f9-d9b50f7881ad
",
"id": "
27c5a82a-9d84-4698-be8f-17fb15457fe3
",
"metadata": {},
"outputs": [],
"source": []
...
...
%% 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:
bea7cae7-2f79-4bcf-88f9-d9b50f7881ad
tags:
%% Cell type:code id:
27c5a82a-9d84-4698-be8f-17fb15457fe3
tags:
```
python
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment