% $Id: ElevAzi.m,v 1.2 2005/04/18 19:46:46 vnadkar Exp $
%
% Must first run doMpMap.bat on a data set in the current directory.
% This script will run through the data and plot elevation against
% azimuth and also elevation/azimuth against time for each satellite.
%
% 


%
% set the RGB values. The colours are a combination of standard Matlab
% settings, HTML definitions and ones I made up.
%

% R
colour_LUT(1,1) = 0;    % Blue
colour_LUT(2,1) = 255;  % Red
colour_LUT(3,1) = 255;  % Magenta / HTML 4.01 fuschia
colour_LUT(4,1) = 0;    % Green / HTML 4.01 lime
colour_LUT(5,1) = 0;    % Cyan / HTML 4.01 aqua
colour_LUT(6,1) = 0;    % Black
colour_LUT(7,1) = 255;  % Yellow
colour_LUT(8,1) = 0;    % HTML 4.01 Teal
colour_LUT(9,1) = 0;    % HTML 4.01 Green
colour_LUT(10,1) = 128;  % HTML 4.01 Maroon
colour_LUT(11,1) = 0;    % HTML 4.01 Navy
colour_LUT(12,1) = 128;  % HTML 4.01 Olive
colour_LUT(13,1) = 128;  % HTML 4.01 Purple
colour_LUT(14,1) = 255;  % Horrible salmon (my creation)
colour_LUT(15,1) = 192;  % HTML 4.01 Silver
colour_LUT(16,1) = 128;  % HTML 4.01 Gray
colour_LUT(17,1) = 128;  
colour_LUT(18,1) = 128; 
colour_LUT(19,1) = 128;

% G
colour_LUT(1,2) = 0;    % Blue
colour_LUT(2,2) = 0;    % Red
colour_LUT(3,2) = 0;    % Magenta / HTML 4.01 fuschia
colour_LUT(4,2) = 255;  % Green / HTML 4.01 lime
colour_LUT(5,2) = 255;  % Cyan / HTML 4.01 aqua
colour_LUT(6,2) = 0;    % Black
colour_LUT(7,2) = 255;  % Yellow
colour_LUT(8,2) = 128;  % HTML 4.01 Teal
colour_LUT(9,2) = 128;  % HTML 4.01 Green
colour_LUT(10,2) = 0;    % HTML 4.01 Maroon
colour_LUT(11,2) = 0;    % HTML 4.01 Navy
colour_LUT(12,2) = 128;  % HTML 4.01 Olive
colour_LUT(13,2) = 0;    % HTML 4.01 Purple
colour_LUT(14,2) = 177;  % Horrible salmon (my creation)
colour_LUT(15,2) = 192;  % HTML 4.01 Silver
colour_LUT(16,2) = 128;  % HTML 4.01 Gray
colour_LUT(17,2) = 255;
colour_LUT(18,2) = 51;
colour_LUT(19,2) = 0;

% B
colour_LUT(1,3) = 255;  % Blue
colour_LUT(2,3) = 0;    % Red
colour_LUT(3,3) = 255;  % Magenta / HTML 4.01 fuschia
colour_LUT(4,3) = 0;    % Green / HTML 4.01 lime
colour_LUT(5,3) = 255;  % Cyan / HTML 4.01 aqua
colour_LUT(6,3) = 0;    % Black
colour_LUT(7,3) = 0;    % Yellow
colour_LUT(8,3) = 128;  % HTML 4.01 Teal
colour_LUT(9,3) = 0;    % HTML 4.01 Green
colour_LUT(10,3) = 0;    % HTML 4.01 Maroon
colour_LUT(11,3) = 128;  % HTML 4.01 Navy
colour_LUT(12,3) = 0;    % HTML 4.01 Olive
colour_LUT(13,3) = 128;  % HTML 4.01 Purple
colour_LUT(14,3) = 177;  % Horrible salmon (my creation)
colour_LUT(15,3) = 192;  % HTML 4.01 Silver
colour_LUT(16,3) = 128;  % HTML 4.01 Gray
colour_LUT(17,3) = 0;
colour_LUT(18,3) = 51;
colour_LUT(19,3) = 255;

% Duplicate the colours
colour_LUT(20:38,:) = colour_LUT(1:19,:);

% Scale into the range 0-1
colour_LUT = colour_LUT./255;

% End of Colour map setup
colour = 0;

load elev.out
load azi.out

f(1) = figure('Visible', 'off');
f(2) = figure('Visible', 'off');
f(3) = figure('Visible', 'off');
for i=2:33
  if( sum(isfinite(elev(:,i))) > 0)
    colour = colour + 1;
    
    % figure(f(1));
    set(0, 'CurrentFigure', f(1));
    polar_expanded(azi(:,i).*pi/180, 90 - elev(:,i),'color',colour_LUT(colour,:),'linewidth',2);
    hold on;
    
    % figure(f(2));
    set(0, 'CurrentFigure', f(2));
    plot(elev(:,1), elev(:,i),'color',colour_LUT(colour,:),'linewidth',2);
    hold on;
    
    % figure(f(3));
    set(0, 'CurrentFigure', f(3));
    j = find(azi(:,i) < -180);
    azi(j,i) = azi(j,i) + 360;
    
    j = find(azi(:,i) > 180);
    azi(j,i) = azi(j,i) - 360;

    plot(azi(:,1), azi(:,i),'color',colour_LUT(colour,:),'linewidth',2);
    hold on;

    SvPRN(colour) = i - 1;
  end
end

for i=1:colour
  StringMatrix(i) = {['PRN ',int2str(SvPRN(i))]};
end

% figure(f(1));
set(0, 'CurrentFigure', f(1));
legend(StringMatrix,0);
title('Azimuth Versus Elevation, Origin = Zenith')
print -dpng ElevAzi.png


% figure(f(2));
set(0, 'CurrentFigure', f(2));
legend(StringMatrix,0);
title('Elevation versus Time');
xlabel('Time [Sec]');
ylabel('Elevation [Degrees]');
% Set the axis
A    = axis;
A(3) = 0;
A(4) = 90;
axis(A);
grid
print -dpng Elev.png


% figure(f(3));
set(0, 'CurrentFigure', f(3));
legend(StringMatrix,0);
title('Azimuth versus Time');
xlabel('Time [Sec]');
ylabel('Azimuth [Degrees]');
% Set the axis
A    = axis;
A(3) = -180;
A(4) =  180;
axis(A);
grid
print -dpng Azi.png





