clear all
close all

buoy_load = textread('1.001.txt','%f','commentstyle','shell');
anchor_load = textread('1.002.txt','%f','commentstyle','shell');
%counts = [counts ; textread('2.002.txt')];
%counts = [counts ; textread('3.002.txt')];

time = .25:.25:length(buoy_load)/4;
buoy_load = (buoy_load-0.004)*(10000/0.016);
anchor_load = (anchor_load-0.004)*(10000/0.016);

start_time = 165900.0;
delta_time = 1200;
if(start_time == 0)
    start_pt = 1
else
start_pt = start_time/.25;
end

if(delta_time ==0)
    end_pt = length(time);
else
end_pt = start_pt+delta_time/.25;
end


figure

h1 = plot(time(start_pt:end_pt)-start_time,buoy_load(start_pt:end_pt),'g-',time(start_pt:end_pt)-start_time,anchor_load(start_pt:end_pt),'b-');
xlabel('seconds','FontSize',16,'FontWeight','light');
ylabel('lbs','FontSize',16,'FontWeight','light');



[legend_h,object_h,plot_h,text_strings] = legend('Buoy Loads','Anchor Loads');
set(object_h(1),'FontSize',16)

%title('Loads below buoy and above anchor during anchor free-fall');

print -depsc2 'DeploymentLoads'

figure

l = end_pt-start_pt;
f = 4*(0:l/2)/l;

anchor_freq = fft(anchor_load(start_pt:end_pt));
buoy_freq = fft(buoy_load(start_pt:end_pt));

anchor_pwr = anchor_freq .* conj(anchor_freq)/(l);

plot(f(2:end),anchor_pwr(2:length(anchor_pwr)/2+1));
