lon_ECMWF=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/SST/dat/SST_ECMWF.nc','longitude');
lat_ECMWF=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/SST/dat/SST_ECMWF.nc','latitude');
lat=-89.5:1:89.5;
lon=-179.5:1:179.5;
year=1:36;
month=1:432;
load ~/Aerosol_Variaiton/IRUN/SST/ncfile/NINO34_monthly_ECMWF_1979_2014.mat

windowSize = 5;
x=NINO34;
y=filter(ones(1,windowSize)/windowSize,1,x);

EN_Month=zeros(length(month),1);
LL_Month=zeros(length(month),1);

for monthID=1:length(month);
    if y(monthID)>0.4
        EN_Month(monthID)=1;
    end
    if y(monthID)<-0.4
        LL_Month(monthID)=1;
    end
end


save('ENSO_Month_ECMWF_1979_2014.mat','EN_Month','LL_Month')

nccreate('ENSO_Month_ECMWF_1979_2014.nc','Month','Dimensions',{'time',Inf},'Format','classic')
ncwrite('ENSO_Month_ECMWF_1979_2014.nc','Month', month)
ncwriteatt('ENSO_Month_ECMWF_1979_2014.nc','Month','long_name','month')
nccreate('ENSO_Month_ECMWF_1979_2014.nc','EN_Month','Dimensions',{'month',length(month)},'Format','classic')
ncwrite('ENSO_Month_ECMWF_1979_2014.nc','EN_Month', EN_Month)
nccreate('ENSO_Month_ECMWF_1979_2014.nc','LL_Month','Dimensions',{'month',length(month)},'Format','classic')
ncwrite('ENSO_Month_ECMWF_1979_2014.nc','LL_Month', LL_Month)
ncdisp('ENSO_Month_ECMWF_1979_2014.nc')