addpath /ligo/svncommon/NbSVN/aligonoisebudget/trunk/Externals/SimulinkNb/Utils/

gps_time = 1214691797;
dt = 1; 
measurements = {'MC1 P', 'MC2 P', 'MC3 P', 'MC1 Y', 'MC2 Y', 'MC3 Y'};
A2L_chans = {'H1:SUS-MC1_M3_DRIVEALIGN_P2L_GAIN', 'H1:SUS-MC2_M3_DRIVEALIGN_P2L_GAIN', 'H1:SUS-MC3_M3_DRIVEALIGN_P2L_GAIN', ...
    'H1:SUS-MC1_M3_DRIVEALIGN_Y2L_GAIN', 'H1:SUS-MC2_M3_DRIVEALIGN_Y2L_GAIN', 'H1:SUS-MC3_M3_DRIVEALIGN_Y2L_GAIN'};

A2A_chans = {'H1:SUS-MC1_M3_DRIVEALIGN_P2P_GAIN', 'H1:SUS-MC2_M3_DRIVEALIGN_P2P_GAIN', 'H1:SUS-MC3_M3_DRIVEALIGN_P2P_GAIN', ...
    'H1:SUS-MC1_M3_DRIVEALIGN_Y2Y_GAIN', 'H1:SUS-MC2_M3_DRIVEALIGN_Y2Y_GAIN', 'H1:SUS-MC3_M3_DRIVEALIGN_Y2Y_GAIN'};

L2Eul_chans = {'H1:SUS-MC1_M3_EUL2OSEM_2_1', 'H1:SUS-MC2_M3_EUL2OSEM_2_1', 'H1:SUS-MC3_M3_EUL2OSEM_2_1', ...
    'H1:SUS-MC1_M3_EUL2OSEM_2_1', 'H1:SUS-MC2_M3_EUL2OSEM_2_1', 'H1:SUS-MC3_M3_EUL2OSEM_2_1'};

A2Eul_chans = {'H1:SUS-MC1_M3_EUL2OSEM_2_2', 'H1:SUS-MC2_M3_EUL2OSEM_2_2', 'H1:SUS-MC3_M3_EUL2OSEM_2_2', ...
    'H1:SUS-MC1_M3_EUL2OSEM_2_3', 'H1:SUS-MC2_M3_EUL2OSEM_2_3', 'H1:SUS-MC3_M3_EUL2OSEM_2_3'};

% fetch channel data
gwd = GWData();
gwd.make_kerberos_ready;
% gwd.site_info(2).server = 'nds2.ligo.caltech.edu';
% gwd.site_info(2).port = 31200;
gwd.site_info(2).server = 'h1nds1';
gwd.site_info(2).port = 8088;

[A2L_data, ~, ~] = gwd.fetch(gps_time, dt, A2L_chans);
[A2A_data, ~, ~] = gwd.fetch(gps_time, dt, A2A_chans);
[L2Eul_data, ~, ~] = gwd.fetch(gps_time, dt, L2Eul_chans);
[A2Eul_data, ~, ~] = gwd.fetch(gps_time, dt, A2Eul_chans);

A2L_data=mean(A2L_data);
A2A_data=mean(A2A_data);
L2Eul_data=mean(L2Eul_data);
A2Eul_data=mean(A2Eul_data);

%see LHO alog 31402 (Jenne)
alpha = A2L_data.*L2Eul_data./(A2A_data.*A2Eul_data)

%see LHO alog 14788 (Kiwamu) and alog 42602 (Craig)
% (Craig) HSTS = Ham Small Triple Suspensions for MC1, MC2, MC3
alpha2mm = [39.28, 39.28, 39.28, 39.28, 39.28, 39.28];
measurements
miscentering = alpha .* alpha2mm %in mm for HSTS

%since we are using LL as our refernce coil, negative alphas mean the beam
%is closer to LL than center.  Postive pit numbers mean above center,
%positive yaw numbers mean right of center