%  PlotSigVol.m
%     Plot the thickness and volume of density layers
%

plotDep=0;
plotThick=1;
plotNegTh=0;

%CruiseName='NBP0103';
CruiseName='NBP0104';

load([CruiseName '.gridstns.mat']);
load([CruiseName '.siggrid.mat']);

[m nsig]=size(siglevels);
[n,nx]=size(xi);
[n,ny]=size(yi);
[xxi,yyi]=meshgrid(xi,yi);

if plotNegTh
   for isig=1:nsig-1
     ThickSig=DepSigGrid(:,:,isig+1)-DepSigGrid(:,:,isig);
     figure
     i=find(ThickSig < 0);
     plot(xxi(i),yyi(i),'r*');
     title(['Negative Thickness of between sigma ' ...
           num2str(siglevels(isig+1)) ' and ' num2str(siglevels(isig))]);
     axis([0 500 -50 300]);
     hold on;
     i=find(isnan(ThickSig));
     plot(xxi(i),yyi(i),'go');
     text(50,0,CruiseName)
     hold off
  end
end
if plotThick
   for isig=1:nsig-1
     ThickSig=DepSigGrid(:,:,isig+1)-DepSigGrid(:,:,isig);
     i=find(ThickSig < 0);
     ThickSig(i)=0;
     figure
     i=find(~isnan(ThickSig));
     if(~isempty(i))
       [Con,Han]=contour(xxi,yyi,ThickSig);
       clabel(Con,Han);
     else
       text(250,200,'Density surfaces do not occur')
     end
     title(['Thickness of between sigma ' ...
           num2str(siglevels(isig+1)) ' and ' num2str(siglevels(isig))]);
     axis([0 500 -50 300]);
     hold on;
     i=find(isnan(ThickSig));
     plot(xxi(i),yyi(i),'go');
     text(50,0,CruiseName)
     hold off
  end
end
if plotDep
   for isig=1:nsig
     figure
     i=find(~isnan(DepSigGrid(:,:,isig)));
     if(~isempty(i))
       [Con,Han]=contour(xxi,yyi,DepSigGrid(:,:,isig));
       clabel(Con,Han);
     else
       text(250,200,'Density surface does not occur')
     end
     title(['Depth of sigma ' num2str(siglevels(isig))]);
     axis([0 500 -50 300]);
     hold on;
     i=find(~isnan(PTsig(isig,:)));
     plot(xgrid(i),ygrid(i),'r*');
     i=find(isnan(DepSigGrid(:,:,isig)));
     plot(xxi(i),yyi(i),'go');
     text(50,0,CruiseName)
     hold off
  end
end


