load ~/NC/grid
load ~/NC/area_1.9_2.5.mat
year=1:150;

DUSTSF_temp=ncread('~/Aerosol_Variaiton/DRUN/read_nc/ncfile/read_nc_DUSTSF.nc','DUSTSF');

DUSTSF_ANN=zeros(144,96,150);

DUSTSF_ANN(:,:,:)=mean(DUSTSF_temp,3);

DUSTSF_GLOBAL_ANN=zeros(150,1);
for yearID=1:150
    DUSTSF_GLOBAL_ANN(yearID)=sum(sum(DUSTSF_ANN(:,:,yearID).*area,2),1)/sum(area(:));
end


save('DUSTSF.mat','DUSTSF_ANN','DUSTSF_GLOBAL_ANN')

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