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

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

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


AOD_weak_temp=zeros(144,96,sum(WIND_year));
AOD_ECHINA_weak=0;
n=0;
for yearID=1:length(year)
    if WIND_year(yearID)==1
        n=n+1;
        AOD_weak_temp(:,:,n)=AOD(:,:,yearID);
        AOD_ECHINA_weak=AOD_ECHINA_weak+AOD_ECHINA(yearID)/sum(WIND_year);
    end
end
AOD_weak=mean(AOD_weak_temp,3);


AOD_aveg=mean(AOD,3);
AOD_diff=AOD_weak-AOD_aveg;

AOD_ECHINA_aveg=mean(AOD_ECHINA);
AOD_ECHINA_diff=AOD_ECHINA_weak-AOD_ECHINA_aveg;

save('AOD_10th.mat','AOD_weak','AOD_aveg','AOD_diff')

nccreate('AOD_10th.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('AOD_10th.nc','lat', lat)
ncwriteatt('AOD_10th.nc','lat','units','degrees_north')
ncwriteatt('AOD_10th.nc','lat','long_name','Latitude')
nccreate('AOD_10th.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('AOD_10th.nc','lon', lon)
ncwriteatt('AOD_10th.nc','lon','units','degrees_east')
ncwriteatt('AOD_10th.nc','lon','long_name','Longitude')
nccreate('AOD_10th.nc','AOD_weak','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('AOD_10th.nc','AOD_weak', AOD_weak)
nccreate('AOD_10th.nc','AOD_aveg','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('AOD_10th.nc','AOD_aveg', AOD_aveg)
nccreate('AOD_10th.nc','AOD_diff','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('AOD_10th.nc','AOD_diff', AOD_diff)
ncdisp('AOD_10th.nc')