%===============================================
%
% PLMR processing software suite
%
% This program creates the calibration files or produces
% output files, as defined in the different argument and
% variable files. It uses the subroutines calibration.m, plmr.m, ....
%
% The arguments have to be set in input_arg.m (system and path settings),
% flight_arg.m (flight settings, temperature correction etc.), 
% and calib_*.m for the various calibration files.
%
% This is not a program for distribution!!! 
%
% Author          Date           version
% C. Rüdiger      18-Oct-09      1.0
% C. Rüdiger      10-Nov-09      1.01    added CCCP processing
% C. Rüdiger      11-Nov-09      1.02    added RASP processing
% C. Rüdiger      12-Nov-09      1.10    added graphics
%
%===============================================

clear all
close all
clc

tic
%-----------------------------------------------
% load system and experiment specific variables
%-----------------------------------------------
[linux,preproc,ussr,p2sp,rasp,calib,anci,kml,plmr_pro,graphs,experi,geb,pol,res,chk,sve,plt,tpause]=c_input_arg;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CALIBRATION
%-----------------------------------------------
% launch raw PLMR data processing (conversion of counts to Tb)
%-----------------------------------------------
if (plmr_pro)
    f_raw_plmr
end

%-----------------------------------------------
% launch calibration runs
%-----------------------------------------------
if (calib)
    f_calibration
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ARA PROCESSING
%
%-----------------------------------------------
% Brightness Temperatures:
% launch CCCP extraction of PLMR data files and prepare them
% for use with RASP, using PLMR2SP
%-----------------------------------------------
if (preproc)
    f_PLMR_extract
end

%-----------------------------------------------
% launch RASP for georeferencing data points
%-----------------------------------------------
if (rasp)
    f_RASP
end

%-----------------------------------------------
% launch R12 to extract TIR and Skye data
%-----------------------------------------------
if (anci)
    f_Skye
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% UoM GRAPHICS
%-----------------------------------------------
% launch display/analysis runs
% this includes post-processing of the PLMR observations, ie. normalisation
% for temperature variation and angles.
%-----------------------------------------------
if (graphs)
    disp('... a little patience please ...');
    pause(4*tpause)
    disp('... and here we go again ...');
    f_graph_rasp
end

%-----------------------------------------------
% launch KML script
%-----------------------------------------------
if (kml)
    if (rasp)
        disp('... and yet another little break ...');
        pause(4*tpause)
        disp('... and here we go again ...');
    end
    f_KML
end

toc