%sci_prof_bar.m
%load FAUCON.mat

sbd='';
%fig=2;
yin=P;
zin=T;
%prof=17; 

%temp
figure(4); hold on;
if(WAVE)
    set(gcf,'visible','off');
end
for prof=1:1:size(yin,1)
    numdat=1;
    clear('y','z');
    %first strip out the nans
    for j=1:1:size(yin,2)
        if(~isnan(yin(prof,j)) && yin(prof,j)<0)
            y(prof,numdat)=yin(prof,j);
            z(prof,numdat)=zin(prof,j);
            numdat=numdat+1;
        end
    end


    %get time   
    if (prof==1)
        x1 = datenum(CPtime(prof,1)-minutes(5));
    else
        tdiff = (CPtime(prof,1)-CPtime(prof-1,1) )/2;
        x1 = CPtime(prof,1)-tdiff;
    end
    
    
    if (prof==size(yin,1))
        x2 = datenum(CPtime(prof,1)+minutes(5));
    else
        tdiff = (CPtime(prof+1,1)-CPtime(prof,1) )/2;
        x2 = CPtime(prof,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

end %end for prof
outstr = sprintf('%s Temp',sbd);
title(outstr);
colorbar;
datetick;
xlabel('Time');
ylabel('dBar');
grid on;
print(outfig,'-djpeg');
if(WAVE)
    close gcf;
    clear gcf;
end


%sal
yin=P;
zin=S;
figure(5); hold on;
if(WAVE)
    set(gcf,'visible','off');
end
for prof=1:1:size(yin,1)
    numdat=1;
    clear('y','z');
    %first strip out the nans
    for j=1:1:size(yin,2)
        if(~isnan(yin(prof,j)) && yin(prof,j)<0)
            y(prof,numdat)=yin(prof,j);
            z(prof,numdat)=zin(prof,j);
            numdat=numdat+1;
        end
    end


    %get time   
    if (prof==1)
        x1 = datenum(CPtime(prof,1)-minutes(5));
    else
        tdiff = (CPtime(prof,1)-CPtime(prof-1,1) )/2;
        x1 = CPtime(prof,1)-tdiff;
    end
    
    
    if (prof==size(yin,1))
        x2 = datenum(CPtime(prof,1)+minutes(5));
    else
        tdiff = (CPtime(prof+1,1)-CPtime(prof,1) )/2;
        x2 = CPtime(prof,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

end %end for prof
outstr = sprintf('%s Salinity',sbd);
title(outstr);
colorbar;
datetick;
xlabel('Time');
ylabel('dBar');
grid on;
print(outfigS,'-djpeg');
if(WAVE)
    close gcf;
    clear gcf;
end


