lon=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/UWND/dat/uwnd.mon.mean.nc','lon');
lat=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/UWND/dat/uwnd.mon.mean.nc','lat');
year=1:14;
month=1:168;
load ~/Aerosol_Variaiton/IRUN/SST/ncfile/ENSO_Month_NCEP.mat
load ~/Aerosol_Variaiton/IRUN/UWND/ncfile/UWND_NCEP_monthly.mat

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

UWND_EN_month=zeros(144,73,a);
UWND_LL_month=zeros(144,73,b);

n=0;
m=0;
for monthID=1:length(month)
    if EN_Month(monthID)==1
        n=n+1;
        UWND_EN_month(:,:,n)=UWND_MONTH(:,:,monthID);
    end
    if LL_Month(monthID)==1
        m=m+1;
        UWND_LL_month(:,:,m)=UWND_MONTH(:,:,monthID);
    end
end

UWND_EN=mean(UWND_EN_month,3);
UWND_LL=mean(UWND_LL_month,3);

UWND_ENSO=UWND_EN-UWND_LL;


save('UWND_NCEP_ENSO_composite_monthly.mat','UWND_EN','UWND_LL','UWND_ENSO')

nccreate('UWND_NCEP_ENSO_composite_monthly.nc','lat','Dimensions',{'lat',73},'Format','classic')
ncwrite('UWND_NCEP_ENSO_composite_monthly.nc','lat', lat)
ncwriteatt('UWND_NCEP_ENSO_composite_monthly.nc','lat','units','degrees_north')
ncwriteatt('UWND_NCEP_ENSO_composite_monthly.nc','lat','long_name','Latitude')
nccreate('UWND_NCEP_ENSO_composite_monthly.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('UWND_NCEP_ENSO_composite_monthly.nc','lon', lon)
ncwriteatt('UWND_NCEP_ENSO_composite_monthly.nc','lon','units','degrees_east')
ncwriteatt('UWND_NCEP_ENSO_composite_monthly.nc','lon','long_name','Longitude')
nccreate('UWND_NCEP_ENSO_composite_monthly.nc','UWND_EN','Dimensions',{'lon',144,'lat',73},'Format','classic')
ncwrite('UWND_NCEP_ENSO_composite_monthly.nc','UWND_EN', UWND_EN)
nccreate('UWND_NCEP_ENSO_composite_monthly.nc','UWND_LL','Dimensions',{'lon',144,'lat',73},'Format','classic')
ncwrite('UWND_NCEP_ENSO_composite_monthly.nc','UWND_LL', UWND_LL)
nccreate('UWND_NCEP_ENSO_composite_monthly.nc','UWND_ENSO','Dimensions',{'lon',144,'lat',73},'Format','classic')
ncwrite('UWND_NCEP_ENSO_composite_monthly.nc','UWND_ENSO', UWND_ENSO)
ncdisp('UWND_NCEP_ENSO_composite_monthly.nc')
