%%
close all
clear all
clc

%%
printFigs = true;

imageDir = {'/ligo/data/camera/archive/2017/08/29/';...
            '/ligo/data/camera/archive/2017/09/01/'};

[dcreadout_0829,~] = imread([imageDir{1} 'H1 ETMX (h1cam25)_2017-08-29-02-02-08.tiff']);
[dcreadout_0901,~] = imread([imageDir{2} 'H1 ETMX (h1cam25)_2017-09-01-22-04-39.tiff']);
difference_ETMX = (dcreadout_0829 - dcreadout_0901);

figure(1);
imagesc(dcreadout_0829);
colormap(gray);
title({'H1 ETMX Red Camera; DC Readout, 2W';'2017-08-29 Pre-TMDS Discharge'});
xlabel('Horizontal Pixel Count')
ylabel('Vertical Pixel Count')
xlim([25 475])
ylim([25 475])

figure(2);
imagesc(dcreadout_0901);
colormap(gray);
title({'H1 ETMX Red Camera; DC Readout, 2W';'2017-09-01 Post-TMDS Discharge'});
xlabel('Horizontal Pixel Count')
ylabel('Vertical Pixel Count')
xlim([25 475])
ylim([25 475])

figure(3);
imagesc(difference_ETMX);
colormap(gray);
title({'H1 ETMX Red Camera; DC Readout, 2W';'(Pre - Post) TMDS Discharge'});
xlabel('Horizontal Pixel Count')
ylabel('Vertical Pixel Count')
xlim([25 475])
ylim([25 475])

%%
if printFigs
    figure(1)
    FillPage('w')
    colorbar
    saveas(gcf,'2017-08-29_H1COCETMX_RedCameraImage_DCReadout2W_BeforeTMDS.png')
    saveas(gcf,'2017-08-29_H1COCETMX_RedCameraImage_DCReadout2W_BeforeTMDS.pdf')
    
    figure(2)
    FillPage('w')
    colorbar
    saveas(gcf,'2017-09-01_H1COCETMX_RedCameraImage_DCReadout2W_AfterTMDS.png')
    saveas(gcf,'2017-09-01_H1COCETMX_RedCameraImage_DCReadout2W_AfterTMDS.pdf')
    
    figure(3)
    FillPage('w')
    colorbar
    saveas(gcf,'2017-09-01_H1COCETMX_RedCameraImage_DCReadout2W_Before-AfterTMDS.png')
    saveas(gcf,'2017-09-01_H1COCETMX_RedCameraImage_DCReadout2W_Before-AfterTMDS.pdf')
end