Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aligo_finesse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
finesse
aligo_finesse
Commits
4422e001
Commit
4422e001
authored
8 years ago
by
Anna Green
Browse files
Options
Downloads
Patches
Plain Diff
added Plot_DOFs tool to zero_locks, v similar to the one in awc_tools, updated to use ifo functions
parent
4359ae37
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
playground/anna/file_review/zero_locks.py
+87
-20
87 additions, 20 deletions
playground/anna/file_review/zero_locks.py
with
87 additions
and
20 deletions
playground/anna/file_review/zero_locks.py
+
87
−
20
View file @
4422e001
...
...
@@ -8,6 +8,8 @@ import matplotlib.pyplot as plt
import
matplotlib.cm
as
cm
import
pykat
import
numpy
as
np
from
scipy.interpolate
import
interp1d
import
matplotlib.gridspec
as
gridspec
import
AG_tools
as
ag
...
...
@@ -34,6 +36,13 @@ DOFAccuracy = {#,abs_accuracy,rel_accuracy
"
MICH
"
:
[
10e-11
,
1e-7
],
"
SRCL
"
:
[
10e-11
,
1e-7
]}
DOFPlotting
=
{
#scan_range,
"
CARM
"
:
[
0.001
],
"
DARM
"
:
[
0.01
],
"
PRCL
"
:
[
0.1
],
"
MICH
"
:
[
0.5
],
"
SRCL
"
:
[
1
]}
def
main
():
plt
.
close
(
"
all
"
)
print
(
"""
...
...
@@ -57,14 +66,15 @@ def main():
# ## initial tuning
# zero_locks(kat)
# power_ratios(kat)
plot_DOFs
(
kat
,
xscale
=
10
)
# ag.plot_QNS(kat,plotit=True,show=True,unlock=True)
#
# ## applying offset
OffS
=
DC_offset
(
kat
,
debug
=
True
,
apply
=
True
)
#
OffS = DC_offset(kat,debug=True,apply=True)
# power_ratios(kat)
# ag.plot_QNS(kat,plotit=True,show=True,unlock=True)
make_locks
(
kat
,
DCoffset
=
OffS
)
#
make_locks(kat,DCoffset=OffS)
def
zero_locks
(
_kat
,
pretune_precision
=
1e-5
):
...
...
@@ -229,8 +239,16 @@ def DC_offset(_kat,debug=False,apply=False):
# Y=out["P_DC_AS"] #*1e3
Y
=
(
np
.
abs
(
out
[
"
AS0
"
])
**
2
)
*
1e3
#converting to power in mW
idxs
=
[]
f1
=
interp1d
(
Y
,
X
)
f2
=
interp1d
(
X
,
Y
)
try
:
EMX_out
=
f1
(
AS_power
)
pow_out
=
f2
(
AS_power
)
except
:
print
(
"
\n
Interpolation error, using secondary method.
"
)
idxs
=
[]
for
y
in
range
(
len
(
Y
)
-
1
):
if
Y
[
y
]
==
AS_power
:
idxs
.
append
(
y
)
...
...
@@ -238,18 +256,14 @@ def DC_offset(_kat,debug=False,apply=False):
idxs
.
append
(
y
+
1
)
# so we always choose the slightly higher AS power. unnessary if single-sided seach.
elif
Y
[
y
+
1
]
<=
AS_power
and
Y
[
y
]
>=
AS_power
:
#below phi=0
idxs
.
append
(
y
)
if
len
(
idxs
)
!=
1
:
raise
pkex
.
BasePyKatException
(
"
Zero or multiple tuning options found. Check x limits and target power.
"
)
EMX_out
=
X
[
idxs
[
0
]]
EMY_out
=
-
X
[
idxs
[
0
]]
pow_out
=
Y
[
idxs
[
0
]]
if
apply
==
True
:
_kat
.
ETMX
.
phi
=
EMX_out
_kat
.
ETMY
.
phi
=
EM
Y
_out
_kat
.
ETMY
.
phi
=
-
EM
X
_out
print
(
"""
AS carrier power found = {0:.4g}mW
...
...
@@ -257,7 +271,7 @@ def DC_offset(_kat,debug=False,apply=False):
new tunings:
ETMX: {1} deg
ETMY: {2} deg
"""
.
format
(
pow_out
,
EMX_out
,
EM
Y
_out
))
"""
.
format
(
pow_out
,
EMX_out
,
(
-
EM
X
_out
))
)
if
debug
==
True
:
plt
.
semilogy
(
X
,
Y
)
...
...
@@ -495,6 +509,59 @@ def tune_via_DARM(_kat,_optic,xlimits=[-100,100],steps=200,debug=False,freq=0.1)
return
X_out
,
stepsize
def
plot_DOFs
(
_kat
,
xscale
=
1
,
steps
=
200
):
print
(
"
Plotting Error signals
"
)
_kat
=
_kat
.
deepcopy
()
_kat
.
verbose
=
False
_kat
.
removeBlock
(
'
locks
'
)
plt
.
figure
(
figsize
=
(
10
,
8
))
gs
=
gridspec
.
GridSpec
(
3
,
2
)
ax
=
[
plt
.
subplot
(
gs
[
0
,
0
]),
plt
.
subplot
(
gs
[
0
,
1
]),
plt
.
subplot
(
gs
[
1
,
0
]),
plt
.
subplot
(
gs
[
1
,
1
]),
plt
.
subplot
(
gs
[
2
,:])]
sp
=
0
for
_dof
in
DOFs
:
kat
=
_kat
.
deepcopy
()
info
=
DOFInfo
[
_dof
]
demod_freq
=
info
[
0
]
demod_phase
=
info
[
1
]
optics
=
ifo
.
make_list_copy
(
info
[
2
])
factors
=
ifo
.
make_list_copy
(
info
[
3
])
# sig_phases = ifo.make_list_copy(info[4])
node
=
info
[
5
]
detname
=
"
{0}_Err
"
.
format
(
_dof
)
kat
.
parseCommands
(
"
pd1 {0} {1} {2} {3}
"
.
format
(
detname
,
demod_freq
,
demod_phase
,
node
))
xlim
=
DOFPlotting
[
_dof
][
0
]
*
xscale
out
=
ifo
.
scan_optics
(
kat
,
optics
,
factors
,
xlimits
=
[
-
xlim
,
xlim
],
steps
=
steps
,
relative
=
True
)
f1
=
interp1d
(
out
[
detname
],
out
.
x
)
f2
=
interp1d
(
out
.
x
,
out
[
detname
])
try
:
title
=
"
0-Crossing = {0:.3g} deg
\n
offset (at 0) = {1:.3g}
"
.
format
(
float
(
f1
(
0
)),
float
(
f2
(
0
)))
#ugly line with new str formatting, worked with %.3g...
except
:
title
=
None
#"Interpolation error"
ax
[
sp
].
ticklabel_format
(
style
=
"
sci
"
,
scilimits
=
(
1
,
2
))
ax
[
sp
].
set_title
(
title
,
fontsize
=
10
)
ax
[
sp
].
plot
(
out
.
x
,
out
[
detname
])
ax
[
sp
].
set_xlim
(
out
.
x
.
min
(),
out
.
x
.
max
())
ax
[
sp
].
set_xlabel
(
_dof
+
"
[Deg]
"
)
ax
[
sp
].
set_ylabel
(
detname
)
ax
[
sp
].
grid
()
sp
+=
1
plt
.
tight_layout
()
plt
.
show
()
def
phi_tuning
(
deltam
,
lambda0
=
1064e-9
):
return
(
deltam
/
lambda0
)
*
360
...
...
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