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
3f2583cf
Commit
3f2583cf
authored
2 years ago
by
Martin Killenberg
Browse files
Options
Downloads
Patches
Plain Diff
Revert "perform measurement in a separate thread"
This reverts commit
c6944c41
.
parent
c6944c41
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Python_script/MeasurementPlot.py
+4
-27
4 additions, 27 deletions
Python_script/MeasurementPlot.py
Python_script/prototype.py
+2
-15
2 additions, 15 deletions
Python_script/prototype.py
with
6 additions
and
42 deletions
Python_script/MeasurementPlot.py
+
4
−
27
View file @
3f2583cf
...
...
@@ -2,7 +2,6 @@ import pandas as pd
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
time
import
queue
# Different exceptions can be thrown while plotting, depending on the backend.
# We catch them all locally and raise our own exception instead
...
...
@@ -54,28 +53,7 @@ class MeasurementPlot:
labels
=
[
pc
.
get_label
()
for
pc
in
all_path_collections
]
self
.
ax1
[
1
].
legend
(
all_path_collections
,
labels
,
loc
=
'
lower right
'
)
self
.
data_queue
=
queue
.
Queue
(
10
)
def
stop
(
self
):
self
.
data_queue
.
put
((
None
,
None
,
True
))
def
draw_in_other_thread
(
self
,
data_frame
,
pdf_name
=
''
):
# A shallow copy is enough (although not strictly 100 % thread safe). Data is only appended and
# the data members are not altered.
frame_copy
=
data_frame
.
copy
()
try
:
self
.
data_queue
.
put_nowait
((
frame_copy
,
pdf_name
,
False
))
except
queue
.
Full
:
pass
def
drawing_loop
(
self
):
while
True
:
data_frame
,
pdf_name
,
stop_thread
=
self
.
data_queue
.
get
()
if
stop_thread
:
return
self
.
draw_in_this_thread
(
data_frame
,
pdf_name
=
''
)
def
draw_in_this_thread
(
self
,
data_frame
,
pdf_name
=
''
):
def
draw
(
self
,
data_frame
,
pdf_name
=
''
):
timestamps
=
data_frame
.
TIMESTAMP
minimum
,
maximum
=
self
.
get_extended_min_max
(
timestamps
)
self
.
ax1
[
0
].
set_xlim
(
minimum
,
maximum
)
...
...
@@ -128,7 +106,6 @@ if __name__ == '__main__':
plt
.
ion
()
measurements
=
[]
#FIXME: The loop should run in a separate thread and use draw_in_other_thread
for
i
in
range
(
20
):
measurement
=
{
'
TIMESTAMP
'
:
i
,
...
...
@@ -139,11 +116,11 @@ if __name__ == '__main__':
'
S21_MAGNITUDE
'
:
0.3
*
i
}
measurements
.
append
(
measurement
)
my_
data_frame
=
pd
.
DataFrame
(
measurements
)
m
.
draw
_in_this_thread
(
my_
data_frame
)
data_frame
=
pd
.
DataFrame
(
measurements
)
m
.
draw
(
data_frame
)
print
(
str
(
i
))
time
.
sleep
(
0.3
)
print
(
'
I am done.
'
)
plt
.
ioff
()
m
.
draw
_in_this_thread
(
my_
data_frame
,
'
the.pdf
'
)
m
.
draw
(
data_frame
,
'
the.pdf
'
)
This diff is collapsed.
Click to expand it.
Python_script/prototype.py
+
2
−
15
View file @
3f2583cf
...
...
@@ -14,7 +14,6 @@ import json
import
MeasurementPlot
import
sys
import
analysis
import
threading
TEMPERATURE_STABLE
=
0x1
HUMIDITY_STABLE
=
0x2
...
...
@@ -137,17 +136,7 @@ class Measurements:
plt
.
close
()
return
sweep_values
# wrapper function which calls the impl in a separate thread and runs the
# plotting loop
def
perform_single_measurement
(
self
,
output
,
target_temp
,
target_hum
,
soaking_time
,
n_stable_reads
):
measurement_thread
=
threading
.
Thread
(
target
=
self
.
perform_single_measurement_impl
,
args
=
(
output
,
target_temp
,
target_hum
,
soaking_time
,
n_stable_reads
))
measurement_thread
.
start
()
self
.
measurement_plot
.
drawing_loop
()
measurement_thread
.
join
()
def
perform_single_measurement_impl
(
self
,
output
,
target_temp
,
target_hum
,
soaking_time
,
n_stable_reads
):
with
open
(
output
,
mode
=
'
w
'
,
newline
=
''
)
as
csv_file
:
fieldnames
=
[
'
TIMESTAMP
'
,
'
TARGET_TEMPERATURE
'
,
'
READBACK_TEMPERATURE
'
,
'
TARGET_HUMIDITY
'
,
'
READBACK_HUMIDITY
'
,
'
RF_POWER
'
,
'
RF_FREQUENCY
'
,
'
DUT_IDENTIFIER
'
,
'
RUN_ID
'
,
...
...
@@ -266,8 +255,6 @@ class Measurements:
writer
.
writerow
(
measurement
)
self
.
measurement_plot
.
stop
()
def
sleep_until
(
self
,
wakeup_time
):
remaining_sleep_time
=
wakeup_time
-
self
.
clock
.
time
()
if
remaining_sleep_time
>
0
:
...
...
@@ -306,7 +293,7 @@ class Measurements:
}
self
.
data_collection
.
append
(
measurement
)
data_frame
=
pd
.
DataFrame
(
self
.
data_collection
)
self
.
measurement_plot
.
draw
_in_other_thread
(
data_frame
)
self
.
measurement_plot
.
draw
(
data_frame
)
def
current_milli_time
(
self
):
return
int
(
round
(
self
.
clock
.
time
()
*
1000
))
...
...
@@ -375,7 +362,7 @@ def plot_output(output_basename, measurements_appendices, show_blocking_plot, ti
if
show_blocking_plot
:
plt
.
ioff
()
plot
=
MeasurementPlot
.
MeasurementPlot
(
title
)
plot
.
draw
_in_this_thread
(
combined_data_frame
,
output_basename
+
'
_graph.pdf
'
)
plot
.
draw
(
combined_data_frame
,
output_basename
+
'
_graph.pdf
'
)
def
run_temperature_sweep_from_file
(
temperature_sweep_file
,
meas
):
with
open
(
temperature_sweep_file
)
as
file
:
...
...
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