load ~/NC/grid.mat
load ~/Aerosol_Variaiton/IRUN/SST/ncfile/ENSO_Month_10th.mat
load ~/Aerosol_Variaiton/IRUN/U10/ncfile/U10_monthly.mat
month=1:1800;

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

U10_EN_month=zeros(144,96,a);
U10_LL_month=zeros(144,96,b);

n=0;
m=0;
for monthID=1:length(month)
    if EN_Month(monthID)==1
        n=n+1;
        U10_EN_month(:,:,n)=U10_MONTH(:,:,monthID);
    end
    if LL_Month(monthID)==1
        m=m+1;
        U10_LL_month(:,:,m)=U10_MONTH(:,:,monthID);
    end
end

U10_EN=mean(U10_EN_month,3);
U10_LL=mean(U10_LL_month,3);

H=zeros(length(lon),length(lat));
for i=1:length(lon)
    for j=1:length(lat)
        H(i,j)=ttest2(U10_EN_month(i,j,:),U10_LL_month(i,j,:),0.05);
    end
end

U10_ENSO=U10_EN-U10_LL;

save('U10_ENSO_composite_monthly_10th.mat','U10_EN','U10_LL','U10_ENSO')

nccreate('U10_ENSO_composite_monthly_10th.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('U10_ENSO_composite_monthly_10th.nc','lat', lat)
ncwriteatt('U10_ENSO_composite_monthly_10th.nc','lat','units','degrees_north')
ncwriteatt('U10_ENSO_composite_monthly_10th.nc','lat','long_name','Latitude')
nccreate('U10_ENSO_composite_monthly_10th.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('U10_ENSO_composite_monthly_10th.nc','lon', lon)
ncwriteatt('U10_ENSO_composite_monthly_10th.nc','lon','units','degrees_east')
ncwriteatt('U10_ENSO_composite_monthly_10th.nc','lon','long_name','Longitude')
nccreate('U10_ENSO_composite_monthly_10th.nc','U10_EN','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('U10_ENSO_composite_monthly_10th.nc','U10_EN', U10_EN)
nccreate('U10_ENSO_composite_monthly_10th.nc','U10_LL','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('U10_ENSO_composite_monthly_10th.nc','U10_LL', U10_LL)
nccreate('U10_ENSO_composite_monthly_10th.nc','U10_ENSO','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('U10_ENSO_composite_monthly_10th.nc','U10_ENSO', U10_ENSO)
nccreate('U10_ENSO_composite_monthly_10th.nc','H','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('U10_ENSO_composite_monthly_10th.nc','H', H)
ncdisp('U10_ENSO_composite_monthly_10th.nc')
