load ~/NC/grid
month=1:1800;
load ~/Aerosol_Variaiton/DRUN/SST/ncfile/NINO34_monthly.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.mat','EN_Month','LL_Month')

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