
% Plots underway and Wave Glider CO2 (later others...) already ID'd
%  as MBTS using loadWG_MBTS.m

atlas = '//atlas.shore.mbari.org/';

%inputs
 veh = 'wgTiny';
 dep = '20170307';

%load already-made data structures
 load([atlas 'jsevadjian/Waveglider/' veh '_' dep '/MBTSwg']);
 load([atlas 'jsevadjian/Waveglider/' veh '_' dep '/MBTSuw']);

%--%

%plot time-lon-CO2
% to choose which MBTS lines to compare

%plot
 figure('Units','inches','Position',[0 0 11 8.5]);
 ha = tight_subplot(2,1,0.03,0.2,0.2);
 set(ha,'NextPlot','add');
 %wg
  for n=1:size(wg.co2,1)
    scatter(ha(1),wg.co2{n}(:,1),wg.co2{n}(:,7),3,wg.co2{n}(:,3),'filled');
    scatter(ha(2),wg.co2{n}(:,1),wg.co2{n}(:,7),3,wg.co2{n}(:,4),'filled');
  end
 %uw
  for n=1:size(uw,1)
    scatter(ha(1),uw{n}(:,1),uw{n}(:,9),3,uw{n}(:,6),'filled');
  end
  linkaxes(ha,'x');

%--%

%axes param's
 ax.FontName = 'Arial';
 ax.FontSize = 10;
 ax.XLim = [-2 50];
 ax.XTick = [0:10:50];
 ax.XGrid = 'on';
 ax.YGrid = 'on';
 ax.NextPlot = 'add';
 ax.Box = 'on';
 ax.CLim = [ min([wg.co2{1}(:,1); uw{1}(:,1)]) ...
   max([wg.co2{end}(:,1); uw{end}(:,1)]) ];
 ax1.XTickLabel = [];

%plot
 figure('Units','inches','Position',[0 0 11 8.5]);
 colormap(jet);
 ha = tight_subplot(2,1,0.02,0.2,0.1);
 set(ha(1),ax,ax1);
 set(ha(2),ax);

 %wg
  for n=1:2%size(wg.co2,1)
   %co2
    f = find(~isnan(wg.co2{n}(:,3)));
    x = wg.co2{n}(f,7);
    y = wg.co2{n}(f,3);
    c = wg.co2{n}(f,1);
    axes(ha(1));
    patch([x; NaN],[y; NaN],[c; NaN],...
      'EdgeColor','interp','Marker','o','MarkerFaceColor','flat',...
      'MarkerSize',2);
   %pH
    x = wg.co2{n}(:,7);
    y = wg.co2{n}(:,2);
    c = wg.co2{n}(:,1);
    axes(ha(2));
    patch([x; NaN],[y; NaN],[c; NaN],...
      'EdgeColor','interp','Marker','o','MarkerFaceColor','flat',...
      'MarkerSize',2);
  end

 %uw
  for n=1:2%length(uw)
   %co2
    x = uw{n}(:,9);
    y = uw{n}(:,6);
    c = uw{n}(:,1);
    axes(ha(1));
    p = patch([x; NaN],[y; NaN],[c; NaN],...
      'EdgeColor','interp','Marker','+','MarkerFaceColor','flat',...
      'MarkerSize',3);
   %pH
    x = uw{n}(:,9);
    y = uw{n}(:,10);
    c = uw{n}(:,1);
    axes(ha(2));
    p = patch([x; NaN],[y; NaN],[c; NaN],...
      'EdgeColor','interp','Marker','+','MarkerFaceColor','flat',...
      'MarkerSize',3);
  end


 
 set(ha(1),'YLim',[315 398],'YTick',[320:20:380]);
  ylabel(['(' char(181) 'atm)'],'FontSize',ax.FontSize);
  title('Sea water xCO2','FontSize',ax.FontSize+2);

  set(get(ha(2),'XLabel'),'String',...
    'Distance from C1 (km)','FontSize',ax.FontSize+2);
  ylabel(['(' char(181) 'atm)'],'FontSize',ax.FontSize);
  title('Air xCO2','FontSize',ax.FontSize+2);

  c = colorbar;
  set(c,co,'Position',[ge(1)+ge(3)+0.02 ge(2) ...
    0.012 g1(2)+g1(4)-ge(2)]);

%save
 