% plot_os75,m
% =====================================================
% plot velocity vectors using OS75 adcp data
% =====================================================
% if plot station positions (=1)


close all
%figure
pgrd=0 ;
set(gcf,'color','w');
% load CODAS output data: contour
load Z:\oc415_2\adcp\contour_uv
load Z:\oc415_2\adcp\contour_xy
% averaging through the depth 250 m (22 x 10m + 30 m); 
% codas output is 10 m bins (8 m is setup of OS75)
nd=22;
u=uv(1:nd,1:2:end);
v=uv(1:nd,2:2:end);
% Take the depth-averaged velocity         
% um=nanmean(u);
% vm=nanmean(v);

% Take the velocity at 100m depth
 um=u(7,:);
 vm=v(7,:);

lon=xyt(1,:)-360;
lat=xyt(2,:);
time=xyt(3,:);
% set up time limit: it's not necessary to display the whole
% record from the very beginning; so, let's start from some point n1 
% until n2
%n1=1;n2=length(um);
%% CHANGE PLOT START TIME BY CHANGING n1 - CJS
n1=4100;
n2=4300;
% 
% n1=900;
% n2=length(um);

start=datestr(time(n1)+datenum(2005,1,1),0);
endt=datestr(time(n2)+datenum(2005,1,1),0);
% this line is to stretch a figure whether ship track is 
% meridional
plot([-67. -66.2],[30.8 30.8],'w-');
set(gca,'fontsize',16,'fontweight','bold')
hold on
plot(lon(n1:n2),lat(n1:n2),'m-','linewidth',2);
%ss=find(~isnan(lon)==1);
%n2=ss(end);

%h2=vecplot2(lon(n1:n2),lat(n1:n2),um(n1:n2),vm(n1:n2),0.3,'cm/sec')
h2=vecplot2(lon(n1:n2),lat(n1:n2),um(n1:n2),vm(n1:n2),0.9,'cm/sec');

plot(lon(n2),lat(n2),'d','markersize',10,'markerfacecolor','c',...
     'markeredgecolor','r');
grid

% add spar buoy position - CJS
%plot(-66-55.26/60,30+31.55/60,'r*')
%plot(-66-54.84/60,30+31.31/60,'r*','markersize',10)
%plot(-66-52.86/60,30+26.16/60,'r*','markersize',15) % as of 7/20 12:24Z
%plot(-66.887,30.377,'r*','markersize',15) % as of 7/20 12:24Z
						    
% plot seahorse launch position
%hp1 = plot(-66.9752,30.5087,'g^','markersize',15,'markerfacecolor','g'); ...
% sea horse at 7/21 0255:					    
%hp2 = plot(-66-55.3/60,30+26/60,'g^','markersize',10,'markerfacecolor','g');

% add station locations
load sta_list.dat
sta=sta_list(:,1);
stalat=sta_list(:,2)+sta_list(:,3)/60;
stalon=-sta_list(:,4)-sta_list(:,5)/60;
plot(stalon,stalat,'ko')
text(stalon,stalat,int2str(sta))

hold off
axis equal
title(['OS75: time (GMT): ',start,' -- ',endt]);
% 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  

ax=axis;
axrat = 1/cos(mean(ax(3:4))*pi/180);

set(gca,'DataAspectRatio',[1 1/axrat 1]);

xlabel('Longitude')
ylabel('Latitude')

% change final axis limits here:
axis([-67.9 -67.5 29.8 30.2])

set(gcf,'position',[1 55 1280 897])
