%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%                 VTOOLS                 %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
%Victor Chavarrias (victor.chavarrias@deltares.nl)
%
%$Revision$
%$Date$
%$Author$
%$Id$
%$HeadURL$
%

%% PREAMBLE

clear
clc
fclose all;

%% ADD OET

fpath_add_oet='c:\checkouts\oet_matlab\applications\vtools\general\addOET.m';
fdir_d3d='c:\checkouts\qp\';

%% ADD OET

if isunix %we assume that if Linux we are in the p-drive. 
    fpath_add_oet=strrep(strrep(strcat('/',strrep(fpath_add_oet,'P:','p:')),':',''),'\','/');
end
run(fpath_add_oet);

%% INPUT

paths_main_folder='c:\checkouts\data_stations\'; %path to <data_stations>

%% PATHS

paths=paths_data_stations(paths_main_folder);

%% CALC

load(paths.data_stations_index);

%% PLOT

ns=numel(data_stations_index);
for ks=1:ns
    fname=fullfile(paths.figures,sprintf('%06d',ks));
    fnameext=sprintf('%s.png',fname);

    load(fullfile(paths.separate,sprintf('%06d.mat',ks)),'data_one_station');

    %figure
    if exist(fnameext,'file')~=2
        in_p.fname=fname;
        in_p.data_station=data_one_station;
        in_p.fig_print=1;
        in_p.fig_visible=0;

        fig_data_station(in_p)
    end

    %export
    fpath_csv=fullfile(paths.csv,sprintf('%06d.csv',ks));
    if exist(fpath_csv,'file')~=2
        export_data_station(fpath_csv,data_one_station);
    end

    fprintf('done %4.2f %% \n',ks/ns*100)
end %ks


