Commit a219460c authored by Thomas Bruns's avatar Thomas Bruns
Browse files

reimplemented 'progressive' mode in seq_multi... stuff

parent 280751fa
......@@ -823,7 +823,7 @@ def PR_MultiSine(
) # frequency series, sample rate, sample timestamps, waveform
def seq_multi_threeparam_Dmatrix(f,t,periods=1):
def seq_multi_threeparam_Dmatrix(f,t,periods=1, progressive=True):
"""
Fit a multi-sinus-signal in slices in one go.
......@@ -854,7 +854,10 @@ def seq_multi_threeparam_Dmatrix(f,t,periods=1):
# Designmatrix for sin/cos
for fi, omi in zip(f,2*np.pi*f):
Nri = 0 # counter for the current row index
tau = 1/fi*periods # slice length in seconds
if progressive:
tau = np.ceil(f[0]/fi*periods)/fi # approximately same abs. slice length for all fi
else:
tau = 1/fi*periods # slice length in seconds for periods of fi
t_sl = np.array_split(t,np.ceil(T/tau)) # array of slices of sample times
fr = fr + [fi]*len(t_sl) # len(t_sl) times frequency fi in Design matrix
for ti in t_sl: # loop over slices fo one frequncy
......@@ -883,7 +886,7 @@ def seq_multi_threeparam_Dmatrix(f,t,periods=1):
D = coo_matrix((data,(ri,ci)),shape=(len(t),col)).tocsr()
return np.array(fr), D
def seq_multi_threeparsinefit(f,y,t,periods=1, D_fr=None, abc0=None):
def seq_multi_threeparsinefit(f,y,t,periods=1, D_fr=None, abc0=None, progressive=True):
"""
performs a simultanius, sliced three-parameter fit on a multisine signal y
......@@ -909,7 +912,7 @@ def seq_multi_threeparsinefit(f,y,t,periods=1, D_fr=None, abc0=None):
"""
if D_fr is None:
fr, D = seq_multi_threeparam_Dmatrix(f,t,periods) # calculate the design matrix (as sparse matrix)
fr, D = seq_multi_threeparam_Dmatrix(f,t,periods, progressive=progressive) # calculate the design matrix (as sparse matrix)
else:
D = D_fr[0]
fr = D_fr[1]
......@@ -964,7 +967,7 @@ def seq_multi_fourparam_sineFit(f,y,t,periods=1, tol=1.0e-6, n_max=100):
while (np.abs(dw) > tol) and (itr<n_max):
itr += 1
# Designmatrix for three paramsin/cos
fr,D = seq_multi_threeparam_Dmatrix(f, t, periods=periods)
fr,D = seq_multi_threeparam_Dmatrix(f, t, periods=periods, progressive=False)
# initial ab
f_ab_c = seq_multi_threeparsinefit(f, y, t, D_fr=(D,fr))[0]
last_col = np.zeros(len(t))
......
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