%  plotO2z.m - plot vertical profile of dissolved oxygen versus depth.
%              o2 units can be umol/kg or ml/l controlled by o2units.
%    needs variables set: DataDir CruiseName DepthResolution ctdcastlist 
%                         o2range deprange InfoString o2units
%    sets variables: none
%    calls: readctd

dep=[-1 01];
O2=[-1 0];
figure;

plot(O2,dep);
axis([o2range deprange]);

title('Oxygen vs depth');
if o2units == 1 
   xlabel('Dissolved Oxygen (umol/kg)');
else
   xlabel('Dissolved Oxygen (ml/l)');
end
ylabel('Depth (m)');
text(o2range(1) + .6*(o2range(2)-o2range(1)),.75*deprange(1),InfoString);
text(o2range(1) + .6*(o2range(2)-o2range(1)),.81*deprange(1),CruiseName);
hold on;

for cast = ctdcastlist
  file= [DataDir '/' CruiseName '/Ctd/' DepthResolution '/ctd' castnum(cast) '.dat'];
   [nlines,ndepths,desc,p,t,s,pt,r0,r1,bv,t0,t1,s0,s1,o2,par,tr,fl] = readctd(file);
  dep=-p;
  plot(o2*o2units,dep);

end

hold off;

