% plot sensor noises for SEI

clear all 
close all
clc

%%

printFigs  = true;
svnDir     = '/ligo/svncommon/SeiSVN/seismic/';
dccNumber = 'T0900450';
codeVersion = 'v4';

resultsDir = [svnDir 'Common/Documents/' dccNumber '_Sensor_Noise_estimates/'];
figName{1} = [resultsDir 'summary_SEI_sensor_noise_plot' codeVersion '.pdf'];
figName{2} = [resultsDir 'summary_PEM_sensor_noise_plot' codeVersion '.pdf'];
figName{3} = [resultsDir 'summary_GS_16bit_ADC_noise_plot' codeVersion '.pdf'];

my_colors
lt_purple = [.65 0 1];

freq = logspace(-3,3,1000);

ADE_1mm_noise        = SEI_sensor_noise('ADE_1mm',  freq);
ADE_1mm_idealnoise   = 2e-10 * ones(size(freq));

ADE_p25mm_noise      = SEI_sensor_noise('ADE_p25mm',freq);
ADE_p25mm_idealnoise = 6e-11 * ones(size(freq));

Kaman_1mm_noise      = SEI_sensor_noise('Kaman_IPSmeas',freq);

L4C_noise = SEI_sensor_noise('L4C',freq);

T240meas_noise = SEI_sensor_noise('T240meas',freq);
T240spec_noise = SEI_sensor_noise('T240spec',freq);

GS13meas_noise = SEI_sensor_noise('GS13meas',freq);
GS13calc_noise = SEI_sensor_noise('GS13calc',freq);

HAM_spec = HAM_req(freq);

Guralp_40T    = SEI_sensor_noise('Guralp_40T_Spec', freq);   
PCB_356M132   = SEI_sensor_noise('PCB_356M132_spec', freq);
Wilcoxon_797L = SEI_sensor_noise('Wilcoxon_797L_spec',freq);

GS_16bit_ADC  = SEI_sensor_noise('GS_16bit_ADC',freq);

%%
figure(1)
ll= loglog(...
    freq, ADE_1mm_noise,'b',...
    freq, ADE_1mm_idealnoise,'b--',...
    freq, Kaman_1mm_noise,'b',...
    freq, ADE_p25mm_noise, 'b',...
    freq, ADE_p25mm_idealnoise,'b--',...
    freq, L4C_noise,'b',...
    freq, GS13meas_noise,'g',...
    freq, GS13calc_noise,'g--', ...
    freq, T240meas_noise,'m--',...
    freq, T240spec_noise,'m');

set(ll,'LineWidth',2)
set(ll(1),'Color',lt_purple);
set(ll(2),'Color',lt_purple);
set(ll(3),'Color',lt_blue)
set(ll(4),'Color',[0.0 0.0 0.7]);
set(ll(5),'Color',[0.0 0.0 0.7]);
set(ll(6),'Color',olive);
set(ll(7),'Color',[0.0 1.0 0.0]);
set(ll(8),'Color',[0.0 1.0 0.0]);

set(gca,'FontSize',18)
grid on
title(['Noise estimates for SEI sensors, ' dccNumber '-' codeVersion],'FontSize',22)
xlabel('Frequency (Hz)')
ylabel('Noise Floor ASD (m/\surdHz)')
axis([1e-2 1e3 1e-15 2e-6])
set(gca,'XTick',10.^(-2:3),'YTick',10.^(-15:-6));

legend(...
    '1 mm ADE disp (measured)',...
    '1 mm ADE disp (ideal)',...
    '1 mm KAMAN disp (measured)',...
    '0.25 mm ADE disp (estimate)',...
    '0.25 mm ADE disp (ideal)',...
    'L-4C w/ LT1001',...
    'GS-13 measurement',...
    'GS-13 calculated',...
    'T240 measurement',...
    'T240 spec')

%%
figure(2)
ll = loglog(freq(:),[Guralp_40T(:) ,...
                     PCB_356M132(:) ,...
                     Wilcoxon_797L(:),...
                     GS13meas_noise(:),...
                     T240meas_noise(:)]);
title(['Noise estimates for PEM sensors, ' dccNumber '-' codeVersion],'FontSize',22)
xlabel('Frequency (Hz)')
ylabel('Noise Floor ASD (m/\surdHz)')    
axis([1e-2 1e3 1e-14 2e-6])
set(gca,'XTick',10.^(-2:3),'YTick',10.^(-14:-6));

set(ll(4),'Color',[0.0 1.0 0.0])
set(ll(5),'Color',[1.0 0.0 1.0])

legend(...
     'Guralp 40T (spec)',...
     'PCB 356M132 (spec)',...
     'Wilcoxon 797L (spec)',...
     'GS-13 Measurement',...
     'T240 Measurememt',...
     'Location','SouthWest')

%%
figure(3)
ll = loglog(freq(:),GS_16bit_ADC(:));
title({'Noise estimates for General Standards 16 Bit ADC';...
       [dccNumber '-' codeVersion]},...
       'FontSize',20)
xlabel('Frequency (Hz)')
ylabel('Noise Floor ASD (V/\surdHz)')    
axis([1e-2 1e3 1e-6 1e-4])
set(gca,'XTick',10.^(-2:3),'YTick',10.^(-6:-4));
 
%%
if printFigs
    for iFig = 1:length(figName)
        figure(iFig)
        IDfig
        FillPage('w')
        saveas(gcf,figName{iFig})
    end
end

