
% Contour plots

! perl mkat lcgt

load lcgt_run1.out
load lcgt_run2.out
load lcgt_run3.out
load lcgt_run4.out
load lcgt_run5.out
load lcgt_run6.out
load lcgt_run7.out
load lcgt_run8.out
load lcgt_run9.out
load lcgt_run10.out
load lcgt_run11.out
load lcgt_run12.out
load lcgt_run13.out
load lcgt_run14.out

Nxy = sqrt( size(lcgt_run1, 1 ) );
phase1 = zeros( Nxy, Nxy );
phase2 = zeros( Nxy, Nxy );
SPdc = zeros( Nxy, Nxy );
SPlp= zeros( Nxy, Nxy );
SPlm= zeros( Nxy, Nxy );
SPls= zeros( Nxy, Nxy );
APdc = zeros( Nxy, Nxy );
APlp= zeros( Nxy, Nxy );
APlm= zeros( Nxy, Nxy );
APls= zeros( Nxy, Nxy );
POdc = zeros( Nxy, Nxy );
POlp= zeros( Nxy, Nxy );
POlm= zeros( Nxy, Nxy );
POls= zeros( Nxy, Nxy );
N = size(lcgt_run13,1);
SPLp= zeros( N, 2 );
APLm= zeros( N, 2 );

for ind = 1 : Nxy
phase1(ind,1:Nxy) = lcgt_run1( 1 : Nxy : 1+Nxy*(Nxy-1), 1 )';
phase2(1:Nxy,ind) = lcgt_run1( 1 : Nxy, 2 );
SPdc(ind,1:Nxy) = lcgt_run1( ind : Nxy : ind+Nxy*(Nxy-1), 3 )';
SPlp(ind,1:Nxy) = lcgt_run2( ind : Nxy : ind+Nxy*(Nxy-1), 3 )';
SPlm(ind,1:Nxy) = lcgt_run3( ind : Nxy : ind+Nxy*(Nxy-1), 3 )';
SPls(ind,1:Nxy) = lcgt_run4( ind : Nxy : ind+Nxy*(Nxy-1), 3 )';
APdc(ind,1:Nxy) = lcgt_run5( ind : Nxy : ind+Nxy*(Nxy-1), 3 )';
APlp(ind,1:Nxy) = lcgt_run6( ind : Nxy : ind+Nxy*(Nxy-1), 3 )';
APlm(ind,1:Nxy) = lcgt_run7( ind : Nxy : ind+Nxy*(Nxy-1), 3 )';
APls(ind,1:Nxy) = lcgt_run8( ind : Nxy : ind+Nxy*(Nxy-1), 3 )';
POdc(ind,1:Nxy) = lcgt_run9( ind : Nxy : ind+Nxy*(Nxy-1), 3 )';
POlp(ind,1:Nxy) = lcgt_run10( ind : Nxy : ind+Nxy*(Nxy-1), 3 )';
POlm(ind,1:Nxy) = lcgt_run11( ind : Nxy : ind+Nxy*(Nxy-1), 3 )';%
POls(ind,1:Nxy) = lcgt_run12( ind : Nxy : ind+Nxy*(Nxy-1), 3 )';

end
SPLp=lcgt_run13;
APLm=lcgt_run14;

figure(1)
axis([0 180 0 180])
axis square
box on
%plot (0,0,'k :', 0,0, 'b', 0,0, 'r', 0,0, 'g')
hold on
plot ( 0,0, 'b', 0,0, 'r', 0,0, 'g')
%legend ('dc=0', 'l+', 'l-', 'ls')
legend ( 'l+', 'l-', 'ls')
%contour(phase1, phase2, SPdc,1, 'k:');%1 means "conour level 1" ??
[C,h] = contour(phase1, phase2, SPlp, 'b');
clabel(C,h, 'FontSize', 10)
[C,h] = contour(phase1, phase2, SPlm, 'r');
clabel(C,h, 'FontSize', 10)
[C,h] = contour(phase1, phase2, SPls, 'g');
clabel(C,h, 'FontSize', 10)

set(gca,'xtick',[0 45 90 135 180])
set(gca,'ytick',[0 45 90 135 180])


h=findobj('LineStyle',':');
set (h, 'LineWidth', 3);
h=findobj('LineWidth', 0.5);;
set (h, 'LineWidth', 2);
h=findobj('FontSize', 9);
set (h, 'FontSize', 20);

%xlabel('Demodulation Phase of f1','FontSize',16)
%ylabel('Demodulation Phase of f2','FontSize',16)
title('Double Demodulation at SP','FontSize',12)
h=findobj('LineStyle',':');
set (h, 'LineWidth', 3);
h=findobj('LineWidth', 0.5);
set (h, 'LineWidth', 1);
h=findobj('FontSize', 9);
set (h, 'FontSize', 12);
h = gcf;
saveas(h,'SP.fig');
saveas(h,'SP.emf');
%clf


figure(2)
axis([0 180 0 180])
axis square
box on
%plot (0,0,'k :', 0,0, 'b', 0,0, 'r', 0,0, 'g')
hold on
plot ( 0,0, 'b', 0,0, 'r', 0,0, 'g')
%legend ('dc=0', 'l+', 'l-', 'ls')
legend ( 'l+', 'l-', 'ls')
%contour(phase1, phase2, APdc,1, 'k:');
[C,h] = contour(phase1, phase2, APlp, 'b');
clabel(C,h, 'FontSize', 10)
[C,h] = contour(phase1, phase2, APlm, 'r');
clabel(C,h, 'FontSize', 10)
[C,h] = contour(phase1, phase2, APls, 'g');
clabel(C,h, 'FontSize', 10)

set(gca,'xtick',[0 45 90 135 180])
set(gca,'ytick',[0 45 90 135 180])


h=findobj('LineStyle',':');
set (h, 'LineWidth', 1);
h=findobj('LineWidth', 0.5);
set (h, 'LineWidth', 1);
h=findobj('FontSize', 3);
set (h, 'FontSize', 5);

%xlabel('Demodulation Phase of f1','FontSize',16)
%ylabel('Demodulation Phase of f2','FontSize',16)
title('Double Demodulation at AP','FontSize',12)
h=findobj('LineStyle',':');
set (h, 'LineWidth', 3);
h=findobj('LineWidth', 0.5);
set (h, 'LineWidth', 1);
h=findobj('FontSize', 9);
set (h, 'FontSize', 12);
h = gcf;
saveas(h,'AP.fig');
saveas(h,'AP.emf');
%clf

figure(3)
axis([0 180 0 180])
axis square
box on
%plot (0,0,'k :', 0,0, 'b', 0,0, 'r', 0,0, 'g')
hold on
plot ( 0,0, 'b', 0,0, 'r', 0,0, 'g')
%legend ('dc=0', 'l+', 'l-', 'ls')
legend ( 'l+', 'l-', 'ls')
%contour(phase1, phase2, POdc,1, 'k:');
[C,h] = contour(phase1, phase2, POlp, 'b');
clabel(C,h, 'FontSize', 10)
[C,h] = contour(phase1, phase2, POlm, 'r');
clabel(C,h, 'FontSize', 10)
[C,h] = contour(phase1, phase2, POls, 'g');
clabel(C,h, 'FontSize', 10)
%xlabel('Demodulation Phase of f1','FontSize',16)
%ylabel('Demodulation Phase of f2','FontSize',16)
title('Double Demodulation at PO','FontSize',12)

set(gca,'xtick',[0 45 90 135 180])
set(gca,'ytick',[0 45 90 135 180])


h=findobj('LineStyle',':');
set (h, 'LineWidth', 1);
h=findobj('LineWidth', 0.5);
%set (h, 'LineWidth', 1);
set (h, 'LineWidth', 1);
h=findobj('FontSize', 9);
%h=findobj('FontSize', 3);
set (h, 'FontSize', 12);
%set (h, 'FontSize', 5);
h = gcf;
saveas(h,'PO.fig');
saveas(h,'PO.emf');
