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
4e9f466b
Commit
4e9f466b
authored
Sep 01, 2011
by
Federico Asara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sinefit4 has an iteration limit.
parent
70b19910
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
Sinefit.py
SignalProcessing/Sinefit.py
+7
-3
No files found.
SignalProcessing/Sinefit.py
View file @
4e9f466b
...
...
@@ -32,7 +32,7 @@ def doubleSinefit3(samples, sample_t, w0, w1):
x0
=
(
D0T
*
D0
)
.
I
*
D0T
*
matrix
(
samples
)
.
T
return
array
(
x0
)
.
reshape
((
5
,))
def
doubleSinefit4matrix
(
samples
,
sample_t
,
w0
,
w1
,
tol
=
1e-
9
):
def
doubleSinefit4matrix
(
samples
,
sample_t
,
w0
,
w1
,
tol
=
1e-
12
):
"""fit a sampled wave to a sine of unknown frequency
This routine implements the algorithm of IEEE 1241, sect. 4.1.4.3.,
...
...
@@ -90,7 +90,7 @@ def sinefit3(samples, sample_t, w0):
x0
=
(
D0T
*
D0
)
.
I
*
D0T
*
matrix
(
samples
)
.
T
return
array
(
x0
)
.
reshape
((
3
,))
def
sinefit4matrix
(
samples
,
sample_t
,
w0
,
tol
=
1e-
7
):
def
sinefit4matrix
(
samples
,
sample_t
,
w0
,
tol
=
1e-
12
,
imax
=
50
):
"""fit a sampled wave to a sine of unknown frequency
This routine implements the algorithm of IEEE 1241, sect. 4.1.4.3.,
...
...
@@ -107,7 +107,10 @@ def sinefit4matrix(samples, sample_t, w0, tol=1e-7):
a0
,
b0
,
c0
=
sinefit3
(
samples
,
sample_t
,
w0
)
deltaw0
=
0
while
True
:
#while True:
for
i
in
xrange
(
imax
):
print
'Sinefit:'
,
i
w0
+=
deltaw0
n
=
samples
.
size
t
=
arange
(
n
)
*
sample_t
...
...
@@ -120,6 +123,7 @@ def sinefit4matrix(samples, sample_t, w0, tol=1e-7):
a0
,
b0
,
c0
,
deltaw0
=
x0
if
abs
(
deltaw0
/
w0
)
<
tol
:
return
(
w0
+
deltaw0
,
a0
,
b0
,
c0
)
return
(
w0
+
deltaw0
,
a0
,
b0
,
c0
)
def
sinefit4scipy
(
data
,
Ts
,
w0
,
*
args
,
**
kwargs
):
# Target function
...
...
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