%% Example #6
% Accumulation radar using mcords5 system
fn = 'E:\accum\2017_Greenland_P3\chan1\mcords5_01_20170226_111814_04_0004.bin';
[hdr,data_iq] = basic_load_mcords5(fn);
data = data_iq{1} + j*data_iq{2};
clear pc_param;
pc_param.f0 = 600e6;
pc_param.f1 = 900e6;
pc_param.Tpd = 2e-6;
pc_param.window_func = @hanning;
pc_param.tukey = 0.05;
pc_param.DDC_mode = true;
fs = 1.6e9/4;
Nt = size(data,1);
t0 = 0e-6;
dt = 1/fs;
pc_param.time = t0 + (0:dt:(Nt-1)*dt).';
pc_param.DDC_freq = 750e6;

[pc_signal,pc_time] = pulse_compress(data,pc_param);

title('Radar Echogram DDC4 mode (400 MSPS)');
figure(1); clf;
imagesc(lp(pc_signal));
xlabel('Range line');
ylabel('Range bin');
ylim([4800 6000])

figure(3); clf;
imagesc(lp(fft2(pc_signal)));
xlabel('Doppler bin');
ylabel('Frequency bin');
title('Radar FK DDC4 mode (400 MSPS)');

figure(2); clf;
title('Radar A-Scope DDC4 mode (400 MSPS)');
plot(lp(pc_signal(:,1)))
hold on
plot(lp(pc_signal(:,1500)),'r')
grid on;
xlabel('Range line');
ylabel('Range bin');
ylim([0 60]);
xlim([4000 7000]); 
legend('Range line 1','Range line 2','location','best');

saveas(1,'E:\accum\2017_Greenland_P3\Echogram.jpg');
saveas(3,'E:\accum\2017_Greenland_P3\Echogram_FK.jpg');
saveas(2,'E:\accum\2017_Greenland_P3\Ascope.fig');
saveas(2,'E:\accum\2017_Greenland_P3\Ascope.jpg');

return

10000 Hz PRF
128 I records (64 zero-pi pairs)
128 Q records (64 zero-pi pairs)

This amounts to an EPRI that is 10 times that of the previous system.
The I and Q waveforms may not line up because of the relatively large offset (1.6 meters) between each.

