% Date: Feb. 2014
% Author: Jing Lin

%% Set up data loading and images saving directory

tic;

% clc;
% clear;

d0 = fileparts([pwd, filesep]);
d0 = d0(1 : strfind(d0,'trunk')+4);

% app.savemat = 'Save_GMM11_M005/mat/BGC_001';
% app.saveimg = 'Save_GMM11_M005/img/BGC_001';

if ~exist(sprintf('%s/%s', d0, app.savemat), 'dir')
    error('Wrong data directory!');
end;

if ~exist(sprintf('%s/%s', d0, app.saveimg), 'dir')
    mkdir(sprintf('%s/%s', d0, app.saveimg));
end;


%% Load setup data

load(sprintf('%s/%s/setup', d0, app.savemat));
d0 = fileparts([pwd, filesep]);
d0 = d0(1 : strfind(d0,'trunk')+4);

XP = XP*h/1000; YP = YP*h/1000;
XU = XU*h/1000; YU = YU*h/1000;
XV = XV*h/1000; YV = YV*h/1000;


%% Plot and Save

% Start_Frame = 0;
% End_Frame = 32;

RowPerFig = 11;

%font_settings = struct('fontname', 'Times', 'fontsize', 24, 'fontweight', 'Bold');
first_pass = true;
for k = Start_Frame : End_Frame
    if exist(sprintf('%s/%s/%03d.mat', d0, app.savemat, k), 'file')
        DataNum = sprintf('%03d', k);
        eval('BGC_DO_Full_Plot');
    end;
    
    if exist(sprintf('%s/%s/%03d_pos.mat', d0, app.savemat, k), 'file')
        DataNum = sprintf('%03d_pos', k);
        eval('BGC_DO_Full_Plot');
    end;
end;

toc;