Skip to content
Snippets Groups Projects
Commit 1bd94e77 authored by Anna Green's avatar Anna Green
Browse files

adapted tools from ifo.py to plot error signals and test locks in variable configurations

parent e821ae22
No related branches found
No related tags found
No related merge requests found
from pykat import finesse
from pykat.commands import *
import pykat.gw_detectors.ifo as ifo
import matplotlib.pyplot as plt
from tune_tools import *
def main():
########################
katfile = "DRMi"
########################
# LIGO1 = ifo.aLIGO(debug=True)
LIGO1 = ifo.aLIGO(debug=True)
kat = finesse.kat()
kat.verbose=False
kat.loadKatFile("raw/PI-"+katfile+".kat") #locks fail. compare to original aLIGO kat.
########################
katfile = "DRMi"
kat.loadKatFile("raw/PI-"+katfile+".kat")
# kat = LIGO1.kat
########################
kat.maxtem = 0#'off'
kat.phase = 2
kat.ETMX.mass = 1e9 #necessary for lock drags to work...
kat.ETMY.mass = 1e9
kat.ITMX.mass = 1e9
kat.ITMY.mass = 1e9
################ make locks ####################
DRkat = DRMi_tuning(kat)
# print(DRkat)
kat.maxtem = 'off'#0
kat.phase = 2
################################################
################# test #####################
DRkat = DRMi_tuning(kat,debug=True) #locks fail. compare to testLIGO.
print(DRkat)
# kat.verbose=True
dofs = [LIGO1.DARM, LIGO1.CARM, LIGO1.PRCL, LIGO1.SRCL, LIGO1.MICH]
plot_errs(DRkat,dofs,xlimits=[-1e-2, 1e-2])
## make own of these so not stuck with DRMi and locked
LIGO1.plot_error_signals(DRkat, xlimits=[-1e-2, 1e-2])
locks = ["ETMX_lock", "ETMY_lock", "PRCL_lock", "MICH_lock", "ITMY_lock", "SRCL_lock"]
test_locks(DRkat,locks)
test_locks(DRkat,locks,PRC=True)
################################################
################# save ######################
# kat.saveScript("tuned/PI-"+katfile+".kat")
def test_locks(_kat,locks):
kat = _kat.deepcopy()
# test lock with BS tuning
code = """
xaxis BS phi lin 0 2 100
yaxis abs
#showiterate -1
"""
kat.parseCommands(code)
out = kat.run()
plt.figure()
ifo.make_list_copy(locks)
for l in locks:
plt.plot(out.x,out[l], label=l)
plt.legend()
plt.show()
# check f1 resonance in PRC
kat = _kat.deepcopy()
LIGO1.check_f1_PRC_resonance(kat)
END = input('press enter to finish and close all plots')#to override auto-closing.
if __name__ == '__main__':
main()
\ No newline at end of file
......@@ -4,6 +4,7 @@ from __future__ import print_function
from __future__ import unicode_literals
import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter
import numpy as np
from pykat import finesse
......@@ -12,12 +13,67 @@ import pykat.gw_detectors.ifo as ifo
LIGO1 = ifo.aLIGO(debug=True)
def DRMi_tuning(_kat,debug=False):
# simplified from Andreas' TestLIGO file
def plot_errs(_kat,dofs=[LIGO1.DARM, LIGO1.CARM, LIGO1.PRCL, LIGO1.SRCL, LIGO1.MICH],xlimits=[-1,1]):
#based on ifo.py, adapted to select dofs
kat = _kat.deepcopy()
kat.verbose=False
kat.noxaxis=True
#remove the lock block if it's present
BlockList = kat._kat__blocks
if 'locks' in BlockList:
kat.removeBlock('locks')
if 'errsigs' in BlockList:
kat.removeBlock('errsigs')
if 'powers' in BlockList:
kat.removeBlock('powers')
#plotting
w = int((len(dofs)+1)/2) #make figure of nice size for number of dofs:
idx=1
fig = plt.figure()
for d in dofs:
ax = fig.add_subplot(w,2,idx)
idx+=1
out = ifo.scan_DOF(kat, d, xlimits = np.multiply(d.scale,xlimits), relative = True)
ax.plot(out.x,out[d.signal_name(kat)])
ax.set_xlim([np.min(out.x), np.max(out.x)])
ax.set_xlabel("{} [deg]".format(d.name))
ax.set_ylabel('{} [W] '.format(d.port.name))
ax.grid()
plt.tight_layout()
plt.show(block=0)
def test_locks(_kat,locks,PRC=False):
# separated from DRMi_tuning
kat = _kat.deepcopy()
if PRC==True:
# check f1 resonance in PRC
kat = _kat.deepcopy()
LIGO1.check_f1_PRC_resonance(kat)
# test lock with BS tuning
code = """
xaxis BS phi lin 0 2 100
yaxis abs
#showiterate -1
"""
kat.parseCommands(code)
out = kat.run()
plt.figure()
ifo.make_list_copy(locks)
for l in locks:
plt.plot(out.x,out[l], label=l)
plt.legend()
plt.show(block=0)
def DRMi_tuning(_kat):
# edited from Andreas' TestLIGO file
kat = _kat.deepcopy()
BlockList = kat._kat__blocks
if 'locks' in BlockList:
kat.removeBlock('locks')
if 'errsigs' in BlockList:
kat.removeBlock('errsigs')
if 'powers' in BlockList:
kat.removeBlock('powers')
#pretuning and DC offset
pretune(kat, verbose=True, debug=False)
......@@ -25,32 +81,13 @@ def DRMi_tuning(_kat,debug=False):
LIGO1.lengths_status(kat)
DCoffset = 20e-12 / kat.lambda0 * 180.0 # 20 pm
LIGO1.set_DC_offset(kat, DCoffset=DCoffset, verbose=True)
LIGO1.plot_error_signals(kat, xlimits=[-1e-2, 1e-2])
#LIGO1.plot_error_signals(kat, xlimits=[-1e-2, 1e-2])
#locks
kat_lock = prepare_locks(kat, verbose=True)
kat_lock.noxaxis = True
kat_lock.verbose = True
out = kat_lock.run()
LIGO1.apply_lock_feedback(kat_lock, out)
if debug==True:
kat_check = kat_lock.deepcopy()
# test lock with BS tuning
code = """
xaxis BS phi lin 0 2 100
yaxis abs
#showiterate -1
"""
kat_check.parseCommands(code)
out = kat_check.run()
plt.figure()
locks = ["ETMX_lock", "ETMY_lock", "PRCL_lock", "MICH_lock", "ITMY_lock", "SRCL_lock"]
for l in locks:
plt.plot(out.x,out[l], label=l)
plt.legend()
plt.show()
# check f1 resonance in PRC
kat_check = kat_lock.deepcopy()
LIGO1.check_f1_PRC_resonance(kat_check)
return kat_lock
def pretune(kat, verbose=False, debug=False):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment