-
Sonja Murto authored
import_acas_cl31_wrapper.m 1.97 KiB
function import_acas_cl31_wrapper(indir,outdir,starttime,endtime,message)
% import_acas_cl31_wrapper - bulk import of ACAS WX cl31 data from raw
% files. Identifies when a message has been split over two files and
% appends the split message lines to the preceeding file
%
% import_acas_cl31_wrapper(indir,outdir,starttime,endtime)
%
% INPUT
% indir - directory to read raw files from (string)
% outdir - directory to write output files to (string)
% starttime - (optional) first time to import (matlab serial day)
% endtime - (optional) last time to import (matlab serial day)
% NB. if used BOTH start and end time must be given
% to import all upto a given time give starttime = 0
% to import all files after a given time set endtime = now
% message - Ceilometer message line 1
%
% JZP November 2018
files = dir([indir,'/*.CL']);
if nargin > 2
doit = false([length(files),1]);
for n = 1:length(files)
filename = files(n).name;
YYYY = 2000 + str2double(filename(1:2));
MM = str2double(filename(3:4));
DD = str2double(filename(5:6));
hh = str2double(filename(8:9));
mm = str2double(filename(10:11));
ss = str2double(filename(12:16));
filetime = datenum(YYYY,MM,DD,hh,mm,ss);
if (filetime >= starttime) && (filetime <= endtime)
doit(n) = true;
end
end
doit = find(doit);
else
doit = 1:length(files);
end
len = length(doit);
cl31 = nan;
for n = 1:len
disp(['importing ',num2str(n),' of ',num2str(len),' : ',...
files(doit(n)).name]);
cl31_next = import_cl31([indir,'/',files(doit(n)).name]);
outfilename_next = [files(doit(n)).name(1:16),'.cl31.mat'];
if isstruct(cl31)
[cl31,cl31_next] = fix_cl31(cl31,cl31_next,message);
save([outdir,'/',outfilename],'cl31');
end
cl31 = cl31_next;
outfilename = outfilename_next;
end
save([outdir,'/',outfilename],'cl31');