clear
close all
R=input('What is the name of the data file (eg, mbari_deploy)?  ','s');
eval(['load ', R])

N=find(abs(z_t(:,1)==0)); 
a=1:N(1);
dt=t(2)-t(1);
t=t(a);
Ten=T_t(a,1:6);

deploy_seconds = [45,165,285,405,534,645,765];

deploy_a_mean = [996,1909,2189,2301,2449,2444,165];
deploy_a_max  = [2008,2426,2498,2722,2788,3293,198];

deploy_b_mean = [1905,2616,2737,2659,2717,2956,1336];
deploy_b_max = [2590,2981,3047,3050,3098,3791,1516];




figure(1)
clf
%plot(t,Ten(:,1),t,Ten(:,6),'r:',t,Ten(:,1),'k-.')
plot(t,Ten(:,6),t,Ten(:,1),'k-.')
hold on
plot(deploy_seconds,deploy_b_max,'r*',deploy_seconds,deploy_a_max,'r+')
legend('Below the buoy','At the anchor','Buoy Load Cell','Anchor Load Cell',2)
title('Tension below the surface buoy and at the anchor, predicted and measured')
xlabel('Time (s)')
ylabel('Tension (lbf)')
print -depsc -tiff -r300 tensions
print -dpng -r300 tensions

figure(2)
clf
axis image
plot(x,z,'r.',x_s,z_s)
%The red dotted line is just before the anchor was dropped
Tf=-round(x_t(N(1)-1));
title(['Final Location = -',num2str(Tf),'meters.   Time to reach bottom = ',num2str(t(N(1)-1)),' seconds'])
text(x(100),z(1)+50,'initial')
text(-500,500,'final')
ylabel('Depth (m)')
xlabel('Horizontal coordinate (m)')
print -depsc -tiff -r300 positions
print -dpng -r300 positions

figure(3)
plot(s, T, 'r.', s,T_s)
maxT=round(max(max(Ten)));
title(['Tension snapshots, Max Tension = ',num2str(maxT)])
ylabel('Tension (lbf)')
xlabel('Lagrangian coordinate (m)')
print -depsc -tiff -r300 tensions-snap
print -dpng -r300 tensions-snap

eval(['load ', R,'-Global'])

figure(4)
U = U_t(1:length(t),:);
W = W_t(1:length(t),:);
plot(t,U(:,6)*1.943,t,1.943*W(:,1),527,3.8,'r*')
title('Horizontal Speed of Bouy and Vertical Speed of Anchor (kts)')
legend('Horizontal Speed of Bouy','Vertical Speed of Anchor','Velocity from GPS on Buoy',4)
xlabel('Time (s)')
ylabel('Kts')
print -depsc -tiff -r300 speeds
print -dpng -r300 speeds


['The final location of the anchor is ', num2str(Tf),' meters behind where it was dropped.']
['It took ', num2str(t(N(1)-1)), ' seconds for the anchor to reach the bottom.']
['The maximum tension achieved anywhere during deployment is ', num2str(maxT), ' lbf']



