Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
SineTools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Thomas Bruns
SineTools
Commits
eec6362c
Commit
eec6362c
authored
6 years ago
by
Thomas Bruns
Browse files
Options
Downloads
Patches
Plain Diff
Bug hunting release
parent
838c6b95
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SineTools.py
+24
-15
24 additions, 15 deletions
SineTools.py
with
24 additions
and
15 deletions
SineTools.py
+
24
−
15
View file @
eec6362c
...
...
@@ -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]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment