% plot_adcp.m
% =====================================================
% plot velocity vectors using adcp data
% =====================================================
% if plot station positions (=1)
         pgrd=1
         sh=0 % if apply a filter on ship's velocity
         set(gcf,'color','w');
% load adcp data from adcp4quoddy.mat file
% the output from "get_adcp_oc415_1.m"
         load adcp4quoddy
% filter 
       if(sh==1)
% exclude all points where ship speed is lower then X kts (say, 7kts)
% ship speed (m/ses) is variable ship_U
       ship_w=3600/1842*sqrt(ship_U(1,:).^2+ship_U(2,:).^2);
       gg=find(ship_w < 7);
       ABS_U(:,gg)=nan;ABS_V(:,gg)=nan;
      end
% get depth averaged  vectors      
         u=nanmean(ABS_U);
         v=nanmean(ABS_V);
% plot vectors between n1 and n3 in gray,
% between n3 and n2 in color
        hi=1;
        n1=1370;n2=length(nav);
% n3 & n4 -- vector plotting        
        n3=1670;%n4=4070;
% plot navigation (ship track)
        plot([-67. -66.2],[30.8 30.8],'w-');
        hold on
        h1=plot(nav(1,n1:n2),nav(2,n1:n2),'m-','linewidth',2);
% plot vectors -- until n3, in grey, then from n3 to n2
     if(hi==1 & n3>n1)
         h1=vecplot2(nav(1,n1:n3-1),nav(2,n1:n3-1),u(n1:n3-1),v(n1:n3-1),.3,'cm/sec')
         set(h1,'color',[0.8 .8 .8])
     end
         h2=vecplot2(nav(1,n3:n2),nav(2,n3:n2),u(n3:n2),v(n3:n2),0.3,'cm/sec')
         set(h2,'color','b')
         plot(nav(1,n2),nav(2,n2),'d','markersize',8,'markerfacecolor','c',...
         'markeredgecolor','r');
         pp=axis;
         axis([pp(1)-.1 pp(2)+.1 pp(3)-.1 pp(4)+.1]);
         grid
         hold off
         axis equal
         title(['NB150:  time (GMT): ',starttime,' -- ',endtime]);
        
% plot station positions
        if(pgrd==1)
        load coord_mtx_05new.txt;
        c=coord_mtx_05new;
        pp=axis
% plot the only numbers inside axis
        ff=find(c(:,3)>pp(1) & c(:,3)<pp(2) & c(:,2)>pp(3) & c(:,2)<pp(4));
      for i=[1:length(ff)]         
        text(c(ff(i),3),c(ff(i),2),['   ',num2str(c(ff(i),1))],'fontsize',7);
      end
      hold on
        plot(c(ff,3),c(ff,2),'sm','markersize',7)
      
  end% BATS site coordinates
   
     hold off
        
        xlabel('Longitude')
        ylabel('Latitude')
