clear all;

a = load('fplane_phase_re');
b = load('fplane_phase_im');

theta = load('theta');
theta = theta;
theta_new = linspace(0,pi/2,length(theta));
I = sqrt(-1);
c = a + I*b;

figure(1); imagesc(theta*180/pi,theta*180/pi,abs(c)); axis image; colorbar
xlabel('\theta_{in} (degrees)');
ylabel('\theta_{out} (degrees)');

x = 1./cos(theta);

figure(2); semilogy(x,diag(abs(c)).^2,'o-');
xlabel('1/cos(theta_{out})')
ylabel('log_e(|G(\theta,\theta)|^2)')
saveas(gcf,'diagonal_intensity_semilogy.eps','epsc')


figure(3); plot(x,diag(abs(c)).^2,'o-');
xlabel('1/cos(theta_{out})')
ylabel('|G(\theta,\theta)|^2')
saveas(gcf,'diagonal_intensity_linear.eps','epsc')

d = c(:,1:21);
result = real(d);
save('fplane_phase_re_21_columns.dat', 'result','-ascii');
result = imag(d);
save('fplane_phase_im_21_columns.dat', 'result','-ascii');
