% Plot various signals in the PR-BS plane

function [md, mp, xx, yy] = halfBaked(opt)

  p.nIn = 2;
  p.fMod = 6264080;
  p.gMod = 0.17;
  p.order = 2;
  
  dSpec = [1, 2, 1,  0.0		% REFL
           1, 2, 3,  0.0		% REFL 3
           3, 2, 1,  0.0		% AS
           3, 3, 1,  0.0		% PO
           6, 2, 1,  0.0		% TRX
           7, 2, 1,  0.0];		% TRY

  N = 100;
  z = zeros(N^2, opt.Nopt);

  nxy = (1:N^2)' - 1;
  x = mod(nxy, N) * opt.lambda / (1.5 * N);
  y = floor(nxy/N) * opt.lambda / (3 * N);

  z(:,1) = x;   % PR position
  z(:,2) = y;   % BSa position
  z(:,3) = y;   % BSb position

  z(:, 6) = 2e-7;
  
  [md, mp] = dcDemod(opt, p.nIn, p.fMod, p.gMod, p.order, dSpec, z);

  xx = reshape(x,N,N);
  yy = reshape(y,N,N);
  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% make a bunch of figures
  return

  d2_p = imag(md(:,1));
  d2_q = real(md(:,1));
  d2_3p = imag(md(:,2));
  d2_3q = real(md(:,2));
  d1_p = imag(md(:,3));
  d1_q = real(md(:,3));
  d5_p = imag(md(:,4));
  d5_q = real(md(:,4));

  d2_dc = real(mp(:,1));
  d1_dc = real(mp(:,3));
  d5_dc = real(mp(:,4));

  makeSurf(xx, yy, d2_p, 'd2 p'); figure
  makeSurf(xx, yy, d2_q, 'd2 q'); figure
  makeSurf(xx, yy, d2_3p, 'd2 3p'); figure
  makeSurf(xx, yy, d2_3q, 'd2 3q'); figure
  makeSurf(xx, yy, d1_p, 'd1 p'); figure
  makeSurf(xx, yy, d1_q, 'd1 q'); figure
  makeSurf(xx, yy, d5_p, 'd5 p'); figure
  makeSurf(xx, yy, d5_q, 'd5 q'); figure
  makeSurf(xx, yy, d5_dc, 'd5 dc'); figure
  makeSurf(xx, yy, d2_dc, 'd2 dc'); figure
  makeSurf(xx, yy, d1_dc, 'd1 dc')

