load ~/NC/grid.mat
load ~/Aerosol_Variaiton/IRUN/SST/ncfile/ENSO_Month.mat
load ~/Aerosol_Variaiton/IRUN/DUST/ncfile/DUST_monthly.mat
month=1:1800;

a=sum(EN_Month);
b=sum(LL_Month);

DUST_EN_month=zeros(144,96,a);
DUST_LL_month=zeros(144,96,b);

n=0;
m=0;
for monthID=1:length(month)
    if EN_Month(monthID)==1
        n=n+1;
        DUST_EN_month(:,:,n)=DUST_MONTH(:,:,monthID);
    end
    if LL_Month(monthID)==1
        m=m+1;
        DUST_LL_month(:,:,m)=DUST_MONTH(:,:,monthID);
    end
end

DUST_EN=mean(DUST_EN_month,3);
DUST_LL=mean(DUST_LL_month,3);

DUST_ENSO=DUST_EN-DUST_LL;

load ~/NC/area_1.9_2.5.mat
IR=sum(sum(DUST_ENSO(37:59,37:60).*area(37:59,37:60),2),1)/sum(sum(area(37:59,37:60),1),2);
TP=sum(sum(DUST_ENSO(59:97,37:60).*area(59:97,37:60),2),1)/sum(sum(area(59:97,37:60),1),2);
load ~/Aerosol_Variaiton/IRUN/DUST/ncfile/DUST.mat
temp_IR=sum(sum(mean(DUST_ANN(37:59,37:60,:),3).*area(37:59,37:60),2),1)/sum(sum(area(37:59,37:60),1),2);
temp_TP=sum(sum(mean(DUST_ANN(59:97,37:60,:),3).*area(59:97,37:60),2),1)/sum(sum(area(59:97,37:60),1),2);
IR_ratio=IR/temp_IR*100;
TP_ratio=TP/temp_TP*100;


save('DUST_ENSO_composite_monthly.mat','DUST_EN','DUST_LL','DUST_ENSO')

nccreate('DUST_ENSO_composite_monthly.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('DUST_ENSO_composite_monthly.nc','lat', lat)
ncwriteatt('DUST_ENSO_composite_monthly.nc','lat','units','degrees_north')
ncwriteatt('DUST_ENSO_composite_monthly.nc','lat','long_name','Latitude')
nccreate('DUST_ENSO_composite_monthly.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('DUST_ENSO_composite_monthly.nc','lon', lon)
ncwriteatt('DUST_ENSO_composite_monthly.nc','lon','units','degrees_east')
ncwriteatt('DUST_ENSO_composite_monthly.nc','lon','long_name','Longitude')
nccreate('DUST_ENSO_composite_monthly.nc','DUST_EN','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('DUST_ENSO_composite_monthly.nc','DUST_EN', DUST_EN)
nccreate('DUST_ENSO_composite_monthly.nc','DUST_LL','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('DUST_ENSO_composite_monthly.nc','DUST_LL', DUST_LL)
nccreate('DUST_ENSO_composite_monthly.nc','DUST_ENSO','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('DUST_ENSO_composite_monthly.nc','DUST_ENSO', DUST_ENSO)
ncdisp('DUST_ENSO_composite_monthly.nc')
