function[newetl] =get_etl(indir,file_date)
% for stratus 2011
% get data from local copy of etl file
%
% me101109110_raw.txt
% me1     011   091    10
% type    year yday    hour
%
%generate file names from file_date
% then use records' timestamp (minute, second, msec)
% file_date like   01109100   yyy011   ddd091   hh00
yyydddhh=sscanf(file_date,'%03d%03d%2d');
newetl.year=ones(60,1)*(yyydddhh(1)+2000);
newetl.iyday=ones(60,1)* yyydddhh(2);
newetl.hour=ones(60,1)* yyydddhh(3);
day1= datenum(newetl.year,1,0);
mymday=day1 + yyydddhh(2) + yyydddhh(3)/24;

% first file, me1
infile_1=[indir 'me1' file_date '_raw.txt'];
fprintf('looking for %s\n',infile_1);
infmt=...
    '%2f%2f%3f %f %f %f %f %f %f %f %f %f %f %f %f %*3c %f %f %f %f %f %f %f %f %f %f %f %f %f %*3c %f %*[^\n]';
infid=fopen(infile_1,'rt');
if infid
    incell = textscan(infid,infmt,  'delimiter', ', ', 'headerlines', 1,  'emptyvalue', NaN);
    fclose(infid);
    fprintf(' length input %d\n',length(incell));
    % remove 2nd clause if looking for partial files
    if length(incell) == 29     && length(incell{1}) == 60
        rawdat=cell2mat(incell);
        rawdat=rawdat';
        % get time (each rec) minutes, seconds

        minsperday = 24 * 60;
        secsperday = 24*60*60;
        newetl.minute=rawdat(1,:)';
        newetl.second=rawdat(2,:)';
        daymins=rawdat(1,:)/minsperday; daysecs=rawdat(2,:)/secsperday;

        newetl.mday =  mymday + daymins' + daysecs';

        newetl.rainrate=rawdat(14,:);   % mm/hr   (org: rain rate)
        newetl.sst=rawdat(17,:); % snake  (degC)
        newetl.atmp=rawdat(12,:); % atmp
        newetl.hrh=rawdat(13,:); % hrh

        % next, file me2
        infile_2=[indir 'me2' file_date '_raw.txt'];
        infmt=...
            '%2f%2f%3f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %*[^\n]';
        infid = fopen(infile_2,'rt');
        if infid > 0
            incell = textscan(infid, infmt,  'delimiter', ', ', 'headerlines', 1,  'emptyvalue', NaN);
            fclose(infid);
            if length(incell) == 43  && length(incell{1}) == 60
                rawdat =  cell2mat(incell);  rawdat=rawdat';
                newetl.bpr=rawdat(23,:);    %pressure (mbar=hPa)
                newetl.swr=rawdat(13,:);  %Eppley PSP
                newetl.swrKz=rawdat(20,:);  %K&Z PSP
                [newetl.lwr, newetl.lwrKz] =get_lwr(rawdat);
            else
                fprintf('bad me2 filesize, skipping\n');
                % get rid of these so they'll be re-downloaded
                movefile(infile_1,'data/etl/parts');
                movefile(infile_2,'data/etl/parts');
                newetl=[];
            end
        end
    else
        fprintf('bad me1 filesize, skipping\n');
        newetl=[];
    end
end
% new(?) stratus 2011, mw
%03/31/2011 12:00 Campbell CR1000 (SN: 7911)
%0037271 12.85,25.6,1,1.001,3.282,5.087,0.036,-7999,20.03,65.64,0,5,3745,20,0.035,0.014,0,0.001,0.008,0,0,0,0.021,0.158,0,0,1.828,0.011
%  1           2    3 4     5     6     7      8    9
%0037271 12.85,25.6,1,1.001,3.282,5.087,0.036,-7999,20.03,
%10   11 12 13  14 15    16   17 18 ....
%65.64,0,5,3745,20,0.035,0.014,0,0.001,0.008,0,0,0,0.021,0.158,0,0,1.828,0.011

% timestamp is mmssmmm (minu, sec,msec)
% sample: 20100103  data/read/ met01000315_raw.txt

