load ~/NC/grid.mat
load ~/NC/area_1.9_2.5.mat
load ~/Aerosol_Variaiton/AOD/ncfile/AOD.mat
year=1:150;

AOD_GLOBAL_ANN=zeros(150,1);
AOD_GLOBAL_DJF=zeros(150,1);
AOD_GLOBAL_MAM=zeros(150,1);
AOD_GLOBAL_JJA=zeros(150,1);
AOD_GLOBAL_SON=zeros(150,1);

for yearID=1:150
    AOD_GLOBAL_ANN(yearID)=sum(sum(AOD_ANN(:,13:84,yearID).*area(:,13:84),2),1)/sum(sum(area(:,13:84),2),1);
    AOD_GLOBAL_DJF(yearID)=sum(sum(AOD_DJF(:,13:84,yearID).*area(:,13:84),2),1)/sum(sum(area(:,13:84),2),1);
    AOD_GLOBAL_MAM(yearID)=sum(sum(AOD_MAM(:,13:84,yearID).*area(:,13:84),2),1)/sum(sum(area(:,13:84),2),1);
    AOD_GLOBAL_JJA(yearID)=sum(sum(AOD_JJA(:,13:84,yearID).*area(:,13:84),2),1)/sum(sum(area(:,13:84),2),1);
    AOD_GLOBAL_SON(yearID)=sum(sum(AOD_SON(:,13:84,yearID).*area(:,13:84),2),1)/sum(sum(area(:,13:84),2),1);
end
    
AOD_GLOBAL_ANN_MAD=mad(AOD_GLOBAL_ANN);
AOD_GLOBAL_ANN_APDM=AOD_GLOBAL_ANN_MAD/mean(AOD_GLOBAL_ANN);
AOD_GLOBAL_DJF_MAD=mad(AOD_GLOBAL_DJF);
AOD_GLOBAL_DJF_APDM=AOD_GLOBAL_DJF_MAD/mean(AOD_GLOBAL_DJF);
AOD_GLOBAL_MAM_MAD=mad(AOD_GLOBAL_MAM);
AOD_GLOBAL_MAM_APDM=AOD_GLOBAL_MAM_MAD/mean(AOD_GLOBAL_MAM);
AOD_GLOBAL_JJA_MAD=mad(AOD_GLOBAL_JJA);
AOD_GLOBAL_JJA_APDM=AOD_GLOBAL_JJA_MAD/mean(AOD_GLOBAL_JJA);
AOD_GLOBAL_SON_MAD=mad(AOD_GLOBAL_SON);
AOD_GLOBAL_SON_APDM=AOD_GLOBAL_SON_MAD/mean(AOD_GLOBAL_SON);

AOD_NAMERICA_ANN=zeros(150,1);
AOD_NAMERICA_DJF=zeros(150,1);
AOD_NAMERICA_MAM=zeros(150,1);
AOD_NAMERICA_JJA=zeros(150,1);
AOD_NAMERICA_SON=zeros(150,1);

for yearID=1:150
    AOD_NAMERICA_ANN(yearID)=sum(sum(AOD_ANN(93:117,59:78,yearID).*area(93:117,59:78),2),1)/sum(sum(area(93:117,59:78),2),1);
    AOD_NAMERICA_DJF(yearID)=sum(sum(AOD_DJF(93:117,59:78,yearID).*area(93:117,59:78),2),1)/sum(sum(area(93:117,59:78),2),1);
    AOD_NAMERICA_MAM(yearID)=sum(sum(AOD_MAM(93:117,59:78,yearID).*area(93:117,59:78),2),1)/sum(sum(area(93:117,59:78),2),1);
    AOD_NAMERICA_JJA(yearID)=sum(sum(AOD_JJA(93:117,59:78,yearID).*area(93:117,59:78),2),1)/sum(sum(area(93:117,59:78),2),1);
    AOD_NAMERICA_SON(yearID)=sum(sum(AOD_SON(93:117,59:78,yearID).*area(93:117,59:78),2),1)/sum(sum(area(93:117,59:78),2),1);
end
    
AOD_NAMERICA_ANN_MAD=mad(AOD_NAMERICA_ANN);
AOD_NAMERICA_ANN_APDM=AOD_NAMERICA_ANN_MAD/mean(AOD_NAMERICA_ANN);
AOD_NAMERICA_DJF_MAD=mad(AOD_NAMERICA_DJF);
AOD_NAMERICA_DJF_APDM=AOD_NAMERICA_DJF_MAD/mean(AOD_NAMERICA_DJF);
AOD_NAMERICA_MAM_MAD=mad(AOD_NAMERICA_MAM);
AOD_NAMERICA_MAM_APDM=AOD_NAMERICA_MAM_MAD/mean(AOD_NAMERICA_MAM);
AOD_NAMERICA_JJA_MAD=mad(AOD_NAMERICA_JJA);
AOD_NAMERICA_JJA_APDM=AOD_NAMERICA_JJA_MAD/mean(AOD_NAMERICA_JJA);
AOD_NAMERICA_SON_MAD=mad(AOD_NAMERICA_SON);
AOD_NAMERICA_SON_APDM=AOD_NAMERICA_SON_MAD/mean(AOD_NAMERICA_SON);

AOD_EUROPE_ANN=zeros(150,1);
AOD_EUROPE_DJF=zeros(150,1);
AOD_EUROPE_MAM=zeros(150,1);
AOD_EUROPE_JJA=zeros(150,1);
AOD_EUROPE_SON=zeros(150,1);

for yearID=1:150
    AOD_EUROPE_ANN(yearID)=sum(sum(AOD_ANN([1:19,139:144],64:84,yearID).*area([1:19,139:144],64:84),2),1)/sum(sum(area([1:19,139:144],64:84),2),1);
    AOD_EUROPE_DJF(yearID)=sum(sum(AOD_DJF([1:19,139:144],64:84,yearID).*area([1:19,139:144],64:84),2),1)/sum(sum(area([1:19,139:144],64:84),2),1);
    AOD_EUROPE_MAM(yearID)=sum(sum(AOD_MAM([1:19,139:144],64:84,yearID).*area([1:19,139:144],64:84),2),1)/sum(sum(area([1:19,139:144],64:84),2),1);
    AOD_EUROPE_JJA(yearID)=sum(sum(AOD_JJA([1:19,139:144],64:84,yearID).*area([1:19,139:144],64:84),2),1)/sum(sum(area([1:19,139:144],64:84),2),1);
    AOD_EUROPE_SON(yearID)=sum(sum(AOD_SON([1:19,139:144],64:84,yearID).*area([1:19,139:144],64:84),2),1)/sum(sum(area([1:19,139:144],64:84),2),1);
end
    
AOD_EUROPE_ANN_MAD=mad(AOD_EUROPE_ANN);
AOD_EUROPE_ANN_APDM=AOD_EUROPE_ANN_MAD/mean(AOD_EUROPE_ANN);
AOD_EUROPE_DJF_MAD=mad(AOD_EUROPE_DJF);
AOD_EUROPE_DJF_APDM=AOD_EUROPE_DJF_MAD/mean(AOD_EUROPE_DJF);
AOD_EUROPE_MAM_MAD=mad(AOD_EUROPE_MAM);
AOD_EUROPE_MAM_APDM=AOD_EUROPE_MAM_MAD/mean(AOD_EUROPE_MAM);
AOD_EUROPE_JJA_MAD=mad(AOD_EUROPE_JJA);
AOD_EUROPE_JJA_APDM=AOD_EUROPE_JJA_MAD/mean(AOD_EUROPE_JJA);
AOD_EUROPE_SON_MAD=mad(AOD_EUROPE_SON);
AOD_EUROPE_SON_APDM=AOD_EUROPE_SON_MAD/mean(AOD_EUROPE_SON);

AOD_EASIA_ANN=zeros(150,1);
AOD_EASIA_DJF=zeros(150,1);
AOD_EASIA_MAM=zeros(150,1);
AOD_EASIA_JJA=zeros(150,1);
AOD_EASIA_SON=zeros(150,1);

for yearID=1:150
    AOD_EASIA_ANN(yearID)=sum(sum(AOD_ANN(41:65,64:84,yearID).*area(41:65,64:84),2),1)/sum(sum(area(41:65,64:84),2),1);
    AOD_EASIA_DJF(yearID)=sum(sum(AOD_DJF(41:65,64:84,yearID).*area(41:65,64:84),2),1)/sum(sum(area(41:65,64:84),2),1);
    AOD_EASIA_MAM(yearID)=sum(sum(AOD_MAM(41:65,64:84,yearID).*area(41:65,64:84),2),1)/sum(sum(area(41:65,64:84),2),1);
    AOD_EASIA_JJA(yearID)=sum(sum(AOD_JJA(41:65,64:84,yearID).*area(41:65,64:84),2),1)/sum(sum(area(41:65,64:84),2),1);
    AOD_EASIA_SON(yearID)=sum(sum(AOD_SON(41:65,64:84,yearID).*area(41:65,64:84),2),1)/sum(sum(area(41:65,64:84),2),1);
end
    
AOD_EASIA_ANN_MAD=mad(AOD_EASIA_ANN);
AOD_EASIA_ANN_APDM=AOD_EASIA_ANN_MAD/mean(AOD_EASIA_ANN);
AOD_EASIA_DJF_MAD=mad(AOD_EASIA_DJF);
AOD_EASIA_DJF_APDM=AOD_EASIA_DJF_MAD/mean(AOD_EASIA_DJF);
AOD_EASIA_MAM_MAD=mad(AOD_EASIA_MAM);
AOD_EASIA_MAM_APDM=AOD_EASIA_MAM_MAD/mean(AOD_EASIA_MAM);
AOD_EASIA_JJA_MAD=mad(AOD_EASIA_JJA);
AOD_EASIA_JJA_APDM=AOD_EASIA_JJA_MAD/mean(AOD_EASIA_JJA);
AOD_EASIA_SON_MAD=mad(AOD_EASIA_SON);
AOD_EASIA_SON_APDM=AOD_EASIA_SON_MAD/mean(AOD_EASIA_SON);

AOD_SAMERICA_ANN=zeros(150,1);
AOD_SAMERICA_DJF=zeros(150,1);
AOD_SAMERICA_MAM=zeros(150,1);
AOD_SAMERICA_JJA=zeros(150,1);
AOD_SAMERICA_SON=zeros(150,1);

for yearID=1:150
    AOD_SAMERICA_ANN(yearID)=sum(sum(AOD_ANN(113:129,31:47,yearID).*area(113:129,31:47),2),1)/sum(sum(area(113:129,31:47),2),1);
    AOD_SAMERICA_DJF(yearID)=sum(sum(AOD_DJF(113:129,31:47,yearID).*area(113:129,31:47),2),1)/sum(sum(area(113:129,31:47),2),1);
    AOD_SAMERICA_MAM(yearID)=sum(sum(AOD_MAM(113:129,31:47,yearID).*area(113:129,31:47),2),1)/sum(sum(area(113:129,31:47),2),1);
    AOD_SAMERICA_JJA(yearID)=sum(sum(AOD_JJA(113:129,31:47,yearID).*area(113:129,31:47),2),1)/sum(sum(area(113:129,31:47),2),1);
    AOD_SAMERICA_SON(yearID)=sum(sum(AOD_SON(113:129,31:47,yearID).*area(113:129,31:47),2),1)/sum(sum(area(113:129,31:47),2),1);
end
    
AOD_SAMERICA_ANN_MAD=mad(AOD_SAMERICA_ANN);
AOD_SAMERICA_ANN_APDM=AOD_SAMERICA_ANN_MAD/mean(AOD_SAMERICA_ANN);
AOD_SAMERICA_DJF_MAD=mad(AOD_SAMERICA_DJF);
AOD_SAMERICA_DJF_APDM=AOD_SAMERICA_DJF_MAD/mean(AOD_SAMERICA_DJF);
AOD_SAMERICA_MAM_MAD=mad(AOD_SAMERICA_MAM);
AOD_SAMERICA_MAM_APDM=AOD_SAMERICA_MAM_MAD/mean(AOD_SAMERICA_MAM);
AOD_SAMERICA_JJA_MAD=mad(AOD_SAMERICA_JJA);
AOD_SAMERICA_JJA_APDM=AOD_SAMERICA_JJA_MAD/mean(AOD_SAMERICA_JJA);
AOD_SAMERICA_SON_MAD=mad(AOD_SAMERICA_SON);
AOD_SAMERICA_SON_APDM=AOD_SAMERICA_SON_MAD/mean(AOD_SAMERICA_SON);

AOD_SAFRICA_ANN=zeros(150,1);
AOD_SAFRICA_DJF=zeros(150,1);
AOD_SAFRICA_MAM=zeros(150,1);
AOD_SAFRICA_JJA=zeros(150,1);
AOD_SAFRICA_SON=zeros(150,1);

for yearID=1:150
    AOD_SAFRICA_ANN(yearID)=sum(sum(AOD_ANN([1:19,137:144],31:47,yearID).*area([1:19,137:144],31:47),2),1)/sum(sum(area([1:19,137:144],31:47),2),1);
    AOD_SAFRICA_DJF(yearID)=sum(sum(AOD_DJF([1:19,137:144],31:47,yearID).*area([1:19,137:144],31:47),2),1)/sum(sum(area([1:19,137:144],31:47),2),1);
    AOD_SAFRICA_MAM(yearID)=sum(sum(AOD_MAM([1:19,137:144],31:47,yearID).*area([1:19,137:144],31:47),2),1)/sum(sum(area([1:19,137:144],31:47),2),1);
    AOD_SAFRICA_JJA(yearID)=sum(sum(AOD_JJA([1:19,137:144],31:47,yearID).*area([1:19,137:144],31:47),2),1)/sum(sum(area([1:19,137:144],31:47),2),1);
    AOD_SAFRICA_SON(yearID)=sum(sum(AOD_SON([1:19,137:144],31:47,yearID).*area([1:19,137:144],31:47),2),1)/sum(sum(area([1:19,137:144],31:47),2),1);
end
    
AOD_SAFRICA_ANN_MAD=mad(AOD_SAFRICA_ANN);
AOD_SAFRICA_ANN_APDM=AOD_SAFRICA_ANN_MAD/mean(AOD_SAFRICA_ANN);
AOD_SAFRICA_DJF_MAD=mad(AOD_SAFRICA_DJF);
AOD_SAFRICA_DJF_APDM=AOD_SAFRICA_DJF_MAD/mean(AOD_SAFRICA_DJF);
AOD_SAFRICA_MAM_MAD=mad(AOD_SAFRICA_MAM);
AOD_SAFRICA_MAM_APDM=AOD_SAFRICA_MAM_MAD/mean(AOD_SAFRICA_MAM);
AOD_SAFRICA_JJA_MAD=mad(AOD_SAFRICA_JJA);
AOD_SAFRICA_JJA_APDM=AOD_SAFRICA_JJA_MAD/mean(AOD_SAFRICA_JJA);
AOD_SAFRICA_SON_MAD=mad(AOD_SAFRICA_SON);
AOD_SAFRICA_SON_APDM=AOD_SAFRICA_SON_MAD/mean(AOD_SAFRICA_SON);

AOD_SASIA_ANN=zeros(150,1);
AOD_SASIA_DJF=zeros(150,1);
AOD_SASIA_MAM=zeros(150,1);
AOD_SASIA_JJA=zeros(150,1);
AOD_SASIA_SON=zeros(150,1);

for yearID=1:150
    AOD_SASIA_ANN(yearID)=sum(sum(AOD_ANN(25:45,54:64,yearID).*area(25:45,54:64),2),1)/sum(sum(area(25:45,54:64),2),1);
    AOD_SASIA_DJF(yearID)=sum(sum(AOD_DJF(25:45,54:64,yearID).*area(25:45,54:64),2),1)/sum(sum(area(25:45,54:64),2),1);
    AOD_SASIA_MAM(yearID)=sum(sum(AOD_MAM(25:45,54:64,yearID).*area(25:45,54:64),2),1)/sum(sum(area(25:45,54:64),2),1);
    AOD_SASIA_JJA(yearID)=sum(sum(AOD_JJA(25:45,54:64,yearID).*area(25:45,54:64),2),1)/sum(sum(area(25:45,54:64),2),1);
    AOD_SASIA_SON(yearID)=sum(sum(AOD_SON(25:45,54:64,yearID).*area(25:45,54:64),2),1)/sum(sum(area(25:45,54:64),2),1);
end
    
AOD_SASIA_ANN_MAD=mad(AOD_SASIA_ANN);
AOD_SASIA_ANN_APDM=AOD_SASIA_ANN_MAD/mean(AOD_SASIA_ANN);
AOD_SASIA_DJF_MAD=mad(AOD_SASIA_DJF);
AOD_SASIA_DJF_APDM=AOD_SASIA_DJF_MAD/mean(AOD_SASIA_DJF);
AOD_SASIA_MAM_MAD=mad(AOD_SASIA_MAM);
AOD_SASIA_MAM_APDM=AOD_SASIA_MAM_MAD/mean(AOD_SASIA_MAM);
AOD_SASIA_JJA_MAD=mad(AOD_SASIA_JJA);
AOD_SASIA_JJA_APDM=AOD_SASIA_JJA_MAD/mean(AOD_SASIA_JJA);
AOD_SASIA_SON_MAD=mad(AOD_SASIA_SON);
AOD_SASIA_SON_APDM=AOD_SASIA_SON_MAD/mean(AOD_SASIA_SON);

AOD_NAFRICA_ANN=zeros(150,1);
AOD_NAFRICA_DJF=zeros(150,1);
AOD_NAFRICA_MAM=zeros(150,1);
AOD_NAFRICA_JJA=zeros(150,1);
AOD_NAFRICA_SON=zeros(150,1);

for yearID=1:150
    AOD_NAFRICA_ANN(yearID)=sum(sum(AOD_ANN([1:25,137:144],49:64,yearID).*area([1:25,137:144],49:64),2),1)/sum(sum(area([1:25,137:144],49:64),2),1);
    AOD_NAFRICA_DJF(yearID)=sum(sum(AOD_DJF([1:25,137:144],49:64,yearID).*area([1:25,137:144],49:64),2),1)/sum(sum(area([1:25,137:144],49:64),2),1);
    AOD_NAFRICA_MAM(yearID)=sum(sum(AOD_MAM([1:25,137:144],49:64,yearID).*area([1:25,137:144],49:64),2),1)/sum(sum(area([1:25,137:144],49:64),2),1);
    AOD_NAFRICA_JJA(yearID)=sum(sum(AOD_JJA([1:25,137:144],49:64,yearID).*area([1:25,137:144],49:64),2),1)/sum(sum(area([1:25,137:144],49:64),2),1);
    AOD_NAFRICA_SON(yearID)=sum(sum(AOD_SON([1:25,137:144],49:64,yearID).*area([1:25,137:144],49:64),2),1)/sum(sum(area([1:25,137:144],49:64),2),1);
end
    
AOD_NAFRICA_ANN_MAD=mad(AOD_NAFRICA_ANN);
AOD_NAFRICA_ANN_APDM=AOD_NAFRICA_ANN_MAD/mean(AOD_NAFRICA_ANN);
AOD_NAFRICA_DJF_MAD=mad(AOD_NAFRICA_DJF);
AOD_NAFRICA_DJF_APDM=AOD_NAFRICA_DJF_MAD/mean(AOD_NAFRICA_DJF);
AOD_NAFRICA_MAM_MAD=mad(AOD_NAFRICA_MAM);
AOD_NAFRICA_MAM_APDM=AOD_NAFRICA_MAM_MAD/mean(AOD_NAFRICA_MAM);
AOD_NAFRICA_JJA_MAD=mad(AOD_NAFRICA_JJA);
AOD_NAFRICA_JJA_APDM=AOD_NAFRICA_JJA_MAD/mean(AOD_NAFRICA_JJA);
AOD_NAFRICA_SON_MAD=mad(AOD_NAFRICA_SON);
AOD_NAFRICA_SON_APDM=AOD_NAFRICA_SON_MAD/mean(AOD_NAFRICA_SON);
