Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Climate Lab Test Stand
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MSK-SW
Low-Level Radio Frequency
Climate Lab
Climate Lab Test Stand
Commits
b6b6a348
Commit
b6b6a348
authored
2 years ago
by
Martin Killenberg
Browse files
Options
Downloads
Patches
Plain Diff
use MeasurementPlot class in prototype script
parent
06183301
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Python_script/prototype.py
+13
-63
13 additions, 63 deletions
Python_script/prototype.py
with
13 additions
and
63 deletions
Python_script/prototype.py
+
13
−
63
View file @
b6b6a348
...
...
@@ -11,7 +11,7 @@ import climate_chamber
import
VNA
import
virtual_time
import
json
import
MeasurementPlot
TEMPERATURE_STABLE
=
0x1
HUMIDITY_STABLE
=
0x2
...
...
@@ -61,6 +61,8 @@ class Measurements:
self
.
vna
.
create_new_trace
(
"
Trace3
"
,
"
S21
"
)
self
.
vna
.
create_new_trace
(
"
Trace4
"
,
"
S22
"
)
self
.
measurement_plot
=
MeasurementPlot
.
MeasurementPlot
()
def
perform_measurements
(
self
):
with
open
(
self
.
output
,
mode
=
'
w
'
,
newline
=
''
)
as
csv_file
:
fieldnames
=
[
'
TIMESTAMP
'
,
'
TARGET_TEMPERATURE
'
,
'
READBACK_TEMPERATURE
'
,
'
TARGET_HUMIDITY
'
,
...
...
@@ -71,7 +73,7 @@ class Measurements:
writer
=
csv
.
DictWriter
(
csv_file
,
fieldnames
=
fieldnames
)
writer
.
writeheader
()
self
.
data_collection
=
[]
self
.
subplot_tuple
=
plt
.
subplots
(
2
,
figsize
=
(
12
,
10
)
)
plt
.
ion
(
)
with
open
(
self
.
sweep_file
)
as
file
:
try
:
...
...
@@ -136,8 +138,7 @@ class Measurements:
print
(
'
Setpoint:
'
+
str
(
next_temp
)
+
'
'
+
str
(
next_hum
)
+
'
| Temp:
'
+
data
.
temp
+
'
°C
'
+
'
| Humid:
'
+
data
.
hum
+
'
%
'
+
'
| soaking read nr
'
+
str
(
len
(
magnitudes_queue
)))
self
.
write_data
(
writer
,
next_temp
,
next_hum
,
data
,
self
.
cook_up_equi_indicator
())
#,
#data_frame, subplot_tuple)
self
.
write_data
(
writer
,
next_temp
,
next_hum
,
data
,
self
.
cook_up_equi_indicator
())
if
self
.
temperature_stable
and
self
.
humidity_stable
and
self
.
magnitude_stable
and
\
self
.
phase_stable
:
...
...
@@ -201,13 +202,13 @@ class Measurements:
return
MeasurementData
(
int
(
self
.
clock
.
time
()),
temp
,
hum
,
power
,
frequency
,
s11
,
s21
,
s12
,
s22
)
def
write_data
(
self
,
writer
,
target_temp
,
target_hum
,
data
,
equi_indicator
):
#, data_frame, subplot_tuple):
def
write_data
(
self
,
writer
,
target_temp
,
target_hum
,
data
,
equi_indicator
):
measurement
=
{
'
TIMESTAMP
'
:
data
.
timestamp
,
'
TARGET_TEMPERATURE
'
:
target_temp
,
'
READBACK_TEMPERATURE
'
:
data
.
temp
,
'
READBACK_TEMPERATURE
'
:
float
(
data
.
temp
)
,
'
TARGET_HUMIDITY
'
:
target_hum
,
'
READBACK_HUMIDITY
'
:
data
.
hum
,
'
READBACK_HUMIDITY
'
:
float
(
data
.
hum
)
,
'
RF_POWER
'
:
data
.
power
,
'
RF_FREQUENCY
'
:
data
.
frequency
,
'
EQUILIBRIUM_INDICATOR
'
:
equi_indicator
,
...
...
@@ -223,7 +224,7 @@ class Measurements:
writer
.
writerow
(
measurement
)
self
.
data_collection
.
append
(
measurement
)
data_frame
=
pd
.
DataFrame
(
self
.
data_collection
)
plot_
measurement
(
data_fram
e
,
False
,
False
,
self
.
subplot_tupl
e
)
self
.
measurement
_plot
.
draw
(
data_frame
)
def
current_milli_time
(
self
):
return
int
(
round
(
self
.
clock
.
time
()
*
1000
))
...
...
@@ -282,63 +283,12 @@ class Measurements:
return
(
target_hum
-
self
.
max_delta_hum
<=
float
(
readback_hum
))
and
\
(
float
(
readback_hum
)
<=
target_hum
+
self
.
max_delta_hum
)
# plot a single measurement (phase, magnitude, temp and hum against time) from a pandas data frame
def
plot_measurement
(
data_frame
,
show_blocking_plot
,
save_pdf
=
True
,
subplot_tuple
=
(
None
,
None
)):
fig
,
ax1
=
subplot_tuple
if
fig
is
None
or
ax1
is
None
:
fig
,
ax1
=
plt
.
subplots
(
2
,
figsize
=
(
12
,
10
))
path_collection01
=
ax1
[
0
].
scatter
(
data_frame
.
TIMESTAMP
,
data_frame
.
S21_PHASE
,
c
=
'
red
'
,
marker
=
'
<
'
,
label
=
'
Phase
'
)
twin2_0
=
ax1
[
0
].
twinx
()
path_collection02
=
twin2_0
.
scatter
(
data_frame
.
TIMESTAMP
,
data_frame
.
S21_MAGNITUDE
,
c
=
'
#3120E0
'
,
marker
=
'
4
'
,
label
=
'
Magnitude
'
)
twin3_0
=
ax1
[
0
].
twinx
()
twin3_0
.
spines
[
'
right
'
].
set_position
((
'
outward
'
,
40
))
path_collection03
=
twin3_0
.
scatter
(
data_frame
.
TIMESTAMP
,
data_frame
.
EQUILIBRIUM_INDICATOR
,
c
=
'
black
'
,
marker
=
"
.
"
,
label
=
'
Equilibrium_Indicator
'
)
ax1
[
0
].
set_xlabel
(
"
TIMESTAMP
"
)
ax1
[
0
].
set_ylabel
(
"
PHASE
"
,
color
=
'
red
'
)
twin2_0
.
set_ylabel
(
"
MAGNITUDE
"
,
color
=
'
#3120E0
'
)
twin3_0
.
set_ylabel
(
"
EQUILIBRIUM_INDICATOR
"
,
color
=
'
black
'
)
ax1
[
0
].
grid
(
True
,
linestyle
=
"
:
"
)
all_path_collections
=
[
path_collection01
,
path_collection02
,
path_collection03
]
labels
=
[
pc
.
get_label
()
for
pc
in
all_path_collections
]
ax1
[
0
].
legend
(
all_path_collections
,
labels
,
loc
=
'
lower right
'
)
path_collection11
=
ax1
[
1
].
scatter
(
data_frame
.
TIMESTAMP
,
data_frame
.
READBACK_TEMPERATURE
,
c
=
'
blue
'
,
marker
=
'
p
'
,
label
=
"
Temperature
"
)
twin2_1
=
ax1
[
1
].
twinx
()
path_collection12
=
twin2_1
.
scatter
(
data_frame
.
TIMESTAMP
,
data_frame
.
READBACK_HUMIDITY
,
c
=
'
green
'
,
marker
=
"
*
"
,
label
=
"
Humidity
"
)
twin3_1
=
ax1
[
1
].
twinx
()
twin3_1
.
spines
[
'
right
'
].
set_position
((
'
outward
'
,
40
))
path_collection13
=
twin3_1
.
scatter
(
data_frame
.
TIMESTAMP
,
data_frame
.
EQUILIBRIUM_INDICATOR
,
c
=
'
black
'
,
marker
=
"
.
"
,
label
=
"
Equilibrium_Indicator
"
)
ax1
[
1
].
set_xlabel
(
"
TIMESTAMP
"
)
ax1
[
1
].
set_ylabel
(
"
TEMPERATURE
"
,
color
=
'
blue
'
)
twin2_1
.
set_ylabel
(
"
HUMIDITY
"
,
color
=
'
green
'
)
twin3_1
.
set_ylabel
(
"
EQUILIBRIUM_INDICATOR
"
,
color
=
'
black
'
)
ax1
[
1
].
grid
(
True
,
linestyle
=
"
:
"
)
all_path_collections
=
[
path_collection11
,
path_collection12
,
path_collection13
]
labels
=
[
pc
.
get_label
()
for
pc
in
all_path_collections
]
ax1
[
1
].
legend
(
all_path_collections
,
labels
,
loc
=
'
lower right
'
)
if
save_pdf
:
fig
.
savefig
(
output_basename
+
'
_graph.pdf
'
)
# turn interactive on if we are not supposed to block, otherwise turn it off
if
show_blocking_plot
:
plt
.
ioff
()
else
:
plt
.
ion
()
fig
.
canvas
.
draw
()
fig
.
canvas
.
flush_events
()
plt
.
show
()
def
plot_output
(
output_basename
,
show_blocking_plot
,
save_pdf
=
True
):
data_frame
=
pd
.
read_csv
(
output_basename
+
'
.csv
'
)
plot_measurement
(
data_frame
,
show_blocking_plot
,
save_pdf
)
if
show_blocking_plot
:
plt
.
ioff
()
plot
=
MeasurementPlot
.
MeasurementPlot
()
plot
.
draw
(
data_frame
,
output_basename
+
'
_graph.pdf
'
)
if
__name__
==
'
__main__
'
:
parser
=
ArgumentParser
()
...
...
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