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

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

SSLT_EN_month=zeros(144,96,a);
SSLT_LL_month=zeros(144,96,b);

n=0;
m=0;
for monthID=1:length(month)
    if EN_Month(monthID)==1
        n=n+1;
        SSLT_EN_month(:,:,n)=SSLT_MONTH(:,:,monthID);
    end
    if LL_Month(monthID)==1
        m=m+1;
        SSLT_LL_month(:,:,m)=SSLT_MONTH(:,:,monthID);
    end
end

SSLT_EN=mean(SSLT_EN_month,3);
SSLT_LL=mean(SSLT_LL_month,3);

SSLT_ENSO=SSLT_EN-SSLT_LL;

load ~/NC/area_1.9_2.5.mat
IR=sum(sum(SSLT_ENSO(37:59,37:60).*area(37:59,37:60),2),1)/sum(sum(area(37:59,37:60),1),2);
TP=sum(sum(SSLT_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/SSLT/ncfile/SSLT.mat
temp_IR=sum(sum(mean(SSLT_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(SSLT_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('SSLT_ENSO_composite_monthly.mat','SSLT_EN','SSLT_LL','SSLT_ENSO')

nccreate('SSLT_ENSO_composite_monthly.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('SSLT_ENSO_composite_monthly.nc','lat', lat)
ncwriteatt('SSLT_ENSO_composite_monthly.nc','lat','units','degrees_north')
ncwriteatt('SSLT_ENSO_composite_monthly.nc','lat','long_name','Latitude')
nccreate('SSLT_ENSO_composite_monthly.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('SSLT_ENSO_composite_monthly.nc','lon', lon)
ncwriteatt('SSLT_ENSO_composite_monthly.nc','lon','units','degrees_east')
ncwriteatt('SSLT_ENSO_composite_monthly.nc','lon','long_name','Longitude')
nccreate('SSLT_ENSO_composite_monthly.nc','SSLT_EN','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('SSLT_ENSO_composite_monthly.nc','SSLT_EN', SSLT_EN)
nccreate('SSLT_ENSO_composite_monthly.nc','SSLT_LL','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('SSLT_ENSO_composite_monthly.nc','SSLT_LL', SSLT_LL)
nccreate('SSLT_ENSO_composite_monthly.nc','SSLT_ENSO','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('SSLT_ENSO_composite_monthly.nc','SSLT_ENSO', SSLT_ENSO)
ncdisp('SSLT_ENSO_composite_monthly.nc')
