clear all;

load mission;
time=epochsec-min(epochsec);

%%------------------------
%% Line Plot 
%%------------------------
sax = [min(S) max(S)];
fax = [min(F) max(F)]; Biolumax = [min(Biolum) max(Biolum)]; Bioflowax = [min(Bioflow) max(Bioflow)];
XL = 'mission time';



%%--------------------------------------------------
%% Color Dot plots
%%--------------------------------------------------
vars = ['   T   ';'   S   ';'Bioflow';' Biolum';'   F   ';'  OBS  '];
figure(1); giffig_wide; cmp=jet(256);
for V=1:length(vars);
   eval(['cvar = ' vars(V,:) ';']); 
   CAX(V,:)=caxis;
   cax=CAX(V,:); rng=linspace(cax(1),cax(2),256); 
   pstr=['axes(' '''' 'position' '''' ',P' int2str(V) ');']; eval(pstr);
   for p=1:length(cvar);
      [min k]=min(abs(rng-cvar(p)));
      g=plot(tdist(p),depth(p),'ko'); hold on;
      set(g,'markerfacecolor',cmp(k,:),'markeredgecolor',cmp(k,:),'markersize',5);
	end   
   set(gca,'ydir','reverse'); ylabel('Depth (m)'); 
   if V==3 | V==6
      xlabel('Distance (km)');
   else
      set(gca,'XTicklabel',[])
   end
   axis(AX);
   title(vartitl(V,:));
end

%%--------------------------------------------------
%% Up versus Down Cast
%%--------------------------------------------------
% Depth is positive
dZdt = [NaN; diff(depth)./diff(time)]; 
yoyo_discriminator = 0.1;	% m/s
going_up=find(dZdt<-1*yoyo_discriminator); 
going_down=find(dZdt>yoyo_discriminator); 

figure(2); giffig_wide; cmp=jet(256);
for V=1:length(vars);
   eval(['cvar = ' vars(V,:) ';']); 
   pstr=['subplot(2,3,' int2str(V) ')']; eval(pstr);
   plot(cvar(going_up),depth(going_up),'r.'); hold on;
   plot(cvar(going_down),depth(going_down),'b.');
   set(gca,'ydir','reverse'); ylabel('Depth (m)');
   title(vartitl(V,:));
end

return
