%sedtrap_plot.m


if (1)
    clear;
    dir = '2017Oct31';
    path = sprintf( '../%s/parsed/CPF%s.mat',dir,dir);
    load(path);
    path = sprintf( '../%s/parsed/CPF%s_ENG.mat',dir,dir);
    load(path);
end

clear('pt','p')

%fl
figure(1); hold on;

for prof=1:size(FL,1)
    numdat=1;k=1;
    clear('y','z');
    %first strip out the nans
    for j=1:1:size(FLd,2)
        if(~isnan(FLd(prof,j)) && FLd(prof,j)<0)
            y(prof,numdat)=FLd(prof,j);
            z(prof,numdat)=FL(prof,j);
            numdat=numdat+1;
        end
        if(~isnan(P(prof,j)))
           p(k) = P(prof,j);
           pt(k) = DATETIMENUM(prof,j);
           k=k+1;
        end  
    end
    %disp(p); pause;

    %get time   
    if (prof==1)
        x1 = datenum(DATETIMENUM(prof+1,1)-minutes(5));
    else
        tdiff = (DATETIMENUM(prof+1,1)-DATETIMENUM(prof,1) )/2;
        x1 = DATETIMENUM(prof+1,1)-tdiff;
    end
    
    
    if (prof==size(FL,1))
        x2 = datenum(DATETIMENUM(prof+1,1)+minutes(5));
    else
        tdiff = (DATETIMENUM(prof+2,1)-DATETIMENUM(prof+1,1) )/2;
        x2 = DATETIMENUM(prof+1,1)+tdiff;
    end
    


    if(exist('y'))
        for i=2:1:size(y,2)
            fill([x1 x2 x2 x1],[y(prof,i) y(prof,i) y(prof,i-1) y(prof,i-1)],z(prof,i),'EdgeColor','none');
        end
    end

    
    %do float depth versus time
    if (exist('pt'))
        s = plot( pt,p,'k');
    end
    clear('pt','p')
    
    if (exist('SEDTRAP'))
        if(exist('SEDTRAP.homep'))
            for m = 1:1:size(SEDTRAP(prof).sedhome,2)
                plot(SEDTRAP(prof).sedhome(m),SEDTRAP(prof).homep(m),'gx');
            end
        end
        %if(exist('SEDTRAP.sedadv'))
        for m = 1:1:size(SEDTRAP(prof).sedadv,2)
            plot(SEDTRAP(prof).sedadv(m),SEDTRAP(prof).advp(m),'o',...
                'MarkerEdgeColor','k','MarkerFaceColor','y',...
                'MarkerSize',10);
        end
        %end
    end
    
end %end for prof





outstr = sprintf('Fl sig');
title(outstr);
colorbar;
datetick;
xlabel('Time');
ylabel('dBar');
grid on;