%
% Graphs for Read Noise
% ------------------------------
% This file plots the variance in the read noise across the width
% of the image so that we can see how the read noise varies according to 
% pixel position. We plotted all this for all 8 exposures.
% 

clc;
close all;
clear;

load read_noise.mat;

pixels=pixels_1;
figure(2);
subplot(4,2,1);
hold on;
plot(pixels(:,2), variance_1(:,1),'r');
plot(pixels(:,2), variance_1(:,2),'g-');
plot(pixels(:,2), variance_1(:,3),'b');
plot(pixels(:,2), variance_1(:,4),'g--');
hold off;
title('Read Noise for 1s Exposure');
xlabel('Pixel Position along Width');
ylabel('Read Noise');

subplot(4,2,2);
hold on;
plot(pixels(:,2), variance_2(:,1),'r');
plot(pixels(:,2), variance_2(:,2),'g-');
plot(pixels(:,2), variance_2(:,3),'b');
plot(pixels(:,2), variance_2(:,4),'g--');
hold off;
title('Read Noise for 2s Exposure');

subplot(4,2,3);
hold on;
plot(pixels(:,2), variance_4(:,1),'r');
plot(pixels(:,2), variance_4(:,2),'g-');
plot(pixels(:,2), variance_4(:,3),'b');
plot(pixels(:,2), variance_4(:,4),'g--');
hold off;
title('Read Noise for 4s Exposure');

subplot(4,2,4);
hold on;
plot(pixels(:,2), variance_8(:,1),'r');
plot(pixels(:,2), variance_8(:,2),'g-');
plot(pixels(:,2), variance_8(:,3),'b');
plot(pixels(:,2), variance_8(:,4),'g--');
hold off;
title('Read Noise for 8s Exposure');

subplot(4,2,5);
hold on;
plot(pixels(:,2), variance_15(:,1),'r');
plot(pixels(:,2), variance_15(:,2),'g-');
plot(pixels(:,2), variance_15(:,3),'b');
plot(pixels(:,2), variance_15(:,4),'g--');
hold off;
title('Read Noise for 15s Exposure');

subplot(4,2,6);
hold on;
plot(pixels(:,2), variance_20(:,1),'r');
plot(pixels(:,2), variance_20(:,2),'g-');
plot(pixels(:,2), variance_20(:,3),'b');
plot(pixels(:,2), variance_20(:,4),'g--');
hold off;
title('Read Noise for 20s Exposure');

subplot(4,2,7);
hold on;
plot(pixels(:,2), variance_25(:,1),'r');
plot(pixels(:,2), variance_25(:,2),'g-');
plot(pixels(:,2), variance_25(:,3),'b');
plot(pixels(:,2), variance_25(:,4),'g--');
hold off;

title('Read Noise for 25s Exposure');

subplot(4,2,8);
hold on;
plot(pixels(:,2), variance_30(:,1),'r');
plot(pixels(:,2), variance_30(:,2),'g-');
plot(pixels(:,2), variance_30(:,3),'b');
plot(pixels(:,2), variance_30(:,4),'g--');
hold off;

title('Read Noise for 30s Exposure');


figure(3);
hold on;
plot(pixels(:,2), variance_1(:,1),'y--');
plot(pixels(:,2), variance_2(:,1),'y');
plot(pixels(:,2), variance_4(:,1),'c--');
plot(pixels(:,2), variance_8(:,1),'c');
plot(pixels(:,2), variance_15(:,1),'m--');
plot(pixels(:,2), variance_20(:,1),'m');
plot(pixels(:,2), variance_25(:,1),'k--');
plot(pixels(:,2), variance_30(:,1),'k');
hold off;
title('Variations in Read Noise Across Image for Different Exposures');
xlabel('Pixel Position Along Width');
ylabel('Read Noise');
legend('1s','2s','4s','8s','15s','20s','25s','30s');

