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

AOD_temp=ncread('~/Aerosol_Variaiton/ERUN/read_nc/ncfile/read_nc_AOD.nc','AOD');

AOD_ANN=zeros(144,96,150);

AOD_ANN(:,:,:)=mean(AOD_temp,3);

save('AOD.mat','AOD_ANN')

nccreate('AOD.nc','Year','Dimensions',{'time',Inf},'Format','classic')
ncwrite('AOD.nc','Year', year)
ncwriteatt('AOD.nc','Year','long_name','Year')
nccreate('AOD.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('AOD.nc','lat', lat)
ncwriteatt('AOD.nc','lat','units','degrees_north')
ncwriteatt('AOD.nc','lat','long_name','Latitude')
nccreate('AOD.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('AOD.nc','lon', lon)
ncwriteatt('AOD.nc','lon','units','degrees_east')
ncwriteatt('AOD.nc','lon','long_name','Longitude')
nccreate('AOD.nc','AOD_ANN','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('AOD.nc','AOD_ANN', AOD_ANN)
ncdisp('AOD.nc')