% go_etl_flux
% Run manually, nce per day, when a new file appears
% e.g. K:\RHB\flux\Processed\STRATUS_2011_PSD_flux_5min_2011_04_04_094.txt
% this code will copy it to data/etl/proc/new, process, move to proc/read
%
set_up
flux=[];

infiles=dir('data/etl_proc/read/*flux_5min*.txt');
if ~isempty(infiles)
    for iiff=1:length(infiles)
        infile=['data/etl_proc/read/' infiles(iiff).name ];
        [newflux] = get_etl_flux(infile,year);
        if isstruct(newflux)
            if isstruct(flux)
                flux=structsadd(flux,newflux);
            else
                flux=newflux;
            end
        else
            disp(['error in ' infile]);
        end
        [j,idx,j]=unique(flux.mday);
        flux = structsort(flux, idx);
        save etl_flux.mat flux
  
    end
end
if isstruct(flux)
    [j,idx,j]=unique(flux.mday);
    flux = structsort(flux, idx);
    save etl_flux.mat flux
    % now get hourly average
    flux=rmfield(flux,'cog');
    flux=get_avg_wdirs(flux,'wspd_true', 'wdir_true');
    save etl_flux1h.mat flux
end

