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

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

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


ADE_weak_temp=zeros(144,96,sum(WIND_year));
ADE_ECHINA_weak=0;
n=0;
for yearID=1:length(year)
    if WIND_year(yearID)==1
        n=n+1;
        ADE_weak_temp(:,:,n)=ADE(:,:,yearID);
        ADE_ECHINA_weak=ADE_ECHINA_weak+ADE_ECHINA(yearID)/sum(WIND_year);
    end
end
ADE_weak=mean(ADE_weak_temp,3);


ADE_aveg=mean(ADE,3);
ADE_diff=ADE_weak-ADE_aveg;

ADE_ECHINA_aveg=mean(ADE_ECHINA);
ADE_ECHINA_diff=ADE_ECHINA_weak-ADE_ECHINA_aveg;

save('ADE_10th.mat','ADE_weak','ADE_aveg','ADE_diff')

nccreate('ADE_10th.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('ADE_10th.nc','lat', lat)
ncwriteatt('ADE_10th.nc','lat','units','degrees_north')
ncwriteatt('ADE_10th.nc','lat','long_name','Latitude')
nccreate('ADE_10th.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('ADE_10th.nc','lon', lon)
ncwriteatt('ADE_10th.nc','lon','units','degrees_east')
ncwriteatt('ADE_10th.nc','lon','long_name','Longitude')
nccreate('ADE_10th.nc','ADE_weak','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('ADE_10th.nc','ADE_weak', ADE_weak)
nccreate('ADE_10th.nc','ADE_aveg','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('ADE_10th.nc','ADE_aveg', ADE_aveg)
nccreate('ADE_10th.nc','ADE_diff','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('ADE_10th.nc','ADE_diff', ADE_diff)
ncdisp('ADE_10th.nc')