% syslog_dropweight.m
% Lats modified Sep 19, 2014
% Ben Raanan

% This script locates and logs "dropping drop weight" critical messages

% clear 

% workd = '~/Documents/MATLAB/MBARI/mat/syslog/';
% yr=2010:2014;
% vh={'Tethys','Daphne','Makai'};

global yr vh workd 


for q=1:length(yr);
    
    load([workd 'syslog_' num2str(yr(q)) '_comp.mat']);
    for v=1:length(fieldnames(syslog))
        comp = syslog.(vh{v}).fault.data.comp;
        
        % index "dropping drop weight" messages
        dwi = find(not(cellfun(@isempty,strfind(comp(:,11),'drop weight'))));
        
        % eliminate redundency
        [~,ui] = unique(comp(dwi,2),'stable');
        
        % log
        syslog.(vh{v}).fault.data.drop_weight = comp(dwi(ui),:);
        syslog.(vh{v}).fault.drop_weightTable = array2table(comp(dwi(ui),:),...
        'VariableNames', compHeader);
    end; clear v comp dwi ui 
    % save 
    %
    save(['~/Documents/MATLAB/MBARI/mat/syslog/syslog_' num2str(yr(q)) '_comp.mat'],...
        'filePath','mission','logName','syslog','compHeader')
    %}
end; clear q;

