% plot_os75.m
% =====================================================
% plot velocity vectors using OS75 adcp data
% =====================================================
% if plot station positions (=1)
%clf
figure
pgrd=0 
set(gcf,'color','w');
% load CODAS output data: contour
load /home/howitt/adcp/oc415/contour/contour_uv
load /home/howitt/adcp/oc415/contour/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);
% get averages         
um=nanmean(u);vm=nanmean(v);
lon=xyt(1,:)-360;
for ii = 1:length(lon)-1
 temp_lon(ii) = lon(ii+1);
end
temp_lon(length(lon)) = NaN;
lon=temp_lon;

lat=xyt(2,:);
for ii = 1:length(lat)-1
  temp_lat(ii) = lat(ii+1);
end
temp_lat(length(lat)) = NaN;
lat = temp_lat;
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);
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-56.497/60,30+32.250/60,'r*')

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')
