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

%+
% module
% ======
%
% ++
%
% DESCRIPTION
% ===========
%
% plot ++ from file eof_10-30d_jjas.mat
%
% EXAMPLES
% ========
%
% Following line read eof_10-30d_jjas.mat, plot ++and produce a Postcript file
% resultats_eof_jjas_2006_10-30d.eps 
% produce also carte_eofx_mode_sahel_10-30d.dat and 
% carte_eofx_mode_sahel_10-30d.ctl (GRADS files) and vecteurs_eof_10-30d.txt.
% ::
%
% >> carte_eof234_jjas_df(10,30);
%
% SEE ALSO
% ========
%
% olr_eof_1025.m_
%
% .. _olr_eof_1025.m : olr_eof_1025.m.html
%
% reconstitution_1025.m_
%
% .. _reconstitution_1025.m : reconstitution_1025.m.html
%
% time_serie_jjas_10_25.m_
%
% .. _time_serie_jjas_10_25.m : time_serie_jjas_10_25.m.html
%
% sauvegrads.m_
%
% .. _sauvegrads.m : sauvegrads.m.html
%
% TODO
% ====
%
% improve description
%
% improve file pb
%
% use return function
%
% change filename of Postscript file because same as in carte_eof_ER_jjas_df.m
%
% directory for sauvegrads files
%
% control of sauvegrads call
%
% why ``-carte`` in contourf and sauvegrads instead of ``carte`` ?
%
% EVOLUTIONS
% ==========
%
% $Id$
%
% - fplod 2009-01-27T14:49:51Z aedon.locean-ipsl.upmc.fr (Darwin)
%
%   * created from carte_eof234_jjas_1025.m and carte_eof234_jjas_1030.m
%     to replace both.
%
%     Days will be now written ``ndmin``\-``ndmaxd`` (ex: 10-30d) in filenames.
%
%   *  add sauvegrads on first EOF for homogenity
%
%-


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 : carte_eof234_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,'C','L');
clear fullfilename;

C=status.C;
L=status.L;
clear status;

carte1=C(:,425);

carte=reshape(carte1,25,17);
carte=carte';

clear carte1;
% defintion des lat et lon
lon=[-30:2.5:30]';
lat=[-10:2.5:30];

figure(1);
orient('landscape');
subplot(3,2,1);
palette;
for a=1:17;
    for b=1:25;
        if carte(a,b)>0.2;
            carte(a,b)=0.2;
        elseif carte(a,b)<-0.2;
            carte(a,b)=-0.2;
        end;
    end;
end;
carte(1,1)=-0.2001;
carte(1,2)=0.2001;

contourf(lon,lat,-carte,[-0.2:0.02:0.2],'LineStyle','none');
gradsname=['carte_eof1_mode_sahel_',df];
sauvegrads(gradsname,-carte,[-30 2.5 -10 2.5]);
clear gradsname;

colorbar;
title('OLR EOF1','Fontsize',8);
hold on;
cartemonde;
set (gca,'YTick',[-10:10:30],'YTickLabel',['10S';'  0';'10N';'20N';'30N'],'fontname','Arial','fontsize',6);
set (gca,'XTick',[-30:10:30],'XTickLabel',['30W';'20W';'10W';'  0';'10E';'20E';'30E'],'fontname','Arial','fontsize',6);
set (gca,'tickDir','out');

clear carte1 x y a b carte coco;
carte1=C(:,424);
carte=reshape(carte1,25,17);
carte=carte';

clear carte1;
lon=[-30:2.5:30]';
lat=[-10:2.5:30];

subplot(3,2,3);
palette;
for a=1:17;
    for b=1:25;
        if carte(a,b)>0.2;
            carte(a,b)=0.2;
        elseif carte(a,b)<-0.2;
            carte(a,b)=-0.2;
        end;
    end;
end;
carte(1,1)=-0.2001;
carte(1,2)=0.2001;

contourf(lon,lat,-carte,[-0.2:0.02:0.2],'LineStyle','none');
gradsname=['carte_eof2_mode_sahel_',df];
sauvegrads(gradsname,-carte,[-30 2.5 -10 2.5]);
clear gradsname;
colorbar;

title('OLR EOF2','Fontsize',8);
hold on;
cartemonde;
set (gca,'YTick',[-10:10:30],'YTickLabel',['10S';'  0';'10N';'20N';'30N'],'fontname','Arial','fontsize',6);
set (gca,'XTick',[-30:10:30],'XTickLabel',['30W';'20W';'10W';'  0';'10E';'20E';'30E'],'fontname','Arial','fontsize',6);
set (gca,'tickDir','out');

clear carte1 x y a b carte coco;
carte1=C(:,423);
carte=reshape(carte1,25,17);
carte=carte';
clear carte1;

% defintion des lat et lon
lon=[-30:2.5:30]';
lat=[-10:2.5:30];

subplot(3,2,5);
palette;
for a=1:17;
    for b=1:25;
        if carte(a,b)>0.2;
            carte(a,b)=0.2;
        elseif carte(a,b)<-0.2;
            carte(a,b)=-0.2;
        end;
    end;
end;
carte(1,1)=-0.2001;
carte(1,2)=0.2001;

contourf(lon,lat,-carte,[-0.2:0.02:0.2],'LineStyle','none');
gradsname=['carte_eof3_mode_sahel_',df];
sauvegrads(gradsname,-carte,[-30 2.5 -10 2.5]);
clear gradsname;
colorbar;
title('OLR EOF3','Fontsize',8);
hold on;
cartemonde;
set (gca,'YTick',[-10:10:30],'YTickLabel',['10S';'  0';'10N';'20N';'30N'],'fontname','Arial','fontsize',6);
set (gca,'XTick',[-30:10:30],'XTickLabel',['30W';'20W';'10W';'  0';'10E';'20E';'30E'],'fontname','Arial','fontsize',6);
set (gca,'tickDir','out');

clear carte1 x y a b carte coco;
carte1=C(:,422);
carte=reshape(carte1,25,17);
carte=carte';
clear carte1;

% defintion des lat et lon
lon=[-30:2.5:30]';
lat=[-10:2.5:30];

subplot(3,2,2);
palette;
for a=1:17;
    for b=1:25;
        if carte(a,b)>0.2;
            carte(a,b)=0.2;
        elseif carte(a,b)<-0.2;
            carte(a,b)=-0.2;
        end;
    end;
end;
carte(1,1)=-0.2001;
carte(1,2)=0.2001;

contourf(lon,lat,-carte,[-0.2:0.02:0.2],'LineStyle','none');
gradsname=['carte_eof4_mode_sahel_',df];
sauvegrads(gradsname,-carte,[-30 2.5 -10 2.5]);
clear gradsname;
colorbar;
title('OLR EOF4','Fontsize',8);
hold on;
cartemonde;
set (gca,'YTick',[-10:10:30],'YTickLabel',['10S';'  0';'10N';'20N';'30N'],'fontname','Arial','fontsize',6);
set (gca,'XTick',[-30:10:30],'XTickLabel',['30W';'20W';'10W';'  0';'10E';'20E';'30E'],'fontname','Arial','fontsize',6);
set (gca,'tickDir','out');

subplot(3,2,4);
vaude=0;
for a=1:425;
   vaude=vaude+L(a,a);
end;
vecteurs=zeros(20,1);
for a=1:20;
   b=425-(a-1);
   vecteurs(a)=100*(L(b,b)/vaude);
end;
x=[1:20]';

bar(x,vecteurs,'LineStyle','none')
fullfilename=[IRCAAM_OD,'vecteurs_eof_',df,'.txt'];
save(fullfilename,'vecteurs','-ASCII');
clear fullfilename;

axis([0.5 20.5 0 25]);
set (gca,'YTick',[0:5:25],'YTickLabel',[0:5:25],'fontname','Arial','fontsize',6);
set (gca,'XTick',[2:2:20],'XTickLabel',[2:2:20],'fontname','Arial','fontsize',6);
set (gca,'tickDir','out');

fullfilename=[IRCAAM_OD,'resultats_eof_jjas_2006_',df,'.eps'];
print('-depsc2',fullfilename);
clear fullfilename;
