  % Decomposition en ondelettes de la NAO. 

clear all

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Chargement des donnees a etudier
%load /usr/lodyc/decennal/jmignot/BERGEN/ATMOS/EOF/E75_2075-2274_eof_slp_25N80N_ANNUALmean_d3.mat
%load /usr/home/lbulod/Francia/Velocidades/n2u
load /Francia/Velocidades/res

%y=PC(:,1)';
%y=reshape(y,12,200);
%y=squeeze(mean(y,1));
y=res(:,6);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

exp1=2;
exp2=8;
inter=40;
abc
conv_fft_abc


figure;
%initfig;

subplot(2,1,1)
plot(y,'k')
xlabel('annees')
hold on

subplot(2,1,2)
contourf(abs(wave),[0:0.05:1])
caxis([0 1])
view(0,-90)
%colorbar
hold on
%plot([1 200],[75 75],'w')
ylim([0 210])
r=30:30:210;
%set(gca,'YTick',[6 46 70 86 99 109 118 126 133 139] ,'YTickLabel',[10:10:100])
set(gca,'YTick',r,'YTickLabel',floor(period(r)))
xlabel('annees')
ylabel('periodes(annees)')

wave1=wave;
wave(1:140,:)=0;
wave(170:end,:)=0;
maxmax
plot(dilat_number,'w','LineWidth',2)

subplot(2,1,1)
plot(ridge,'k','LineWidth',2)
%NAO_filtree=real(wave(75,:));
%plot(NAO_filtree,'r')
A=corrcoef(y,ridge);
pourvar=round(A(1,2)^2*1000)/10
tt1=['Signal a 33 ans extrait (' num2str(pourvar) '% de variance expliquee)']

%legend('NAO moyenne annuelle',tt1)


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Chargement des donnees a etudier
%load /usr/lodyc/decennal/jmignot/BERGEN/ATMOS/EOF/E75_2075-2274_eof_slp_25N80N_D3_ONDELETTES_10ANS.mat
%y=PC(:,1)';
y=PC(:,1)';
y=reshape(y,12,200);
y=squeeze(mean(y,1));
y=filtreondelettes(y);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

exp1=3;
exp2=7;
inter=40;
abc
conv_fft_abc



subplot(2,2,2)
plot(y,'k')
xlabel('annees')
hold on

subplot(2,2,4)
contourf(abs(wave),[0:0.05:1])
caxis([0 1])
view(0,-90)
%colorbar
hold on
%plot([1 200],[75 75],'w')
ylim([0 140])
set(gca,'YTick',[6 46 70 86 99 109 118 126 133 139] ,'YTickLabel',[10:10:100])
xlabel('annees')
ylabel('periodes(annees)')
wave1=wave;
wave(1:60,:)=0;
wave(90:end,:)=0;
maxmax
plot(dilat_number,'w','LineWidth',2)

subplot(2,2,2)
plot(ridge,'k','LineWidth',2)
%NAO_filtree=real(wave(75,:));
%plot(NAO_filtree,'r')
A=corrcoef(y,ridge);
pourvar=round(A(1,2)^2*1000)/10
tt1=['Signal a 33 ans extrait (' num2str(pourvar) '% de variance expliquee)']

%legend('NAO decennale',tt1)

     ridge_NAOdecennale=ridge;

save /usr/lodyc/decennal/jmignot/BERGEN/ATMOS/EOF/E75_2075-2274_eof_slp_25N80N_D3_ONDELETTES_10ANS_RIDGE ridge_NAOdecennale




%suptitle('BCM - 2075-2274 - Wavelet decomposition of NAO time serie - Annual mean')
  suptit1=['BCM - Decomposition en ondelettes de la serie temporelle de la NAO - 2075-2274']
  suptit2=['moyennes annuelles (gauche) - decennal (droite)']
  suptit=[{suptit1} {suptit2}]
%  ax=axes('Position',[.05 .93 .9 .05],'Box','on','XTick',[],'YTick',[]);
%  text(.5,.5,suptit,'FontSize',12,'Units', 'Normalized', 'HorizontalAlignment', 'Center');

%ax=axes('Position',[.05 .47 .9 .05],'Box','on','XTick',[],'YTick',[]);
%text(.5,.5,,'FontSize',12,'Units', 'Normalized', 'HorizontalAlignment', 'Center');
