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

Bug hunting release

parent 838c6b95
......@@ -47,11 +47,11 @@ def sinewave(f,a,phi, ti, offset=0, noise=0, absnoise=0, drift=0, ampdrift=0):
return s
def fm_counter_sine(fm, f,a,phi, ti, offset=0, noise=0, absnoise=0, drift=0, ampdrift=0):
def fm_counter_sine(fm, f,x,phi, ti, offset=0, noise=0, absnoise=0, drift=0, ampdrift=0,lamb=633.0e-9):
"""
# calculate counter value of heterodyne signal at \n
carrier freq. fm
a = displacement amplitude
x = displacement amplitude
initial phase phi \n
sample times t_i \n
bias or offset (default 0)\n
......@@ -59,17 +59,18 @@ def fm_counter_sine(fm, f,a,phi, ti, offset=0, noise=0, absnoise=0, drift=0, amp
absnoise as a additive noise component \n
drift as multiples of amplitude per duration in drifting zero \n
ampdrift as a drifting amplitude given as multiple of amplitude \n
lamb as wavelength of Laser
"""
Tau = ti[-1] - ti[0]
n = 0
if noise != 0:
n = a*noise*sp.randn(len(ti))
n = x*noise*sp.randn(len(ti))
if absnoise != 0:
n = n + absnoise*sp.randn(len(ti))
d = drift*a/Tau
d = drift*x/Tau
s = 2/633e-9 * (a*(1+ampdrift/Tau*ti)*sp.sin(2*sp.pi*f * ti - phi) + n +d*ti + offset)
s = 2/lamb * (x*(1+ampdrift/Tau*ti)*sp.sin(2*sp.pi*f * ti - phi) + n +d*ti + offset)
s = sp.floor(s+fm*ti)
return s
......@@ -255,18 +256,12 @@ def seq_threeparcounterfit(y,t,f0, diff=False):
"""
Tau = 1.0/f0
dt = t[1]-t[0]
N = sp.floor(Tau/dt) ## samples per section
M = sp.floor(t.size/N) ## number of sections or periods
N = int(sp.floor(Tau/dt)) ## samples per section
M = int(sp.floor(t.size/N)) ## number of sections or periods
if diff :
d = sp.diff(y)
d = d - sp.mean(d)
y = sp.hstack((0,sp.cumsum(d)))
else:
slope = (y[M*N-1]-y[0])/(M*N) # slope of linear increment
y = y-slope*sp.linspace(0,t.size-1,t.size) # removal of linear increment
remove_counter_carrier(y, diff=diff)
abc = sp.zeros((M,3))
abc = sp.zeros((M,4))
for i in range(int(M)):
ti = t[i*N:(i+1)*N]
......@@ -275,6 +270,20 @@ def seq_threeparcounterfit(y,t,f0, diff=False):
abc[i,:] = threeparsinefit_lin(yi,ti,f0)
return abc ## matrix of all fit vectors per period
def remove_counter_carrier(y, diff=False):
"""
remove the linear increase in the counter signal
generated by the carrier frequency of a heterodyne signal\n
y vector of samples of the signal
"""
if diff :
d = sp.diff(y)
d = d - sp.mean(d)
y = sp.hstack((0,sp.cumsum(d)))
else:
slope = (y[1]-y[0]) # slope of linear increment
y = y-slope*sp.linspace(0,1,len(y),endpoint=False) # removal of linear increment
return y
# calculate displacement and acceleration to the same analytical s(t)
# Bsp: fm = 2e7, f=10, s0=0.15, phi0=sp.pi/3, ti, drift=0.03, ampdrift=0.03,thd=[0,0.02,0,0.004]
......
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