%

% ncload('rlut_d.AfNQIVIV.197106-09.nc')
% whos
% Name        Size                  Bytes  Class     Attributes
%
% ans         1x4                     268  cell
% lat        64x1                     512  double
% lon       128x1                    1024  double
% rlut      122x64x128            7995392  double
% time      122x1                     976  double
%

close all;
clear;

olr=zeros(122,30,64,128);

ncload('rlut_d.AfNQIVIV.197106-09.nc','rlut');
olr(:,1,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.197206-09.nc','rlut');
olr(:,2,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.197306-09.nc','rlut');
olr(:,3,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.197406-09.nc','rlut');
olr(:,4,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.197506-09.nc','rlut');
olr(:,5,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.197606-09.nc','rlut');
olr(:,6,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.197706-09.nc','rlut');
olr(:,7,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.197806-09.nc','rlut');
olr(:,8,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.197906-09.nc','rlut');
olr(:,9,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.198006-09.nc','rlut');
olr(:,10,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.198106-09.nc','rlut');
olr(:,11,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.198206-09.nc','rlut');
olr(:,12,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.198306-09.nc','rlut');
olr(:,13,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.198406-09.nc','rlut');
olr(:,14,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.198506-09.nc','rlut');
olr(:,15,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.198606-09.nc','rlut');
olr(:,16,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.198706-09.nc','rlut');
olr(:,17,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.198806-09.nc','rlut');
olr(:,18,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.198906-09.nc','rlut');
olr(:,19,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.199006-09.nc','rlut');
olr(:,20,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.199106-09.nc','rlut');
olr(:,21,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.199206-09.nc','rlut');
olr(:,22,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.199306-09.nc','rlut');
olr(:,23,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.199406-09.nc','rlut');
olr(:,24,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.199506-09.nc','rlut');
olr(:,25,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.199606-09.nc','rlut');
olr(:,26,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.199706-09.nc','rlut');
olr(:,27,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.199806-09.nc','rlut');
olr(:,28,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.199906-09.nc','rlut');
olr(:,29,:,:)=rlut; clear rlut;

ncload('rlut_d.AfNQIVIV.200006-09.nc','rlut','lon','lat');
olr(:,30,:,:)=rlut; clear rlut;

% selction du domaine geographique
olr1=zeros(122,30,64,128);
olr1(:,:,:,1:64)=olr(:,:,:,65:128);
olr1(:,:,:,65:128)=olr(:,:,:,1:64);
clear olr;
olr=olr1;
clear olr1;
olr=olr(:,:,29:43,54:77);
taille=(43-29+1)*(77-54+1);

% taille de OLR
% 122 30 15 24
olr1=olr(31:122,:,:,:);
clear olr;
olr(:,:,:)=mean(olr1);
clear olr1;
moyenne_olr(:,:)=mean(olr);
olr_centre=zeros(30,15,24);
for a=1:30;
    for b=1:15;
        for c=1:24;
            olr_centre(a,b,c)=olr(a,b,c)-moyenne_olr(b,c);
        end;
    end;
end;

figure(1);
orient('landscape');
figure(2);
orient('landscape');
lon=lon(54:77);
lon=lon-180;
lat=lat(29:43);
lat=lat';
for a=1:22;
     clear kara;
     kara=zeros(15,24);
     kara(:,:)=olr_centre(a+8,:,:);
     if a<13;
         figure(1);
         subplot(3,4,a);
     else
         figure(2);
         subplot(3,4,a-12);
     end;
     for b=1:15;
         for c=1:24;
             if kara(b,c)>20;
                 kara(b,c)=20;
             elseif kara(b,c)<-20;
                 kara(b,c)=-20;
             end;
         end;
     end;
     kara(1,1)=-20.001;
     kara(1,2)=20.001;
     palette
     contourf(lon,lat,kara,[-20:2:20],'LineStyle','none');
     colorbar
     hold on
     cartemonde
       title(a+1978,'Fontsize',8);
     axis equal
     axis([-30 30 -10 30]);
     set (gca,'YTick',[-10:10:30],'YTickLabel',['10S';'  0';'10N';'20N';'30N'],'fontname','Arial','fontsize',4);
     set (gca,'XTick',[-30:10:30],'XTickLabel',['30W';'20W';'10W';'  0';'10E';'20E';'30E'],'fontname','Arial','fontsize',4);
     set (gca,'tickDir','out');
end;

figure(1);
print('-depsc2','anomalies_OLR_1979_2000_simulAFR_part1.eps');
figure(2);
print('-depsc2','anomalies_OLR_1979_2000_simulAFR_part2.eps');
