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

AODDUST_temp=ncread('~/Aerosol_Variaiton/IRUN/read_nc/ncfile/read_nc_AODDUST.nc','AODDUST');

AODDUST_ANN=zeros(144,96,150);
AODDUST_DJF=zeros(144,96,150);
AODDUST_MAM=zeros(144,96,150);
AODDUST_JJA=zeros(144,96,150);
AODDUST_SON=zeros(144,96,150);
AODDUST_JAN=zeros(144,96,150);
AODDUST_JUL=zeros(144,96,150);

AODDUST_ANN(:,:,:)=mean(AODDUST_temp,3);
AODDUST_MAM(:,:,:)=mean(AODDUST_temp(:,:,[3,4,5],:),3);
AODDUST_JJA(:,:,:)=mean(AODDUST_temp(:,:,[6,7,8],:),3);
AODDUST_SON(:,:,:)=mean(AODDUST_temp(:,:,[9,10,11],:),3);
AODDUST_DJF(:,:,1)=mean(AODDUST_temp(:,:,[1,2],1),3);
for yearID=2:150
    AODDUST_DJF(:,:,yearID)=(AODDUST_temp(:,:,12,yearID-1)+AODDUST_temp(:,:,1,yearID)+AODDUST_temp(:,:,2,yearID))/3;
end
AODDUST_JAN(:,:,:)=AODDUST_temp(:,:,1,:);
AODDUST_JUL(:,:,:)=AODDUST_temp(:,:,7,:);
AODDUST_MONTH=AODDUST_temp;

save('AODDUST.mat','AODDUST_ANN','AODDUST_DJF','AODDUST_MAM','AODDUST_JJA','AODDUST_SON','AODDUST_JAN','AODDUST_JUL','AODDUST_MONTH')

nccreate('AODDUST.nc','Year','Dimensions',{'time',Inf},'Format','classic')
ncwrite('AODDUST.nc','Year', year)
ncwriteatt('AODDUST.nc','Year','long_name','Year')
nccreate('AODDUST.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('AODDUST.nc','lat', lat)
ncwriteatt('AODDUST.nc','lat','units','degrees_north')
ncwriteatt('AODDUST.nc','lat','long_name','Latitude')
nccreate('AODDUST.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('AODDUST.nc','lon', lon)
ncwriteatt('AODDUST.nc','lon','units','degrees_east')
ncwriteatt('AODDUST.nc','lon','long_name','Longitude')
nccreate('AODDUST.nc','AODDUST_ANN','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('AODDUST.nc','AODDUST_ANN', AODDUST_ANN)
nccreate('AODDUST.nc','AODDUST_DJF','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('AODDUST.nc','AODDUST_DJF', AODDUST_DJF)
nccreate('AODDUST.nc','AODDUST_MAM','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('AODDUST.nc','AODDUST_MAM', AODDUST_MAM)
nccreate('AODDUST.nc','AODDUST_JJA','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('AODDUST.nc','AODDUST_JJA', AODDUST_JJA)
nccreate('AODDUST.nc','AODDUST_SON','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('AODDUST.nc','AODDUST_SON', AODDUST_SON)
nccreate('AODDUST.nc','AODDUST_JAN','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('AODDUST.nc','AODDUST_JAN', AODDUST_JAN)
nccreate('AODDUST.nc','AODDUST_JUL','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('AODDUST.nc','AODDUST_JUL', AODDUST_JUL)
nccreate('AODDUST.nc','AODDUST_MONTH','Dimensions',{'lon',144,'lat',96,'month',12,'year',length(year)},'Format','classic')
ncwrite('AODDUST.nc','AODDUST_MONTH', AODDUST_MONTH)
ncdisp('AODDUST.nc')