year=2001:2014;
lon=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/SST/dat/air.mon.mean.nc','lon');
lat=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/SST/dat/air.mon.mean.nc','lat');
load ~/Aerosol_Variaiton/IRUN/SST/ncfile/NINO34_yearly_NCEP.mat


SST_90th=prctile(NINO34,90);
SST_10th=prctile(NINO34,10);
EN_Year=zeros(length(year),1);
LL_Year=zeros(length(year),1);

for yearID=1:length(year);
    if NINO34(yearID)>SST_90th
        EN_Year(yearID)=1;
    end
    if NINO34(yearID)<SST_10th
        LL_Year(yearID)=1;
    end
end


save('ENSO_Year_NCEP.mat','EN_Year','LL_Year')

nccreate('ENSO_Year_NCEP.nc','Year','Dimensions',{'time',Inf},'Format','classic')
ncwrite('ENSO_Year_NCEP.nc','Year', year)
ncwriteatt('ENSO_Year_NCEP.nc','Year','long_name','Year')
nccreate('ENSO_Year_NCEP.nc','EN_Year','Dimensions',{'year',length(year)},'Format','classic')
ncwrite('ENSO_Year_NCEP.nc','EN_Year', EN_Year)
nccreate('ENSO_Year_NCEP.nc','LL_Year','Dimensions',{'year',length(year)},'Format','classic')
ncwrite('ENSO_Year_NCEP.nc','LL_Year', LL_Year)
ncdisp('ENSO_Year_NCEP.nc')