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

WIND_year=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/WIND/ncfile/WIND_10th.nc','WIND_year');
DUST=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/DUST/ncfile/DUST.nc','DUST_DJF');

DUST_ECHINA=zeros(length(year),1);
DUST_ECHINA(:)=mean(mean(DUST(45:50,60:72,:),2),1);


DUST_weak_temp=zeros(144,96,sum(WIND_year));
DUST_ECHINA_weak=0;
n=0;
for yearID=1:length(year)
    if WIND_year(yearID)==1
        n=n+1;
        DUST_weak_temp(:,:,n)=DUST(:,:,yearID);
        DUST_ECHINA_weak=DUST_ECHINA_weak+DUST_ECHINA(yearID)/sum(WIND_year);
    end
end
DUST_weak=mean(DUST_weak_temp,3);


DUST_aveg=mean(DUST,3);
DUST_diff=DUST_weak-DUST_aveg;

DUST_ECHINA_aveg=mean(DUST_ECHINA);
DUST_ECHINA_diff=DUST_ECHINA_weak-DUST_ECHINA_aveg;

save('DUST_10th.mat','DUST_weak','DUST_aveg','DUST_diff')

nccreate('DUST_10th.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('DUST_10th.nc','lat', lat)
ncwriteatt('DUST_10th.nc','lat','units','degrees_north')
ncwriteatt('DUST_10th.nc','lat','long_name','Latitude')
nccreate('DUST_10th.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('DUST_10th.nc','lon', lon)
ncwriteatt('DUST_10th.nc','lon','units','degrees_east')
ncwriteatt('DUST_10th.nc','lon','long_name','Longitude')
nccreate('DUST_10th.nc','DUST_weak','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('DUST_10th.nc','DUST_weak', DUST_weak)
nccreate('DUST_10th.nc','DUST_aveg','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('DUST_10th.nc','DUST_aveg', DUST_aveg)
nccreate('DUST_10th.nc','DUST_diff','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('DUST_10th.nc','DUST_diff', DUST_diff)
ncdisp('DUST_10th.nc')