Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
ADC Testing
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
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 Testing
Commits
613f9895
Commit
613f9895
authored
Aug 23, 2017
by
Dimitris Lampridis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix typos and avoid using floats for array indexing, solves #1615
parent
d89f028a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
15 deletions
+13
-15
SingleToneSignal.py
SignalProcessing/SingleToneSignal.py
+9
-9
WindowedSignal.py
SignalProcessing/WindowedSignal.py
+2
-2
MainWindow.py
qtGUI/MainWindow.py
+1
-3
ModuleSelector.py
qtGUI/ModuleSelector.py
+1
-1
No files found.
SignalProcessing/SingleToneSignal.py
View file @
613f9895
...
@@ -88,8 +88,8 @@ class SingleToneSignal(Signal):
...
@@ -88,8 +88,8 @@ class SingleToneSignal(Signal):
fdft
=
self
.
fulldft
fdft
=
self
.
fulldft
# index of the biggest peak
# index of the biggest peak
first
=
1
.
+
argmax
(
fdft
[
1
:
N
/
2
])
first
=
1
+
argmax
(
fdft
[
1
:
N
/
2
])
# index of the biggest peak nearest to `first`
# index of the biggest peak nearest to `first`
# can only be first +-1.
# can only be first +-1.
second
=
first
+
((
fdft
[
first
-
1
]
<
fdft
[
first
+
1
])
*
2
)
-
1
second
=
first
+
((
fdft
[
first
-
1
]
<
fdft
[
first
+
1
])
*
2
)
-
1
...
@@ -127,7 +127,7 @@ class SingleToneSignal(Signal):
...
@@ -127,7 +127,7 @@ class SingleToneSignal(Signal):
# limit data removing incoherency
# limit data removing incoherency
self
.
w0index
=
self
.
w0
/
freqSample
*
self
.
nsamples
self
.
w0index
=
self
.
w0
/
freqSample
*
self
.
nsamples
self
.
limit
=
floor
(
0.5
+
N
*
int
(
self
.
w0index
)
/
self
.
w0index
)
self
.
limit
=
int
(
floor
(
0.5
+
N
*
int
(
self
.
w0index
)
/
self
.
w0index
)
)
self
.
data
=
data
[:
self
.
limit
]
self
.
data
=
data
[:
self
.
limit
]
self
.
nsamples
=
len
(
self
.
data
)
self
.
nsamples
=
len
(
self
.
data
)
...
@@ -202,7 +202,7 @@ class SingleToneSignal(Signal):
...
@@ -202,7 +202,7 @@ class SingleToneSignal(Signal):
tenHarmonicsValues
=
array
(
map
(
lambda
x
:
x
[
2
],
tenHarmonics
))
tenHarmonicsValues
=
array
(
map
(
lambda
x
:
x
[
2
],
tenHarmonics
))
rssHarmonics
=
norm
(
tenHarmonicsValues
)
rssHarmonics
=
norm
(
tenHarmonicsValues
)
output
.
THD
=
-
dB
(
output
.
dft
[
w0index
]
/
rssHarmonics
)
output
.
THD
=
-
dB
(
output
.
dft
[
int
(
w0index
)
]
/
rssHarmonics
)
# we need the avg of HDs
# we need the avg of HDs
avgHarmonics
=
mean
(
tenHarmonicsValues
)
avgHarmonics
=
mean
(
tenHarmonicsValues
)
...
@@ -220,11 +220,11 @@ class SingleToneSignal(Signal):
...
@@ -220,11 +220,11 @@ class SingleToneSignal(Signal):
noiseMask
=
array
(
ones
(
len
(
output
.
dft
)))
noiseMask
=
array
(
ones
(
len
(
output
.
dft
)))
noiseMask
[
0
]
=
0
noiseMask
[
0
]
=
0
noiseMask
[
w0index
]
=
0
noiseMask
[
int
(
w0index
)
]
=
0
noiseMask
[
-
w0index
]
=
0
noiseMask
[
-
int
(
w0index
)
]
=
0
for
i
in
thindex
:
noiseMask
[
int
(
i
)]
=
0
for
i
in
thindex
:
noiseMask
[
int
(
i
)]
=
0
noise
=
where
(
noiseMask
,
self
.
data
,
0
)
noise
=
where
(
noiseMask
,
output
.
dft
,
0
)
output
.
noisePower
=
(
norm
(
noise
)
**
2
)
/
self
.
nsamples
output
.
noisePower
=
(
norm
(
noise
)
**
2
)
/
self
.
nsamples
# SNR
# SNR
...
@@ -242,11 +242,11 @@ class SingleToneSignal(Signal):
...
@@ -242,11 +242,11 @@ class SingleToneSignal(Signal):
output
.
ENOB
=
(
output
.
SINAD
-
1.76
+
factor
)
/
6.02
output
.
ENOB
=
(
output
.
SINAD
-
1.76
+
factor
)
/
6.02
# SFDR - should I use dB(x) instead of 10log10 ?
# SFDR - should I use dB(x) instead of 10log10 ?
output
.
maxPeak
=
10
*
log10
(
output
.
dft
[
w0index
])
output
.
maxPeak
=
10
*
log10
(
output
.
dft
[
int
(
w0index
)
])
secondPeak
=
max
(
thvalues
)
secondPeak
=
max
(
thvalues
)
output
.
secondPeak
=
10
*
log10
(
secondPeak
)
output
.
secondPeak
=
10
*
log10
(
secondPeak
)
output
.
SFDR
=
10
*
log10
(
output
.
dft
[
w0index
]
/
secondPeak
)
output
.
SFDR
=
10
*
log10
(
output
.
dft
[
int
(
w0index
)
]
/
secondPeak
)
return
output
return
output
...
...
SignalProcessing/WindowedSignal.py
View file @
613f9895
...
@@ -33,11 +33,11 @@ class WindowedSignal:
...
@@ -33,11 +33,11 @@ class WindowedSignal:
return
data
return
data
def
harmonicPeaksGenerator
(
self
,
start
,
end
):
def
harmonicPeaksGenerator
(
self
,
start
,
end
):
indexes
=
(
self
.
adjust
(
x
*
self
.
w0index
,
self
.
nsamples
-
1
)
for
x
in
xrange
(
start
,
end
))
indexes
=
(
self
.
adjust
(
x
*
int
(
self
.
w0index
)
,
self
.
nsamples
-
1
)
for
x
in
xrange
(
start
,
end
))
return
((
i
,
self
.
ratio
*
i
,
self
.
dft
[
i
])
for
i
in
indexes
)
return
((
i
,
self
.
ratio
*
i
,
self
.
dft
[
i
])
for
i
in
indexes
)
def
logHarmonicPeaksGenerator
(
self
,
start
,
end
):
def
logHarmonicPeaksGenerator
(
self
,
start
,
end
):
indexes
=
(
self
.
adjust
(
x
*
self
.
w0index
,
self
.
nsamples
-
1
)
for
x
in
xrange
(
start
,
end
))
indexes
=
(
self
.
adjust
(
x
*
int
(
self
.
w0index
)
,
self
.
nsamples
-
1
)
for
x
in
xrange
(
start
,
end
))
return
((
i
,
self
.
ratio
*
i
,
self
.
ldft
[
i
])
for
i
in
indexes
)
return
((
i
,
self
.
ratio
*
i
,
self
.
ldft
[
i
])
for
i
in
indexes
)
...
...
qtGUI/MainWindow.py
View file @
613f9895
...
@@ -322,8 +322,6 @@ class MainWindow(QMainWindow):
...
@@ -322,8 +322,6 @@ class MainWindow(QMainWindow):
print
'Data fetch complete, elaboration is beginning'
print
'Data fetch complete, elaboration is beginning'
print
self
.
wave
.
getType
()
if
self
.
chain
in
(
'adc'
,
'file'
):
if
self
.
chain
in
(
'adc'
,
'file'
):
self
.
decision
=
self
.
modes
[
self
.
ui
.
modeBox
.
currentIndex
()][
1
]
self
.
decision
=
self
.
modes
[
self
.
ui
.
modeBox
.
currentIndex
()][
1
]
else
:
else
:
...
@@ -382,7 +380,7 @@ class MainWindow(QMainWindow):
...
@@ -382,7 +380,7 @@ class MainWindow(QMainWindow):
self
.
updateTT
()
self
.
updateTT
()
def
fetchFile
(
self
):
def
fetchFile
(
self
):
return
readFile
(
self
.
file
N
ame
)
return
readFile
(
self
.
file
n
ame
)
def
fetchSynth
(
self
):
def
fetchSynth
(
self
):
self
.
frequencies
=
frequencies
=
self
.
fcCreateList
()
self
.
frequencies
=
frequencies
=
self
.
fcCreateList
()
...
...
qtGUI/ModuleSelector.py
View file @
613f9895
...
@@ -66,7 +66,7 @@ class ModuleSelector(QDialog):
...
@@ -66,7 +66,7 @@ class ModuleSelector(QDialog):
if
params
[
key
][
3
]
==
'file'
:
if
params
[
key
][
3
]
==
'file'
:
fileName
=
str
(
QFileDialog
.
getOpenFileName
(
self
,
caption
=
"Select device"
,
directory
=
'/dev'
,
filter
=
"*"
))
fileName
=
str
(
QFileDialog
.
getOpenFileName
(
self
,
caption
=
"Select device"
,
directory
=
'/dev'
,
filter
=
"*"
))
if
fileName
!=
""
:
if
fileName
!=
""
:
item
.
setText
(
1
,
file
n
ame
)
item
.
setText
(
1
,
file
N
ame
)
return
return
...
...
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