% routine to plot instrument posn from eventlog

% having code instruments with
% zpn=1,Pump/CTD=2, MOC1/4=3,MOC1=4,Drifter=5,BongoSB=6,SeabirdCTD=7
lab=['ZooPlkNet  ';...
     'Seabird 911';...
     '   MOC1/4  ';...
     '     MOC1  ';...
     '  Drifter  ';...
     'Bongow/SB19';...
     'Seabird 19 ';...
     'Mooring    '];

% open file
%load /home3/ocn/jmanning/gbs97/text/o303sort.txt
load c:\gbs99\events\o339sort.txt
d=o339sort;
% expects lat,lon,sta,cast,code,and s/e (where "s/e" is 0/1)

% Make xx plots, one for each instrument
for k=[2];
  id=find(d(:,5)==k&d(:,6)==0);
  figure(k)
   
  %make subplots
  for is=1:1;
%    subpos(2,2,is); 
%    subplot(3,1,is)
    % in the case of bongo do only those AFTER the grid?????
    % where in case of oc303 station 145 is the last of grid
    if k==6;id2=find(d(id,3)<0);id=id(id2);end;
 
    georbat;
    %  sizesym(d(id,2),d(id,1),-20*ones(length(id),1),1,d(id,4),'k');
    
    ha=['  left';'center';' right'];
    va=['   top';'middle';'bottom'];
    % divide the postings by thirds and change the alignment
    third=length(id)/3;
    load ccodemat;
    for i=1:length(id);
       if d(id(i),7)==0;d(id(i),7)=7;end;
      text(d(id(i),2),d(id(i),1),num2str(d(id(i),4)),...
         'fontsize',6,'horizontalalignment',ha(ceil(i/third),:),...
         'verticalalignment',va(ceil(i/third),:),...
         'color',ccode(d(id(i),7),:),...
         'clipping','on')
 %     plot(d(id(i),2),d(id(i),1),'.','clipping','on','color',ccode(d(id(i),7),:));
      hold on;
    end;
    lar=max(d(id,1))-min(d(id,1));
    lor=max(d(id,2))-min(d(id,2));
    axis([min(d(id,2))-lor/10 max(d(id,2))+lor/10 min(d(id,1))-lar/10 max(d(id,1))+lar/10]);
    title(['OC339 ',lab(k,:),' Cast#'],'fontsize',16);
  %axis('equal')
  
  % Label Transects
  text(-67.1,41.15,'Transect#1','color',ccode(1,:));
  text(-67.1,41.1,'Transect#2','color',ccode(2,:));
  text(-67.1,41.05,'Transect#3','color',ccode(3,:));
  text(-67.1,41.0,'Transect#4','color',ccode(4,:));
  
  lllabel;
  % position subplots
  %  if is==1;axis([-67.5 -67.2 41. 41.2]);set(gca,'position',[.1 .7 .6 .275]);lllabel(10,10,40.8,41.4,-67.5,-67);
  %       title('All MOC1 Tows');xlabel(' ');
  %    elseif is==2;axis([-67.35 -67.25 41.07 41.12]);set(gca,'position',[.1 .39 .6 .265]);title('Site 4');
  %       lllabel(2,3,40.8,41.4,-67.4,-67);xlabel(' ');
  %  elseif is==3;set(gca,'position',[.1 .075 .6 .275]); axis([-67.3 -67.2 41.00 41.07]);title('Site 7');lllabel(2,3,40.8,41.4,-67.4,-67);
  %  end;
  end;
  %if is~=3;set(gca,'xticklabels',' '); set(gca,'yticklabels',' ');xlabel(' ');ylabel(' ');end;
  
end;
orient tall

 