% batchparseNSTB.m
%---------------------------------------------------------
% parse all NSTB files (./data/nstb/) to SGMP files (./data/parsed/)
% Ju-Yong Do,  Jan 26, 2009
%=========================================================
%=========================================================
clear all, close all, clc, format compact, format short
parameterNSTB;

%=========================================================
%get list of NSTB files
inputfiles  = dir(option.inputdir);
for i=size(inputfiles,1):-1:1   %skip directories and non-NSTB files
    if (inputfiles(i).isdir) || length(find(inputfiles(i).name=='.')),        
        inputfiles = inputfiles([1:i-1, i+1:end]); 
    end
end
if size(inputfiles,1)==0,
    error(['Please, copy NSTB files to "',option.inputdir,'" directory']);
end
disp(['parsing ',num2str(size(inputfiles,1)),' files from ',option.inputdir,' directory...']);

%=========================================================
%parse and generate SGMP files
crccheck    = 0;    %no CRC check if faster parsing is wanted
starthour   = 0;    %start time (hr) of day to be parsed
endhour     = 24;   %end time (hr) of day to be parsed
for i=1:size(inputfiles,1)        
    tic
    parseNSTB(inputfiles(i).name, starthour, endhour, crccheck);
    toc
end
%=========================================================
%=========================================================
