channelList = {'H1:LSC-LOCKIN_1_DEMOD_11_I_OUT16', ...
    'H1:LSC-LOCKIN_1_DEMOD_12_I_OUT16', ...
    'H1:LSC-LOCKIN_1_DEMOD_13_I_OUT16', ...
    'H1:LSC-LOCKIN_1_DEMOD_14_I_OUT16', ...
    'H1:ALS-C_COMM_VCO_CONTROLS_SETFREQUENCYOFFSET'}

%channelList = {'H1:LSC-LOCKIN_2_DEMOD_11_I_OUT16', ...
%    'H1:LSC-LOCKIN_2_DEMOD_12_I_OUT16', ...
%    'H1:LSC-LOCKIN_2_DEMOD_13_I_OUT16', ...
%    'H1:LSC-LOCKIN_2_DEMOD_14_I_OUT16', ...
%    'H1:ALS-C_COMM_VCO_CONTROLS_SETFREQUENCYOFFSET'}

out10 = get_data(channelList, 'raw', 1098777760, 130);
out09 = get_data(channelList, 'raw', 1098777933, 107);
out08 = get_data(channelList, 'raw', 1098778062, 24);
out07 = get_data(channelList, 'raw', 1098778096, 79);
out06 = get_data(channelList, 'raw', 1098778184, 68);
out05 = get_data(channelList, 'raw', 1098778261, 17);

driveAmp = 0.02;

outList=[out10; out09; out08; out07; out06; out05];

outMeans = zeros(6, 4);
outStds = zeros(6, 4);
alsCommOffs = zeros(1, 6);

for ii=1:6
    for jj=1:4
        outMeans(ii,jj) = mean(outList(ii,jj).data);
        outStds(ii,jj) = std(outList(ii,jj).data);
    alsCommOffs(ii) = mean(outList(ii,5).data);
    end
end

outMeans(:,2) = outMeans(:,2) * 10
outStds(:,2) = outStds(:,2) * 10

alsCommOffs = repmat(alsCommOffs, 4, 1)'*7e-3 % nm

hFig = errorbar(alsCommOffs, outMeans/driveAmp, outStds/driveAmp);

grid
grid minor
%axis tight
hXLabel = xlabel('ALS Comm offset (nm)');
hYLabel = ylabel('Demodulated sideband responses (cts)');

%% custom color setting of individual traces by RGB number
colorss = {[0.9  0.0  0.0],
           [0.0  0.6  0.0],
           [0.0  0.0  0.9],
           [0.5  0.5  0.5],
           [0.97  0.1  0.0],
           [0.1  0.9  1.0],
           [0.2  0.8  0.1],
           [0.4  0.4  1.0]};
for k = 1:length(hFig)
    set(hFig(k), 'Color', colorss{k});
end

%%
hLegend = legend({'27I', '27Q ($\times10$)', '135I', '135Q'}, ...
    'Interpreter', 'LaTeX', 'Location', 'Best');

hTitle = title('DRMI 3f sensing matrix, PR2');

% =======================================================
% this section uses the matlab handles to set all the Font and FontSize properties --- adjust to your taste
set(hFig, ...
  'LineWidth'       , 4           )


set( gca                       , ...
    'FontName'   , 'Times'     , ...
    'FontSize'   , 28          );
set([hXLabel, hYLabel, hTitle], ...
    'FontName'   , 'Times',...
    'FontSize'   , 28          );
set([hLegend, gca]             , ...
    'FontSize'   , 22          );
%set( hTitle                    , ...
%    'FontSize'   , 12          , ...
%    'FontWeight' , 'bold'      );

set(gca, ...
  'Box'         , 'on'     , ...
  'TickDir'     , 'in'     , ...
  'TickLength'  , [.02 .0] , ...
  'XMinorTick'  , 'on'      , ...
  'YMinorTick'  , 'on'      , ...
  'YGrid'       , 'on'      , ...
  'XColor'      , .1*[.3 .3 .3], ...
  'YColor'      , .1*[.3 .3 .3], ...
  'FontSize'    , 28, ...
  'LineWidth'   , 1        );
% ==========================================================

%% Ridiculous pretty-print code
% --- tells Matlab to use this figure window size and respect this size for printing
orient landscape
set(gcf,'Position', [700 500 900 700])
set(gcf,'PaperPositionMode','auto')
 
opname = 'Sensing3fAlsOffsPR2';
% print the file as a 600 DPI EPS color file - this preserves the vector graphics  
print('-depsc','-r600', [opname '.eps'])
% use the epstopdf command to convert from EPS to PDF without losing quality (makePDF.csh is designed to work on Mac and uses unsetenv to avoid Matlab's bad GS librarys)
[a,b] = system(['./makePDF.csh ' opname '.eps']);
if a ~= 0
    disp('PDF Generation Error')
end