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

AODSS_temp=ncread('~/Aerosol_Variaiton/IRUN/read_nc/ncfile/read_nc_AODSS.nc','AODSS');

AODSS_ANN=zeros(144,96,150);
AODSS_DJF=zeros(144,96,150);
AODSS_MAM=zeros(144,96,150);
AODSS_JJA=zeros(144,96,150);
AODSS_SON=zeros(144,96,150);
AODSS_JAN=zeros(144,96,150);
AODSS_JUL=zeros(144,96,150);

AODSS_ANN(:,:,:)=mean(AODSS_temp,3);
AODSS_MAM(:,:,:)=mean(AODSS_temp(:,:,[3,4,5],:),3);
AODSS_JJA(:,:,:)=mean(AODSS_temp(:,:,[6,7,8],:),3);
AODSS_SON(:,:,:)=mean(AODSS_temp(:,:,[9,10,11],:),3);
AODSS_DJF(:,:,1)=mean(AODSS_temp(:,:,[1,2],1),3);
for yearID=2:150
    AODSS_DJF(:,:,yearID)=(AODSS_temp(:,:,12,yearID-1)+AODSS_temp(:,:,1,yearID)+AODSS_temp(:,:,2,yearID))/3;
end
AODSS_JAN(:,:,:)=AODSS_temp(:,:,1,:);
AODSS_JUL(:,:,:)=AODSS_temp(:,:,7,:);

save('AODSS.mat','AODSS_ANN','AODSS_DJF','AODSS_MAM','AODSS_JJA','AODSS_SON','AODSS_JAN','AODSS_JUL')

nccreate('AODSS.nc','Year','Dimensions',{'time',Inf},'Format','classic')
ncwrite('AODSS.nc','Year', year)
ncwriteatt('AODSS.nc','Year','long_name','Year')
nccreate('AODSS.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('AODSS.nc','lat', lat)
ncwriteatt('AODSS.nc','lat','units','degrees_north')
ncwriteatt('AODSS.nc','lat','long_name','Latitude')
nccreate('AODSS.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('AODSS.nc','lon', lon)
ncwriteatt('AODSS.nc','lon','units','degrees_east')
ncwriteatt('AODSS.nc','lon','long_name','Longitude')
nccreate('AODSS.nc','AODSS_ANN','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('AODSS.nc','AODSS_ANN', AODSS_ANN)
nccreate('AODSS.nc','AODSS_DJF','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('AODSS.nc','AODSS_DJF', AODSS_DJF)
nccreate('AODSS.nc','AODSS_MAM','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('AODSS.nc','AODSS_MAM', AODSS_MAM)
nccreate('AODSS.nc','AODSS_JJA','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('AODSS.nc','AODSS_JJA', AODSS_JJA)
nccreate('AODSS.nc','AODSS_SON','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('AODSS.nc','AODSS_SON', AODSS_SON)
nccreate('AODSS.nc','AODSS_JAN','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('AODSS.nc','AODSS_JAN', AODSS_JAN)
nccreate('AODSS.nc','AODSS_JUL','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('AODSS.nc','AODSS_JUL', AODSS_JUL)
ncdisp('AODSS.nc')