%
% $Id: fftplot.m,v 1.4 2005/04/18 19:46:46 vnadkar Exp $
% Copyright Trimble Navigation Ltd. 2001
%

function fftplot(SV,ph_dd_l1,ph_dd_l2,rg_dd_l1,rg_dd_l2);

figure('Visible','off');

for type=1:4
  if(type==1)
    Y    = excise_vector(ph_dd_l1(:,SV))./10000;
  elseif(type==2)
    Y    = excise_vector(ph_dd_l2(:,SV))./10000;
  elseif(type==3)
    Y    = excise_vector(rg_dd_l1(:,SV))./10000;
  else
    Y    = excise_vector(rg_dd_l2(:,SV))./10000;
  end

  X    = fft(Y);
  N    = length(X);
  X(1) = [];
  power = abs(X(1:floor(N/2))).^2 / N;
  nyquist = 1/2;   % 0.5Hz (assume 1Hz data)
  freq = (1:N/2)/(N/2)*nyquist;
  
  subplot(2,2,type);
  j = find(freq < 0.1); % 0.1Hz data
  plot(freq(j),power(j));
  grid on
  xlabel('Hz');
  ylabel('Power');
  if(type==1)
    title('L1 Phase');
  elseif(type==2)
    title('L2 Phase');
  elseif(type==3)
    title('L1 Range');
  else
    title('L2 Range');
  end

  % find the maximum and annotate

  peak_y = max(power);
  peak_x = freq(find( power == peak_y ));
  text(peak_x,peak_y,['\leftarrow ',num2str(peak_x),' Hz / ', ...
         num2str(1/peak_x,'%.1f'),' Secs'], ...
        'HorizontalAlignment','left');
end

suptitle(['Periodogram for Double Difference PRN ',num2str(SV-1)]);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% $Log: fftplot.m,v $
% Revision 1.4  2005/04/18 19:46:46  vnadkar
% Make plots invisible. This allows the user to work on other things while
% load_pi runs in the background. The outputs from the plots are printed
% to files.
%
% Revision 1.3  2001/04/03 22:10:06  stuart
% o Updates to get the .m files to compile and take advantage of the fact that the latest Matlab compiler will allow .png files to be written directly.
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
