% compare

d =dir('../200*');


col={'r','g','b','k'}
figure(1);
clf
for i=1:length(d);
  load(['../' d(i).name '/ctd/CtdGrid.mat'])
  plot(cgrid.lon,cgrid.lat,'x','col',col{i},'markersi',12);
  hold on;
end;

%%
jmkfigure(2,2,0.8);clf
set(gcf,'defaultaxesfontsize',9);
set(gcf,'defaulttextfontsize',9);
for i=1:4
  load(['../' d(i).name '/ctd/CtdGrid.mat'])
  cgrid.sal=sw_salt(cgrid.c*10/sw_c3515,cgrid.t,repmat(cgrid.depths,1,size(cgrid.c,2)));
  cgrid.pden=sw_pden(cgrid.sal,cgrid.t,repmat(cgrid.depths,1,size(cgrid.c,2)),0)-1000;
  
  subplot3(4,3,3*(i-1)+1,'fontsi',9);
  facetsurface(abs(cgrid.x)/1e3,cgrid.depths,cgrid.t);
  hold on;
  [c,h]=contour(abs(cgrid.x)/1e3,cgrid.depths,cgrid.pden,[20:0.5:30]);
  clabel(c,h,'fontsi',8)
  set(h,'edgecol','k');
  axis ij;
  shading flat;
  caxis([6.5 10.5])
  axis([7 30 0 220]);
  pp = get(gca,'pos');
  hc=colorbar('peer',gca,'location','North','position',[pp(1)+0.7*pp(3) pp(2)+0.1*pp(4) pp(3)/4 0.013]);
  set(get(hc,'title'),'string','T [^oC]');
  if i==1;
    ylabel('DEPTH [m]');
    
  end;
  nm = datestr(datenum(str2num(d(i).name(1:4)),str2num(d(i).name(5:6)),1),'mmm yyyy')
  text(10,200,nm,'fontan','obl','fontsi',11)
  
  
  subplot3(4,3,3*(i-1)+2);
  facetsurface(abs(cgrid.x)/1e3,cgrid.depths,cgrid.sal);
  hold on;
  [c,h]=contour(abs(cgrid.x)/1e3,cgrid.depths,cgrid.pden,[20:0.5:30]);
  set(h,'edgecol','k');
  axis ij;
  shading flat;
  caxis([28 32])
  axis([7 30 0 220]);
  pp = get(gca,'pos');
  hc=colorbar('peer',gca,'location','North','position',[pp(1)+0.7*pp(3) pp(2)+0.1*pp(4) pp(3)/4 0.013]);
  set(get(hc,'title'),'string','S [psu]');

  subplot3(4,3,3*(i-1)+3);
  facetsurface(abs(cgrid.x)/1e3,cgrid.depths,cgrid.O2);
  hold on;
  [c,h]=contour(abs(cgrid.x)/1e3,cgrid.depths,cgrid.pden,[20:0.5:30]);
  set(h,'edgecol','k');
  axis ij;
  shading flat;
  axis([7 30 0 220]);
  caxis([0 9])
  pp = get(gca,'pos');
  hc=colorbar('peer',gca,'location','North','position',[pp(1)+0.7*pp(3) pp(2)+0.1*pp(4) pp(3)/4 0.013]);
  set(get(hc,'title'),'string','O2');
  if i==4
    xlabel('X [km]');
  end;
  
end;

if dop
  docprint('CtdComp','compareem.m');
end;

%%
jmkfigure(3,2,0.9);clf
for i=1:1:4
  load(['../' d(i).name '/ctd/CtdGrid.mat'])
  cgrid.sal=sw_salt(cgrid.c*10/sw_c3515,cgrid.t,repmat(cgrid.depths,1,size(cgrid.c,2)));
  cgrid.pden=sw_pden(cgrid.sal,cgrid.t,repmat(cgrid.depths,1,size(cgrid.c,2)),0)-1000;
  plot(cgrid.pden,cgrid.depths,'col',col{i});
  hold on;
  axis ij;
end;

  
