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

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

DUSTSF_DJF=zeros(144,96,150);
DUSTSF_SON=zeros(144,96,150);

DUSTSF_DJF(:,:,1)=mean(DUSTSF_temp(:,:,[1,2],1),3);
for yearID=2:150
    DUSTSF_DJF(:,:,yearID)=(DUSTSF_temp(:,:,12,yearID-1)+DUSTSF_temp(:,:,1,yearID)+DUSTSF_temp(:,:,2,yearID))/3;
end
DUSTSF_SON(:,:,:)=mean(DUSTSF_temp(:,:,[9,10,11],:),3);

save('DUSTSF.mat','DUSTSF_DJF','DUSTSF_SON')

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_DJF','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('DUSTSF.nc','DUSTSF_DJF', DUSTSF_DJF)
nccreate('DUSTSF.nc','DUSTSF_SON','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('DUSTSF.nc','DUSTSF_SON', DUSTSF_SON)
ncdisp('DUSTSF.nc')