function [ output_args ] = plotongraph(nboffloater, jtlagt, totaltime)
%%%%%%%%%% 



close all

figure(1)

fid = fopen('../obs_float/obs_float_test.dat', 'rb');
fseek(fid, 0, 'eof');
fileSize = ftell(fid);
frewind(fid);
data = fread(fid, fileSize, 'uint8');
numLines = sum(data == 10) + 1;
fclose(fid);
m=numLines-1;
n=m/nboffloater;


load ../obs_float/obs_float_test.dat;
counterobs=0;
for g=1:nboffloater
    
x=obs_float_test (counterobs+1:2:counterobs+n,4);
y=obs_float_test (counterobs+2:2:counterobs+n,4);
plot(x(1),y(1),'+')
hold on;
plot(x(n/2),y(n/2),'>')
hold on;
plot(x(1:n/2),y(1:n/2),'+');
hold on;
plot(x(1:n/2),y(1:n/2),'-r')
hold on;
counterobs=counterobs+n;
end


fid = fopen('../obs_float/rfloat_total.dat', 'rb');
fseek(fid, 0, 'eof');
fileSize = ftell(fid);
frewind(fid);
data = fread(fid, fileSize, 'uint8');
numLines = sum(data == 10) + 1;
fclose(fid);
p=numLines-1;
u=p/nboffloater;

countercorr=0;


load ../obs_float/rfloat_total.dat
ligneobs=0;
for d=1:nboffloater
x2=rfloat_total(countercorr+1:countercorr+u,4);
y2=rfloat_total(countercorr+1:countercorr+u,3);
ligne=ligneobs+1;
for h=1:jtlagt:u
    x2(h)=obs_float_test(ligne,4);
    y2(h)=obs_float_test(ligne+1,4);
    ligne=ligne+2;
end
[k,h]=size(x2);
plot(x2(1),y2(1),'+')
hold on;
plot(x2(k),y2(k),'>')
hold on;
plot(x2(1:k),y2(1:k),'+')
hold on;
plot(x2(1:k),y2(1:k),'-g')
hold on;
ligneobs=ligneobs+n;
countercorr=countercorr+u;
end

fid = fopen('../obs_float/third_observation.dat', 'rb');
fseek(fid, 0, 'eof');
fileSize = ftell(fid);
frewind(fid);
data = fread(fid, fileSize, 'uint8');
numLines = sum(data == 10) + 1;
fclose(fid);
m5=numLines-1;
n5=m5/2;
load ../obs_float/third_observation.dat;

x5=third_observation (1:2:m5,4);
y5=third_observation (2:2:m5,4);
x=x+1;
y=y+1;
plot(x5(1),y5(1),'+')
hold on;
plot(x5(n5),y5(n5),'>')
hold on;
plot(x5(1:n5),y5(1:n5),'+');
hold on;
plot(x5(1:n5),y5(1:n5),'-m')
hold on;

%%% To show the same path but forwarded with the bck that is beeing used 
fid = fopen('../obs_float/generated_fwd.dat', 'rb');
fseek(fid, 0, 'eof');
fileSize = ftell(fid);
frewind(fid);
data = fread(fid, fileSize, 'uint8');
numLines = sum(data == 10) + 1;
fclose(fid);
p3=numLines-1;
u3=p3/3;

load ../obs_float/generated_fwd.dat
x11=generated_fwd (1:2:u3,4);
y11=generated_fwd (2:2:u3,4);

plot(x11(1),y11(1),'+')
hold on;
plot(x11(u3/2),y11(u3/2),'>')
hold on;
plot(x11(1:u3/2),y11(1:u3/2),'+');
hold on;
plot(x11(1:u3/2),y11(1:u3/2),'-b')
hold on;

x13=generated_fwd (u3+1:2:2*u3,4);
y13=generated_fwd (u3+2:2:2*u3,4);

plot(x13(1),y13(1),'+')
hold on;
plot(x13(u3/2),y13(u3/2),'>')
hold on;
plot(x13(1:u3/2),y13(1:u3/2),'+');
hold on;
plot(x13(1:u3/2),y13(1:u3/2),'-b')
hold on;

x15=generated_fwd (2*u3+1:2:p3,4);
y15=generated_fwd (2*u3+2:2:p3,4);

plot(x15(1),y15(1),'+')
hold on;
plot(x15(u3/2),y15(u3/2),'>')
hold on;
plot(x15(1:u3/2),y15(1:u3/2),'+');
hold on;
plot(x15(1:u3/2),y15(1:u3/2),'-b')
hold on;

%%%% To show the same path but forwarded with the mean that is beeing used 
fid = fopen('../obs_float/forwardedbymean.dat', 'rb');
fseek(fid, 0, 'eof');
fileSize = ftell(fid);
frewind(fid);
data = fread(fid, fileSize, 'uint8');
numLines = sum(data == 10) + 1;
fclose(fid);
p4=numLines-1;
u4=p4/3;
% 
load ../obs_float/forwardedbymean.dat
x11=forwardedbymean (1:2:u4,4);
y11=forwardedbymean (2:2:u4,4);
% x=x+1;
% y=y+1;
plot(x11(1),y11(1),'+')
hold on;
plot(x11(u4/2),y11(u4/2),'>')
hold on;
plot(x11(1:u4/2),y11(1:u4/2),'+');
hold on;
plot(x11(1:u4/2),y11(1:u4/2),'-r')
hold on;

x13=forwardedbymean (u4+1:2:2*u4,4);
y13=forwardedbymean (u4+2:2:2*u4,4);
% x3=x3+1;
% y3=y3+1;
plot(x13(1),y13(1),'+')
hold on;
plot(x13(u4/2),y13(u4/2),'>')
hold on;
plot(x13(1:u4/2),y13(1:u4/2),'+');
hold on;
plot(x13(1:u4/2),y13(1:u4/2),'-r')
hold on;

x15=forwardedbymean (2*u4+1:2:p4,4);
y15=forwardedbymean (2*u4+2:2:p4,4);
% x3=x3+1;
% y3=y3+1;
plot(x15(1),y15(1),'+')
hold on;
plot(x15(u4/2),y15(u4/2),'>')
hold on;
plot(x15(1:u4/2),y15(1:u4/2),'+');
hold on;
plot(x15(1:u4/2),y15(1:u4/2),'-r')
hold on;



load ../obs_float/uv_total.dat;
whos;
X1=uv_total(1:5046,end-3);
Y1=uv_total(1:5046,end-2);
X1=X1+2;
Y1=Y1+2;
%%%%%%change si pas de temps change
U1=zeros(5046,1);
V1=zeros(5046,1);
e=1;
for r=1:1:totaltime
    
    Unew=zeros(1,5046);
    Vnew=zeros(1,5046);
    for count=1:5046
        Unew(count)=uv_total(e,end-1);
        Vnew(count)=uv_total(e,end);
        e=e+1;
    end
    U1=U1+Unew';
    V1=V1+Vnew';
   
    
end

U1=U1./totaltime;
V1=V1./totaltime;
%%% Because if the jtlag is 3 we have a set of zeros each 3 time steps in
%%% the uv_total.
U1=U1;
V1=V1;
% U1=roundn(U1,-6);
% V1=roundn(V1,-6);

quiver(X1,Y1,U1,V1,2,'r','Autoscale','off');


load ../obs_float/vel_bck_all.dat;
X2=vel_bck_all(1:5046,end-3);
Y2=vel_bck_all(1:5046,end-2);
X2=X2+1;
Y2=Y2+1;
%change si pas de temps change
U2=zeros(5046,1);
V2=zeros(5046,1);
ebcknew=1;
for r=1:1:28
    
    Ubcknew=zeros(1,5046);
    Vnew=zeros(1,5046);
    for count=1:5046
        Ubcknew(count)=vel_bck_all(ebcknew,end-1);
        Vbcknew(count)=vel_bck_all(ebcknew,end);
        ebcknew=ebcknew+1;
    end
    U2=U2+Ubcknew';
    V2=V2+Vbcknew';
   
    
end

U2=U2./28;
V2=V2./28;

quiver(X2,Y2,U2,V2,2,'b','Autoscale','off');


end

