%desfase
clear
addpath /Francia/Velocidades
addpath /Francia/vientos
addpath /Francia/Estadisticas
addpath /Francia/adcp

load vieusin23
load vievsin23
%load p23w_0
%p23w_0=p23w_0(27:end);
%load p10w_0
%p10w_0=p10w_0(27:end);
load tempsin23
t23=tempsin23(1441:end-14);
load vmax
load uvmoy
v=uvmoy(4,378:end)';v=completo_series1(v,5);
v=v(2:end-1);
u=uvmoy(4,1:377)';u=completo_series1(u,5);
u=u(2:end-1);
%vienv=vievsin23(1441:end-14);
%vienu=vieusin23(1441:end-14);
load upirata23
load vpirata23
modv=sqrt(upirata23.^2+vpirata23.^2);
tu=modv.*upirata23;
tv=modv.*vpirata23;
y1=t23;
y2=vmax';
exp1=2;
exp2=8;
inter=40;
y=y1;
abc
aa=aa(55:70);
period=period(55:70);

conv_fft_abc

y1=y;
convolution1=wave;
y=y2;
%abc
conv_fft_abc;
y2=y;
convolution2=wave;
integration_essai;
phase=unwrap(phase);
delay=(t.*phase/(2*pi));
for i=1:n1;
   xx(i)=i+delay(i);
%xx(i)=i-delay(i);
end;
%xxx=[1:n1];
%yyy=interp1(xx,y1,xxx);
%yyy=yyy';

%eje de tiempo
%fecha=datenum(1997,12,31);
%fet=1:length(u);
%fet=fet+fecha;
tim=1:372;
time=datenum(2001,12,10);
time=time+tim;
%fety1=fet(121:end);


%fecha2=datenum(1999,11,11);
%fet2=1:375;
%fet2=fet2+fecha2;
fet2=time;
x=fet2(1):30:fet2(end);
a=datestr(x,12);

load ssvg23w14
load ssug23w14
load sstem23w14
load ssv23max14
load freadcpv12
load fuadcp14; fuadcp14=-fuadcp14; %por las cuestiones de los residuos
subplot(2,1,1)
plot(fet2,y1,'r')
hold on
plot(fet2,y2)
set(gca,'xlim',[min(fet2)-3 max(fet2)+3],'xtick',x,'xticklabel',[])
title('14 day signal (from wavelet spectra) for the SST (blue) and the adcp meridional component (red) at 10 W')

subplot(2,1,2)
plot(fet2,delay,'k')
ylabel('delay (days)')

set(gca,'xlim',[min(fet2)-3 max(fet2)+3],'xtick',x,'xticklabel',a)

orient landscape
