% last updated 11/08/2001
% en361_xbt_sst.m 
% % &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
%      ADCP    ADCP     ADCP   ADCP    ADCP
% &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
% load integrated ADCP velocity
    load oc404_v1.m3d
    ad=oc404_v1;
    lona=ad(:,2);
    lata=ad(:,3);
    u=ad(:,4);v=ad(:,5);
    ff=find(ad(:,1)>=time(2375));
    uf=filter2(hh',ad(:,4));
    vf=filter2(hh',ad(:,5));
    q1=quiver(lona(ff),lata(ff),uf,vf,4,'.');
    set(q1,'color',[0.5 .0 .5])
    axis([-66   -58   29.5   31.5])
 
% load raw adcp data
    load adcp4quoddy
% get integrated velocity 0:100; 100:400; and 0:400
    for i=[1:2835]
        u100(i)=nanmean(ABS_U(1:12,i));
        v100(i)=nanmean(ABS_V(1:12,i));
        u300(i)=nanmean(ABS_U(12:64,i));
        v300(i)=nanmean(ABS_V(12:64,i));
        u400(i)=nanmean(ABS_U(1:64,i));
        v400(i)=nanmean(ABS_V(1:64,i));  
   end
% filter each part of the adcp record

    hh=fspecial('average',[1,13]);
    uf100=filter2(hh,u100);
    vf100=filter2(hh,v100);
    uf300=filter2(hh,u300);
    vf300=filter2(hh,v300);
    uf400=filter2(hh,u400);
    vf400=filter2(hh,v400);
    
    n1=2375;n2=2835;
    subplot(311)
    q1=quiver(nav(1,n1:n2),nav(2,n1:n2),u100(n1:n2),v100(n1:n2),4,'.');
    set(q1,'color',[0.5 .0 .5])
    axis([-66   -58   29.5   31.5])
    
     subplot(312)
    q1=quiver(nav(1,n1:n2),nav(2,n1:n2),uf100(n1:n2),vf100(n1:n2),4,'.');
    set(q1,'color',[0.5 .0 .5])
    axis([-66   -58  29.5   31.5 ])

     subplot(313)
    q1=quiver(nav(1,n1:n2),nav(2,n1:n2),uf100(n1:n2),vf100(n1:n2),4,'.');
    set(q1,'color',[0.5 .0 .5])
    axis([-66   -58  29.5   31.5 ])
    
    figure
    subplot(211)
    plot(time(n1:n2),u100(n1:n2),'b-')
    hold on
    plot(time(n1:n2),u300(n1:n2),'r-')
    plot(time(n1:n2),u400(n1:n2),'k-')
    plot(ad(ff),u(ff),'g-')
    hold off
    
    subplot(212)
    plot(time(n1:n2),v100(n1:n2),'b-')
    hold on
    plot(time(n1:n2),v300(n1:n2),'r-')
    plot(time(n1:n2),v400(n1:n2),'k-')
    plot(ad(ff),v(ff),'g-')
    hold off

%   kino_wide_pic_hr2
%   1 : 347 : 492 : 618 
    contourf3(xe,ye,ze,20);
    caxis([10.5 12.5])
    hold on
    plot(xb(f1,5),xb(f1,4),'.m')
    n1=492;n2=618;
    q1=quiver(lo(n1:n2),la(n1:n2),uu(n1:n2),vv(n1:n2),4,'.')
    set(q1,'color',[0.5 .0 .5])
    
    plot(lo(n1:n2),la(n1:n2),'m-')
    hold off
    axis([-60.5 -58.95 31 32.])
     
    box on
    setaxis
    hb=colorbar('horiz')
    set(hb,'position',[0.600    0.0400    0.30    0.02])
    set(gca,'position',[0.1300    0.1100    0.7750    0.8150])
    xlabel('Latitude')
    ylabel('Longitude')
    title('Cold eddy C2: temperature at 700m & velocity from ADCP')
    whitebg([.9 .9 .9])
    grid
    set(gcf,'color','w')
    fig2jpeg('fragm_3_700.jpg')
    
% find coordinates of the adcp track       
      for i=[1:75]
        lx=0.005;ly=0.005;
        ff=find(abs(lon(i)-ad(:,2))<lx & abs(lat(i)-ad(:,3))< ly);
        while length(ff)~=1,
        ff=find(abs(lon(i)-ad(:,2))<lx & abs(lat(i)-ad(:,3))< ly);
        if(isempty(ff)==1)
        lx=2*lx;ly=2*ly;
        else
        if(length(ff)>1)
        lx=0.75*lx;ly=0.75*ly;
        end
      end
     end
         td(i)=ff;
     end

    ad(td(length(td))+1:length(ad),:)=[];
    ad(td(56)+1:td(58)-1,:)=[];
    ad(1:td(1)-1,:)=[];   
    td=td-(td(1)-1);

      for i=[1:75]
        lx=0.005;ly=0.005;
        ff=find(abs(lon(i)-ad(:,2))<lx & abs(lat(i)-ad(:,3))< ly);
        while length(ff)~=1,
        ff=find(abs(lon(i)-ad(:,2))<lx & abs(lat(i)-ad(:,3))< ly);
        if(isempty(ff)==1)
        lx=2*lx;ly=2*ly;
        else
        if(length(ff)>1)
        lx=0.75*lx;ly=0.75*ly;
        end
      end
     end
         td(i)=ff;
     end

   lona=ad(:,2);
    lata=ad(:,3);
 
% filter each part of the adcp record

    hh=fspecial('average',[13,1]);

    u1=filter2(hh,ad(td(1):td(56),4));
    v1=filter2(hh,ad(td(1):td(56),5));

    u2=filter2(hh,ad(td(58):td(75),4));
    v2=filter2(hh,ad(td(58):td(75),5));


   addpath /bb2/vk/colorado/
   addpath /usr/people/valery/bin/
   set(gcf,'DefaultAxesFontsize',8)
   kino_wide(3566)

    hold on

    q1=quiver(lona(td(1)+3:2:length(u1)),lata(td(1)+3:2:length(u1)),...
    u1(4:2:length(u1)),v1(4:2:length(u1)),4,'.')
    set(q1,'color',[.2 .2 .2])
    hold on
    plot(lona(td(1)+3:2:length(u1)),lata(td(1)+3:2:length(u1)),'k-')
    q2=quiver(lona(td(58)+3:2:length(ad)),lata(td(58)+3:2:length(ad)),...
    u2(4:2:length(u2)),v2(4:2:length(u2)),4,'.')
    set(q2,'color','b')
    plot(lona(td(58)+3:2:length(ad)),lata(td(58)+3:2:length(ad)),'k-')
    hold off

 
% &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
% GARBIDGE   GARBIDGE   GARBIDGE   GARBIDGE   GARBIDGE  
% &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

   axis([-73 -62. 28. 37.])
   for i=[1:38,68:72]
   h3=text(-lon(i)+0.05,lat(i)+0.2,...
   [num2str(rr(i))],'color','k','HorizontalAlignment','left',...
   'fontsize',6);
   end
   for i=[39:57]
   h4=text(-lon(i),lat(i)-0.15,...
   [num2str(rr(i))],'color','k','VerticalAlignment','top',...
   'fontsize',6);
   end
   for i=[58:67]
   h5=text(-lon(i)-0.15,lat(i)+0.15,...
   [num2str(rr(i))],'color','k','VerticalAlignment','bottom',...
   'fontsize',6);
   end



    for i=[1:15]
    hold on
    y=lat(i);
    plot(y,-x(1,1),'vk','markersize',4,'markerfacecolor','b');

    if(n(i)<10)
    text(y+0.02,-x(1,2*i)+35,[num2str(n(i))],'color','k',...
    'VerticalAlignment','bottom','fontsize',7)
    else
    text(y+0.04,-x(1,2*i)+35,[num2str(n(i))],'color','k',...
    'VerticalAlignment','bottom','fontsize',7)
    end
 
    end

    hold off

    for i=[1:7]
    h1=refline(0,-100*i);
    set(h1,'color','b','linestyle',':')
    end

    for i=[1:15]
    y=33.2-0.2*i;
    hold on
    h2=line([y y],[-x(1,1) -x(1183,1)])
    set(h2,'color','b','linestyle',':');
    end

    hold off
%   set(f1,'Position',[32.011       45.318      1]);
    set(gcf,'PaperPosition',[2 1 4.5 9.0])

    return
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    str1(1)={'36.5^oN'};
    str1(2)={'72.4^oW'};
    text(xx(1)-25,16,str1,'fontsize',6);

    str2(1)={'33.7^oN'};
    str2(2)={'71.0^oW'};
    text(xx(17)-25,16,str2,'fontsize',6);
    str3(1)={'30.3^oN'};
    str3(2)={'68.4^oW'};
    text(xx(39)-25,16,str3,'fontsize',6);
    str4(1)={'29.6^oN'};
    str4(2)={'64.7^oW'};
    text(xx(57)-25,16,str4,'fontsize',6);
    str5(1)={'30.8^oN'};
    str5(2)={'63.5^oW'};
    text(xx(68)-25,16,str5,'fontsize',6);
