function time_serie_jjas_df(ndmin, ndmax)
% time_serie_jjas_df ++explication between ndmin days and ndmax days

%+
% module
% ======
%
% ++
%
% DESCRIPTION
% ===========
%
% From eof_\ *ndmin*\ -\ *ndmax*\ d_jjas.mat, 
% ``time_serie_jjas_df`` compute ++.
%
% ``time_serie_jjas_df`` plot ++.
%
% ``time_serie_jjas_df`` save eof[123]\ *ndmin*\ -\ *ndmax*\ d.txt.
% 
% 2 Postscript files
% time_serie_jjas_\ *ndmin*\ -\ *ndmax*\ d_part[12].eps are
% written.
%
% EXAMPLES
% ========
%
% Following line read ``eof_10-30d_jjas.mat``, 
% compute ++,
% plot ++, 
% write ``eof[123]_10-30d.txt`` and
% write ``time_serie_jjas_eof1_10-30d_part[12].eps``
% ::
%
% >> time_serie_jjas_df(10,30);
%
% SEE ALSO
% ========
%
% composite_olr_eof_df_
%
% .. _composite_olr_eof_df : composite_olr_eof_df.html
%
% TODO
% ====
%
% improve description
%
% improve file pb
%
% use return function
%
% nb of figure depends on number of years to be plot : so figure(3) contains 
% something only if nb years > 23 (or so), so Postscript file of figure(3) 
% shoul not be saved if  nb years is less than 23 !
%
% EVOLUTIONS
% ==========
%
% $Id$
%
% - fplod 2009-01-28T15:28:54Z aedon.locean-ipsl.upmc.fr (Darwin)
%
%   * created from time_serie_jjas_30100.m to replace it as well as
%     time_serie_jjas.m, time_serie_jjas_25_90.m and time_serie_jjas_10_25.m
%
%     Days will be now written ``ndmin``\-``ndmaxd`` (ex: 10-30d) in filenames.
%
%-

global IRCAAM_ID;
global IRCAAM_OD;

if nargin==2
 % ndmin must be lower than ndmax
 if (ndmin > ndmax)
  disp(['ndmin = ', int2str(ndmin)]);
  disp(['ndmax = ', int2str(ndmax)]);
  error('eee : ndmin must be lower than ndmax');
 end
else
  usage='usage : time_serie_jjas_df(ndmin, ndmax)';
  disp(usage);
  error('eee : wrong arguments numbers')
end

% ndmin and ndmax will be used in xx-yyd form in filenames
df = [int2str(ndmin),'-',int2str(ndmax),'d'];
clear ndmin;
clear ndmax;

fullfilename=[IRCAAM_ID,'eof_', df, '_jjas.mat'];
status=load(fullfilename);
clear fullfilename;
C=status.C;
olr=status.olr;
clear status;

olr=olr';
PC1=olr*C;

%%%%%%% cronique de la VP1
time_serie_olr1=PC1(:,425);
time_serie_olr2=PC1(:,424);
time_serie_olr3=PC1(:,423);

dt_olr1=std(time_serie_olr1);
dt_olr2=std(time_serie_olr2);
dt_olr3=std(time_serie_olr3);

for a=1:3416;
   time_serie_olr1(a)=time_serie_olr1(a)/dt_olr1;
   time_serie_olr2(a)=time_serie_olr2(a)/dt_olr2;
   time_serie_olr3(a)=time_serie_olr3(a)/dt_olr3;
end;

fullfilename=[IRCAAM_ID,'eof1_',df,'.txt'];
save(fullfilename,'time_serie_olr1','-ASCII');
clear fullfilename;

fullfilename=[IRCAAM_ID,'eof2_',df,'.txt'];
save(fullfilename,'time_serie_olr2','-ASCII');
clear fullfilename;

fullfilename=[IRCAAM_ID,'eof3_',df,'.txt'];
save(fullfilename,'time_serie_olr3','-ASCII');
clear fullfilename;

x=[1:3416]';
for a=1:22;
   if a<12;
      figure(1);
      subplot(4,3,a);
   elseif a<23;
      figure(2);
      subplot(4,3,a-11);
   else
      figure(3);
      subplot(4,3,a-22);
   end;
   clear koro1;
   debut=(a-1)*122+1;
   fin=a*122;
   koro1=time_serie_olr1(debut:fin);

   clear x;
   x=[1:122]';
   plot(x,koro1,'r');
   hold on
   y=zeros(122,1);
   plot(x,y,'k:');
   title(a+1978,'FontSize',8);
   my_title=['serie temporelle VP1 filtrage ', df];
   if a==2;
       text(0,5.5,my_title);
   elseif a==13;
       text(0,5.5,my_title);
   elseif a==24;
       text(0,5.5,my_title);
   end;
   set (gca,'tickDir','out');
   axis([1 122 -3 3]);

   set (gca,'YTick',[-3:1:3],'YTickLabel',[-3:1:3],'fontname','Arial','fontsize',6);
   set (gca,'XTick',[0:20:120],'XTickLabel',[0:20:120],'fontname','Arial','fontsize',6);
end;

figure(1);
fullfilename=[IRCAAM_OD,'time_serie_jjas_', df, '_part1.eps'];
print('-depsc2',fullfilename);
clear fullfilename;
figure(2);
fullfilename=[IRCAAM_OD,'time_serie_jjas_', df, '_part2.eps'];
print('-depsc2',fullfilename);
clear fullfilename;
figure(3);
fullfilename=[IRCAAM_OD,'time_serie_jjas_', df, '_part3.eps'];
print('-depsc2',fullfilename);
clear fullfilename;
