close all
clear all
clc

%%
printFigs = true;

dataDir = '/Users/kissel/Desktop/scratch/2017LHOVent/BnK/ITMEllipticalBaffles/';

X = 1;
Y = 2;

itm(X).ifo(X).fileName = '2017-12-07_H1AOSITMX_EllipBaffle_Y_IFOX_Exc_Yresp.txt';
itm(X).ifo(Y).fileName = '2017-12-07_H1AOSITMX_EllipBaffle_Z_IFOY_Exc_Zresp.txt';
itm(Y).ifo(X).fileName = '2017-12-07_H1AOSITMY_EllipBaffle_Y_IFOX_Exc_Yresp.txt';
itm(Y).ifo(Y).fileName = '2017-12-07_H1AOSITMY_EllipBaffle_Z_IFOY_Exc_Zresp.txt';

figTag = '2017-12-07_H1AOSITM_EllipticalBaffle_BnK_Response';

%%
for iITM = 1:2
    for iDOF = 1:2
        itm(iITM).ifo(iDOF).rawData = load([dataDir itm(iITM).ifo(iDOF).fileName]);
        
        itm(iITM).ifo(iDOF).freq = itm(iITM).ifo(iDOF).rawData(:,2);
        itm(iITM).ifo(iDOF).tf   = itm(iITM).ifo(iDOF).rawData(:,3) + 1i*itm(iITM).ifo(iDOF).rawData(:,4);
    end
end

%%
figure(1)
subplot(211)
loglog(itm(X).ifo(X).freq, abs(itm(X).ifo(X).tf),...
       itm(Y).ifo(Y).freq, abs(itm(Y).ifo(Y).tf));
xlim([5 400])   
ylim([1e-4 1e0])   
set(gca,'XTick',10.^(0:3),'YTick',10.^(-4:0))
xlabel('Frequency / Hz') 
ylabel('Magnitude / (m.s^{-2}).N^{-2}')
legend('ITMX, IFO X Direction',...
       'ITMY, IFO Y Direction',...
       'Location','SouthWest')
title('2017-12-07 H1AOSITM EllipticalBaffle B&K Response')   

subplot(212)   
loglog(itm(X).ifo(Y).freq, abs(itm(X).ifo(Y).tf),...
       itm(Y).ifo(X).freq, abs(itm(Y).ifo(X).tf));
xlim([5 400])   
ylim([1e-3 1e0])  
legend('ITMX, IFO Y Direction',...
       'ITMY, IFO X Direction',...
       'Location','SouthWest')
set(gca,'XTick',10.^(0:3),'YTick',10.^(-3:0))
xlabel('Frequency / Hz') 
ylabel('Magnitude / (m.s^{-2}).N^{-2}')

%%
figure(2)
subplot(211)
semilogy(itm(X).ifo(X).freq, abs(itm(X).ifo(X).tf),...
       itm(Y).ifo(Y).freq, abs(itm(Y).ifo(Y).tf));
xlim([60 120])   
ylim([1e-4 1e0])   
set(gca,'XTick',60:10:120,'YTick',10.^(-4:0))
xlabel('Frequency / Hz') 
ylabel('Magnitude / (m.s^{-2}).N^{-2}')
legend('ITMX, IFO X Direction',...
       'ITMY, IFO Y Direction',...
       'Location','North')
title('2017-12-07 H1AOSITM EllipticalBaffle B&K Response')   

subplot(212)   
semilogy(itm(X).ifo(Y).freq, abs(itm(X).ifo(Y).tf),...
       itm(Y).ifo(X).freq, abs(itm(Y).ifo(X).tf));
xlim([60 120])   
ylim([1e-3 1e0])  
legend('ITMX, IFO Y Direction',...
       'ITMY, IFO X Direction',...
       'Location','SouthWest')
set(gca,'XTick',60:10:120,'YTick',10.^(-4:0))
xlabel('Frequency / Hz') 
ylabel('Magnitude / (m.s^{-2}).N^{-2}')   

%%
if printFigs
    figure(1)
    FillPage('w')
    IDfig
    saveas(gcf,[dataDir figTag '.pdf'])
    
    figure(2)
    FillPage('w')
    IDfig
    saveas(gcf,[dataDir figTag '_ZOOM.pdf'])
end


