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
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
misc
adc-testing
Commits
ba3e3993
Commit
ba3e3993
authored
Jan 21, 2011
by
Juan David González Cobas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add windowing computations and window definitions
parent
9d3daa44
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
12 deletions
+18
-12
FFTSignal.py
FFTSignal.py
+13
-10
Signal.py
Signal.py
+5
-2
No files found.
FFTSignal.py
View file @
ba3e3993
from
numpy
import
*
class
FFTSignal
(
object
):
"""a representation of a frequency-domain signal
"""
WINDOW_TYPES
=
[
'RECTANGULAR'
,
'HANN'
,
'HAMMING'
,
'TUKEY'
,
'COSINE'
,
'LANCZOS'
,
'BARTLETT_HANN'
]
window_function
=
{
'No window'
:
ones
,
'BARTLETT'
:
bartlett
,
'BLACKMAN'
:
blackman
,
'HAMMING'
:
hamming
,
'HANNING'
:
hanning
,
'KAISER'
:
kaiser
,
}
WINDOW_TYPES
=
window_function
.
keys
()
def
__init__
(
self
,
fft
,
dB
=
None
,
time_domain
=
None
):
"""initialize an FFTSignal object
...
...
Signal.py
View file @
ba3e3993
...
...
@@ -118,7 +118,7 @@ class Signal(object):
inl
=
cumsum
(
dnl
)
return
inl
,
max
(
abs
(
inl
))
def
FFT
(
self
,
navg
,
window
):
def
FFT
(
self
,
navg
=
1
,
window
=
'No window'
):
"""Compute the amplitudes (in dB) of the FFT of signal, averaging navg
slices of it and applying window to it
...
...
@@ -127,7 +127,10 @@ class Signal(object):
returns: an FFTSignal object
"""
return
FFTSignal
(
self
.
data
,
1
,
1
)
print
'using window '
,
window
win
=
FFTSignal
.
window_function
[
window
](
self
.
nsamples
)
dft
=
10
*
log10
(
abs
(
fft
.
rfft
(
self
.
data
*
win
)))
return
FFTSignal
(
dft
,
dB
=
True
,
time_domain
=
self
.
data
)
def
makesine
(
samples
,
periods
,
bits
,
amplitude
=
1
,
noise
=
0
):
...
...
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