load ~/NC/grid
year=1:150;
load ~/Aerosol_Variaiton/IRUN/SST/ncfile/NINO34.mat


EN_DJF=zeros(length(year),1);
LL_DJF=zeros(length(year),1);

for yearID=1:length(year);
    if NINO34_DJF(yearID)>0.4
        EN_DJF(yearID)=1;
    end
    if NINO34_DJF(yearID)<-0.4
        LL_DJF(yearID)=1;
    end
end


EN_JJA=zeros(length(year),1);
LL_JJA=zeros(length(year),1);

for yearID=1:length(year);
    if NINO34_JJA(yearID)>0.4
        EN_JJA(yearID)=1;
    end
    if NINO34_JJA(yearID)<-0.4
        LL_JJA(yearID)=1;
    end
end

save('ENSO_Season.mat','EN_DJF','LL_DJF','EN_JJA','LL_JJA')

nccreate('ENSO_Season.nc','Year','Dimensions',{'time',Inf},'Format','classic')
ncwrite('ENSO_Season.nc','Year', year)
ncwriteatt('ENSO_Season.nc','Year','long_name','Year')
nccreate('ENSO_Season.nc','EN_DJF','Dimensions',{'year',length(year)},'Format','classic')
ncwrite('ENSO_Season.nc','EN_DJF', EN_DJF)
nccreate('ENSO_Season.nc','LL_DJF','Dimensions',{'year',length(year)},'Format','classic')
ncwrite('ENSO_Season.nc','LL_DJF', LL_DJF)
nccreate('ENSO_Season.nc','EN_JJA','Dimensions',{'year',length(year)},'Format','classic')
ncwrite('ENSO_Season.nc','EN_JJA', EN_JJA)
nccreate('ENSO_Season.nc','LL_JJA','Dimensions',{'year',length(year)},'Format','classic')
ncwrite('ENSO_Season.nc','LL_JJA', LL_JJA)
ncdisp('ENSO_Season.nc')