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

SST_90th=prctile(NINO34,90);
SST_10th=prctile(NINO34,10);
EN_Month=zeros(length(month),1);
LL_Month=zeros(length(month),1);

for monthID=1:length(month);
    if NINO34(monthID)>SST_90th
        EN_Month(monthID)=1;
    end
    if NINO34(monthID)<SST_10th
        LL_Month(monthID)=1;
    end
end


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

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