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

WIND_year=ncread('/Users/yangyang/Aerosol_Variaiton/DRUN/WIND/ncfile/WIND_10th.nc','WIND_year');
ADESF=ncread('/Users/yangyang/Aerosol_Variaiton/DRUN/ADESF/ncfile/ADESF.nc','ADESF_DJF');

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


ADESF_weak_temp=zeros(144,96,sum(WIND_year));
ADESF_ECHINA_weak=0;
n=0;
for yearID=1:length(year)
    if WIND_year(yearID)==1
        n=n+1;
        ADESF_weak_temp(:,:,n)=ADESF(:,:,yearID);
        ADESF_ECHINA_weak=ADESF_ECHINA_weak+ADESF_ECHINA(yearID)/sum(WIND_year);
    end
end
ADESF_weak=mean(ADESF_weak_temp,3);


ADESF_aveg=mean(ADESF,3);
ADESF_diff=ADESF_weak-ADESF_aveg;

ADESF_ECHINA_aveg=mean(ADESF_ECHINA);
ADESF_ECHINA_diff=ADESF_ECHINA_weak-ADESF_ECHINA_aveg;

save('ADESF_10th.mat','ADESF_weak','ADESF_aveg','ADESF_diff')

nccreate('ADESF_10th.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('ADESF_10th.nc','lat', lat)
ncwriteatt('ADESF_10th.nc','lat','units','degrees_north')
ncwriteatt('ADESF_10th.nc','lat','long_name','Latitude')
nccreate('ADESF_10th.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('ADESF_10th.nc','lon', lon)
ncwriteatt('ADESF_10th.nc','lon','units','degrees_east')
ncwriteatt('ADESF_10th.nc','lon','long_name','Longitude')
nccreate('ADESF_10th.nc','ADESF_weak','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('ADESF_10th.nc','ADESF_weak', ADESF_weak)
nccreate('ADESF_10th.nc','ADESF_aveg','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('ADESF_10th.nc','ADESF_aveg', ADESF_aveg)
nccreate('ADESF_10th.nc','ADESF_diff','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('ADESF_10th.nc','ADESF_diff', ADESF_diff)
ncdisp('ADESF_10th.nc')