% routine to color code the alongtrack data matrix "d"

load c:\gbs99\ship\el9904at.dat
d=el9904at;

% correct elink ship day
d(:,1)=d(:,1)-1-1/24;

%st=input('start time in yrday0_local: ');
st=105.5;et=107.2;

%specify acceptable values for each of 3 
minv=[5.4 32.3 .0];
maxv=[6.4 32.8 .15];

%et=input('end time in yrday1_local: ');
id=find(d(:,1)>=st&d(:,1)<=et);

lab=['  SST';' Salt';' Flur';' Flur'];

for j=1:3;
   
  %subplot
  subplot(2,2,j);
  %subpos(2,2,j);
   
  %var=menu('Variable?','temp','salt','flur');
  var=j;
  
  % make "var" the column number associated w/variable
  var=var+9;

  georbat;
  axis([-67.6 -67. 40.7 41.4])
  lllabel(5,10,40.9,41.1,-68,-67.5)
  
  % rid of spikes & unwanted values
  id2=find(d(id,var)>minv(j)&d(id,var)<maxv(j));
  
  % get range of acceptable values
  [out,mint,maxt]=rangejm(d(id(id2),var));
  
  k=0;
  cpt=zeros(length(id),3);
  for i=1:5:length(id);
    k=k+1;
    % form a color based on temperature
    cpt(k,:)=[(d(id(i),var)-mint)/out 0 1-(d(id(i),var)-mint)/out];
    if cpt(k,1)<1&cpt(k,3)<1;
     hcc=plot(d(id(i),3),d(id(i),2),'.','color',...
        cpt(k,:),'markersize',2AQ0);
      hold on;
    end;
  end;
    sdate=calday(99,d(id(1),1));
    edate=calday(99,d(id(length(id)),1));
    title([num2str(sdate(3)),'-',num2str(edate(3)),...
    '/',num2str(sdate(2)),'/19',num2str(sdate(1)),...
    lab(var-9,:),' red=',num2str(maxt),...
    ' blue=',num2str(mint)],...
 'fontsize',10)

  if j~=3;set(gca,'xticklabels',[]);xlabel(' ');end;
  if j==2;set(gca,'yticklabels',[]);ylabel(' ');end;
  
  if j==1;set(gca,'position',[.05 .55 .45 .40]);
  elseif j==2;set(gca,'position',[.55 .55 .45 .40]);
  elseif j==3;set(gca,'position',[.05 .05 .45 .40]);
  end;
  
     
end;


% % post values < 12
% id2=find(d(id,var)<12&d(id,var)>5);
% for i=1:length(id2);
%    text(d(id(id2(i)),5),d(id(id2(i)),6),num2str(d(id(id2(i)),7),1))
% end;
% plot(d(id(id2),3),d(id(id2),2),'.','color','b','markersize',30)
