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

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

VWND_EN_month=zeros(144,73,a);
VWND_LL_month=zeros(144,73,b);

n=0;
m=0;
for monthID=1:length(month)
    if EN_Month(monthID)==1
        n=n+1;
        VWND_EN_month(:,:,n)=VWND_MONTH(:,:,monthID);
    end
    if LL_Month(monthID)==1
        m=m+1;
        VWND_LL_month(:,:,m)=VWND_MONTH(:,:,monthID);
    end
end

VWND_EN=mean(VWND_EN_month,3);
VWND_LL=mean(VWND_LL_month,3);

VWND_ENSO=VWND_EN-VWND_LL;


save('VWND_NCEP_ENSO_composite_monthly.mat','VWND_EN','VWND_LL','VWND_ENSO')

nccreate('VWND_NCEP_ENSO_composite_monthly.nc','lat','Dimensions',{'lat',73},'Format','classic')
ncwrite('VWND_NCEP_ENSO_composite_monthly.nc','lat', lat)
ncwriteatt('VWND_NCEP_ENSO_composite_monthly.nc','lat','units','degrees_north')
ncwriteatt('VWND_NCEP_ENSO_composite_monthly.nc','lat','long_name','Latitude')
nccreate('VWND_NCEP_ENSO_composite_monthly.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('VWND_NCEP_ENSO_composite_monthly.nc','lon', lon)
ncwriteatt('VWND_NCEP_ENSO_composite_monthly.nc','lon','units','degrees_east')
ncwriteatt('VWND_NCEP_ENSO_composite_monthly.nc','lon','long_name','Longitude')
nccreate('VWND_NCEP_ENSO_composite_monthly.nc','VWND_EN','Dimensions',{'lon',144,'lat',73},'Format','classic')
ncwrite('VWND_NCEP_ENSO_composite_monthly.nc','VWND_EN', VWND_EN)
nccreate('VWND_NCEP_ENSO_composite_monthly.nc','VWND_LL','Dimensions',{'lon',144,'lat',73},'Format','classic')
ncwrite('VWND_NCEP_ENSO_composite_monthly.nc','VWND_LL', VWND_LL)
nccreate('VWND_NCEP_ENSO_composite_monthly.nc','VWND_ENSO','Dimensions',{'lon',144,'lat',73},'Format','classic')
ncwrite('VWND_NCEP_ENSO_composite_monthly.nc','VWND_ENSO', VWND_ENSO)
ncdisp('VWND_NCEP_ENSO_composite_monthly.nc')
