load ~/NC/grid
year=1:150;

SST_ANN=ncread('~/Aerosol_Variaiton/IRUN/SST/ncfile/SST.nc','SST_ANN');

for i=1:144
    for j=1:96
        temp=mean(SST_ANN(i,j,:),3);
        SST_ANN(i,j,:)=SST_ANN(i,j,:)-temp;
    end
end

NINO34=zeros(150,1);
NINO34(:)=mean(mean(SST_ANN(77:97,46:51,:),2),1);


save('NINO34_ANN.mat','NINO34')

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