Commit 15112d3c authored by Thomas Bruns's avatar Thomas Bruns
Browse files

changed sine and cosine positions for consistency

parent 1b535791
......@@ -89,7 +89,7 @@ def threeparsinefit(y,t,f0):
"""
w0 = 2*sp.pi*f0
a = sp.array([sp.sin(w0*t),sp.cos(w0*t),sp.ones(t.size)])
a = sp.array([sp.cos(w0*t),sp.sin(w0*t),sp.ones(t.size)])
abc = la.lstsq(a.transpose(),y)
return abc[0][0:3] ## fit vector a*sin+b*cos+c
......@@ -107,7 +107,7 @@ def threeparsinefit_lin(y,t,f0):
"""
w0 = 2*sp.pi*f0
a = sp.array([sp.sin(w0*t),sp.cos(w0*t),sp.ones(t.size),t,sp.ones(t.size)])
a = sp.array([sp.cos(w0*t),sp.sin(w0*t),sp.ones(t.size),t,sp.ones(t.size)])
abc = la.lstsq(a.transpose(),y)
return abc[0][0:4] ## fit vector
......@@ -118,7 +118,7 @@ def calc_threeparsine(abc,t,f0):
return y = abc[0]*sin(2*pi*f0*t) + abc[1]*cos(2*pi*f0*t) + abc[2]
"""
w0 =2*sp.pi*f0
return abc[0]*sp.sin(w0*t)+abc[1]*sp.cos(w0*t)+abc[2]
return abc[0]*sp.cos(w0*t)+abc[1]*sp.sin(w0*t)+abc[2]
def amplitude(abc):
......@@ -196,10 +196,10 @@ def fourparsinefit(y,t,f0, tol=1.0e-7, nmax=1000):
err = 1
i = 0
while ((err > tol) and (i<nmax)):
D = sp.array([sp.sin(w*t),
sp.cos(w*t),
D = sp.array([sp.cos(w*t),
sp.sin(w*t),
sp.ones(t.size),
abcd[0]*t*sp.cos(w*t)-abcd[1]*t*sp.sin(w*t)
(-1.0)*abcd[0]*t*sp.sin(w*t)+abcd[1]*t*sp.cos(w*t)
])
abcd = (la.lstsq(D.transpose(),y))[0]
......@@ -217,7 +217,7 @@ def calc_fourparsine(abcf,t):
return y = abc[0]*sin(2*pi*f0*t) + abc[1]*cos(2*pi*f0*t) + abc[2]
"""
w0 =2*sp.pi*abcf[3]
return abcf[0]*sp.sin(w0*t)+abcf[1]*sp.cos(w0*t)+abcf[2]
return abcf[0]*sp.cos(w0*t)+abcf[1]*sp.sin(w0*t)+abcf[2]
"""
from octave ...
......@@ -302,7 +302,7 @@ def multi_threeparsinefit(y,t,f0): # fo vector of frequencies
# set up design matrix
a = sp.ones(len(t))
for w in w0:
a = sp.vstack((sp.vstack((sp.sin(w*t), sp.cos(w*t))),a))
a = sp.vstack((sp.vstack((sp.cos(w*t), sp.sin(w*t))),a))
abc = sp.linalg.lstsq(a.transpose(), y)
return abc[0] ## fit vector a*sin+b*cos+c
......@@ -338,7 +338,7 @@ def multi_waveform_abc(f,abc,t):
"""
ret = 0.0*t +abc[-1] # bias
for fi,a,b in zip(f,abc[0::2],abc[1::2]):
ret = ret+a*sp.sin(2*sp.pi*fi*t)+b*sp.cos(2*sp.pi*fi*t)
ret = ret+a*sp.cos(2*sp.pi*fi*t)+b*sp.sin(2*sp.pi*fi*t)
return ret
##################################
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment