Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
adc-lib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
adc-lib
Commits
102eb8c1
Commit
102eb8c1
authored
Sep 10, 2021
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tst: improve error reporting digital noise
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
9065eaa0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
test_adc_regressions.py
pytest/fmc-adc-100m14b4cha/test_adc_regressions.py
+14
-7
No files found.
pytest/fmc-adc-100m14b4cha/test_adc_regressions.py
View file @
102eb8c1
...
...
@@ -13,24 +13,31 @@ import matplotlib.pyplot as plt
def
adc_simple_triangle
(
adc_simple
):
yield
adc_simple
def
digital_noise_plot
(
raw_data
,
index
,
chan_err
):
def
digital_noise_plot
(
raw_data
,
index
,
chan_err
,
vref
):
# convert signed data to mV (numpy array)
plot_data
=
np
.
array
(
raw_data
)
# plot and store
f1
,
a1
=
plt
.
subplots
()
if
vref
==
PyFmcAdc100m14b4ch
.
ADC_CONF_100M14B4CHA_CHN_RANGE_1V
:
bit_scale
=
0.5
/
(
1
<<
15
)
elif
vref
==
PyFmcAdc100m14b4ch
.
ADC_CONF_100M14B4CHA_CHN_RANGE_10V
:
bit_scale
=
5.0
/
(
1
<<
15
)
else
:
bit_scale
=
1
# raw
volt_data
=
[
data
*
bit_scale
for
data
in
raw_data
]
for
ch
in
range
(
0
,
4
):
a1
.
plot
(
raw
_data
[
ch
::
4
],
label
=
'CH'
+
str
(
ch
+
1
)
+
(
" WARN"
if
ch
==
chan_err
else
""
))
a1
.
plot
(
volt
_data
[
ch
::
4
],
label
=
'CH'
+
str
(
ch
+
1
)
+
(
" WARN"
if
ch
==
chan_err
else
""
))
a1
.
set_xlabel
(
'sample number'
)
a1
.
set_xticklabels
(
range
(
index
,
index
+
int
(
len
(
raw_data
)
/
4
)))
a1
.
set_ylabel
(
'raw value'
)
a1
.
set_ylabel
(
'Volt'
)
a1
.
legend
()
f1
.
savefig
(
"/tmp/digital_noise_plot.png"
,
dpi
=
300
)
plt
.
show
()
def
digital_noise_report
(
buf
,
index
,
chan_err
):
def
digital_noise_report
(
buf
,
index
,
chan_err
,
vref
):
message
=
"Unexpected value on channel {:d}
\n
"
.
format
(
chan_err
)
if
index
>
1
:
for
chan
in
range
(
4
):
...
...
@@ -46,7 +53,7 @@ def digital_noise_report(buf, index, chan_err):
samp
)
subset
=
buf
.
contents
.
data
[:
buf
.
contents
.
nsamples
*
4
]
message
+=
str
(
subset
)
digital_noise_plot
(
subset
,
index
,
chan_err
)
digital_noise_plot
(
subset
,
index
,
chan_err
,
vref
)
return
message
class
TestAdcRegressions
(
object
):
...
...
@@ -93,7 +100,7 @@ class TestAdcRegressions(object):
sample
=
buf
.
contents
.
get_sample
(
chan
,
i
)
>>
2
if
prev_s
is
not
None
:
# TODO improve future sample computarion (just rule of thumb number now)
assert
abs
(
sample
-
prev_s
)
<
500
,
digital_noise_report
(
buf
,
i
,
chan
)
assert
abs
(
sample
-
prev_s
)
<
500
,
digital_noise_report
(
buf
,
i
,
chan
,
vref
)
prev_s
=
sample
adc_simple_triangle
.
release_buffer
(
buf
,
None
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment