Skip to content
Snippets Groups Projects
Commit 14df5e40 authored by Rana's avatar Rana
Browse files

trying to add AC swept-sine sensing matrix...

parent 1c851abd
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
# DRMI ISC Designer
## Use Finesse to optimize the LSC error signals for the DRMI
%% Cell type:code id: tags:
``` python
%matplotlib notebook
from pykat import finesse
from pykat.commands import *
import pykat.external.peakdetect as peak
import pykat.ifo.aligo as aligo
import pykat.ifo.aligo.plot as aligoplt
import gwinc as gwinc
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import pandas as pd
pykat.init_pykat_plotting(dpi=72)
#for animations:
from matplotlib import animation, rc
from IPython.display import HTML
plt.style.use('dark_background')
# Update the matplotlib configuration parameters:
plt.rcParams.update({'text.usetex': False,
'lines.linewidth': 4,
'font.family': 'sans-serif',
'font.sans-serif': 'Verdana',
'font.size': 14,
'xtick.direction': 'in',
'ytick.direction': 'in',
'xtick.labelsize': 'small',
'ytick.labelsize': 'small',
'axes.labelsize': 'medium',
'axes.titlesize': 'medium',
'axes.grid.axis': 'both',
'axes.grid.which': 'both',
'axes.grid': True,
'grid.color': 'xkcd:Sea Green',
'grid.alpha': 0.3,
'lines.markersize': 12,
'legend.borderpad': 0.2,
'legend.fancybox': True,
'legend.fontsize': 'small',
'legend.framealpha': 0.8,
'legend.handletextpad': 0.5,
'legend.labelspacing': 0.33,
'legend.loc': 'best',
'figure.figsize': ((14, 8)),
'savefig.dpi': 140,
'savefig.bbox': 'tight',
'pdf.compression': 9})
def prettySensingMatrix(self, cmap = 'jet'):
# https://pandas.pydata.org/pandas-docs/stable/user_guide/style.html
# Set colormap equal to seaborns light green color palette
cmap = plt.get_cmap(cmap)
# Set CSS properties for th elements in dataframe
th_props = [
('font-size', '24'),
('text-align', 'center'),
('font-weight', 'bold'),
('color', 'xkcd:White'),
('background-color', 'xkcd:Black')
]
# Set CSS properties for td elements in dataframe
td_props = [
('font-size', '24')
]
# Set table styles
styles = [
dict(selector="th", props=th_props),
dict(selector="td", props=td_props)
]
self = (self.style
.background_gradient(cmap=cmap, subset=list(self))
.set_caption('Interferometer Sensing Matrix')
.format("{:0.3g}")
.set_table_styles(styles))
return self
```
%% Cell type:markdown id: tags:
## Outline
1. Get IFO params, build Finesse model
1. Get the LSC sensing matrix
1. Make a radar plot
%% Cell type:code id: tags:
``` python
aLIGO = aligo.make_kat()
aLIGO.maxtem = -1 #USE PLANE WAVES MODEL FIRST (speed, complexity...)
TT = 0.325 #better match to sites
aLIGO.SRM.setRTL(1 - TT-aLIGO.SRM.L, TT, aLIGO.SRM.L)
# DRMI Only
#aLIGO.ETMX.T = 1 - aLIGO.ETMX.L
#aLIGO.ETMY.T = 1 - aLIGO.ETMY.T
aLIGO = aligo.setup(aLIGO)
kat = aLIGO.deepcopy() # Make a copy of the model
```
%% Cell type:code id: tags:
``` python
DOFs = ["DARM", "CARM", "PRCL", "SRCL", "MICH"]
# Add some detectors in to measure the transfer function
# from each degree of freedom specified above to each one
# of these outputs. Here we pick either the I or Q quadrature
detectors = [
kat.IFO.REFL_f1.add_transfer('I'),
kat.IFO.REFL_f1.add_transfer('Q'),
kat.IFO.REFL_f2.add_transfer('I'),
kat.IFO.REFL_f2.add_transfer('Q'),
kat.IFO.POP_f1.add_transfer('I'),
kat.IFO.POP_f1.add_transfer('Q'),
kat.IFO.POP_f2.add_transfer('I'),
kat.IFO.POP_f2.add_transfer('Q'),
kat.IFO.AS_f2.add_transfer('I'),
kat.IFO.AS_f2.add_transfer('Q'),
kat.IFO.AS_DC.add_transfer()
]
# what frequency is this measured at ???
sens = kat.IFO.sensing_matrix(DOFs, detectors)
```
%% Cell type:markdown id: tags:
### Set the demod phases
#### put CARM out of the Q phase everywhere
##### this doesn't make much sense until the CARM loop is closed with high gain
%% Cell type:code id: tags:
``` python
aLIGO.IFO.REFL_f1.phase += 180/np.pi * np.arctan2(sens['REFL_f1_Q_TF']['CARM'], sens['REFL_f1_I_TF']['CARM'])
aLIGO.IFO.REFL_f2.phase += 180/np.pi * np.arctan2(sens['REFL_f2_Q_TF']['CARM'], sens['REFL_f2_I_TF']['CARM'])
aLIGO.IFO.POP_f1.phase += 180/np.pi * np.arctan2( sens['POP_f1_Q_TF']['CARM'], sens['POP_f1_I_TF']['CARM'])
aLIGO.IFO.POP_f2.phase += 180/np.pi * np.arctan2( sens['POP_f2_Q_TF']['CARM'], sens['POP_f2_I_TF']['CARM'])
aLIGO.IFO.AS_f2.phase += 180/np.pi * np.arctan2( sens['AS_f2_Q_TF']['CARM'], sens['AS_f2_I_TF']['CARM'])
aLIGO = aligo.setup(aLIGO)
kat = aLIGO.deepcopy() # Make a copy of the model
detectors = [
kat.IFO.REFL_f1.add_transfer('I'),
kat.IFO.REFL_f1.add_transfer('Q'),
kat.IFO.REFL_f2.add_transfer('I'),
kat.IFO.REFL_f2.add_transfer('Q'),
kat.IFO.POP_f1.add_transfer('I'),
kat.IFO.POP_f1.add_transfer('Q'),
kat.IFO.POP_f2.add_transfer('I'),
kat.IFO.POP_f2.add_transfer('Q'),
kat.IFO.AS_f2.add_transfer('I'),
kat.IFO.AS_f2.add_transfer('Q'),
kat.IFO.AS_DC.add_transfer()
]
sens = kat.IFO.sensing_matrix(DOFs, detectors)
prettySensingMatrix(sens, cmap = 'Spectral')
```
%% Cell type:markdown id: tags:
## Get the AC Sensing Matrix:
### Drive the DoFs, get the complex demod outputs
#### make some Bode plots
%% Cell type:code id: tags:
``` python
kat = aLIGO.deepcopy()
peedees = []
for n in detectors:
peedees.append(n[:-3])
kat.parse("""
const f1 9099471.0
const f2 5 * $f1
%%% FTblock errsigs
pd0 AS_DC nAS
pd1 REFL_f1_I $f1 96.27427245747704 nREFL
pd1 REFL_f1_Q $f1 6.27427245747704 nREFL
pd1 REFL_f2_I $f2 96.27427245747704 nREFL
pd1 REFL_f2_Q $f2 6.27427245747704 nREFL
pd1 POP_f1_I $f1 -57.86313647329267 nPOP
pd1 POP_f1_Q $f1 211.11868103763894 nPOP
pd1 POP_f2_I $f2 -57.86313647329267 nPOP
pd1 POP_f2_Q $f2 211.11868103763894 nPOP
pd1 AS_f1_I $f1 -57.86313647329267 nAS
pd1 AS_f1_Q $f1 211.11868103763894 nAS
pd1 AS_f2_I $f2 -57.86313647329267 nAS
pd1 AS_f2_Q $f2 211.11868103763894 nAS
fsig sig1 LX 1 0 1
fsig sig1 LY 1 180 1
xaxis sig1 f log 1 100k 1000
scale meter
""")
out = kat.run()
# make Bode plots of the LSC Sensing Matrix
fig, ax = plt.subplots(2, 1, sharex=True, figsize=(10, 9))
for d in range(len(peedees)):
v = peedees[d]
ax[0].loglog(out.x, np.abs(out[v]), label=v)
ax[1].semilogx(out.x, np.angle(out[v], deg=True), label=v)
#ax[0].loglog(f_a, np.abs(Em), color='xkcd:Purple Blue', label='Lower Sideband', ls='--')
#ax[0].set_xlabel(r'Frequency [Hz]')
ax[0].set_ylabel(r'Response [W/m ?]')
ax[0].legend(ncol=3)
#ax[0].grid(True, which='Both')
ax[0].set_title('Bode Plot: Transfer function for modulation of the end mirror')
#ax[1].semilogx(f_a, np.angle(Em, deg=True), color='xkcd:Purple Blue', ls='--')
ax[1].set_xlabel(r'Frequency [Hz]')
ax[1].set_ylabel(r'Phase [deg]')
ax[1].set_yticks(np.arange(-180, 181, 60))
#ax[1].grid()
plt.show()
```
%% Cell type:code id: tags:
``` python
print(aLIGO)
```
%% Cell type:code id: tags:
``` python
peedees
```
%% Cell type:code id: tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment