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

WIND_year=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/WIND/ncfile/WIND_20th.nc','WIND_year');
UWND=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/UWND/ncfile/UWND.nc','UWND_DJF');

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


UWND_weak_temp=zeros(144,96,sum(WIND_year));
UWND_ECHINA_weak=0;
n=0;
for yearID=1:length(year)
    if WIND_year(yearID)==1
        n=n+1;
        UWND_weak_temp(:,:,n)=UWND(:,:,yearID);
        UWND_ECHINA_weak=UWND_ECHINA_weak+UWND_ECHINA(yearID)/sum(WIND_year);
    end
end
UWND_weak=mean(UWND_weak_temp,3);


UWND_aveg=mean(UWND,3);
UWND_diff=UWND_weak-UWND_aveg;

UWND_ECHINA_aveg=mean(UWND_ECHINA);
UWND_ECHINA_diff=UWND_ECHINA_weak-UWND_ECHINA_aveg;

save('UWND_20th.mat','UWND_weak','UWND_aveg','UWND_diff')

nccreate('UWND_20th.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('UWND_20th.nc','lat', lat)
ncwriteatt('UWND_20th.nc','lat','units','degrees_north')
ncwriteatt('UWND_20th.nc','lat','long_name','Latitude')
nccreate('UWND_20th.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('UWND_20th.nc','lon', lon)
ncwriteatt('UWND_20th.nc','lon','units','degrees_east')
ncwriteatt('UWND_20th.nc','lon','long_name','Longitude')
nccreate('UWND_20th.nc','UWND_weak','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('UWND_20th.nc','UWND_weak', UWND_weak)
nccreate('UWND_20th.nc','UWND_aveg','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('UWND_20th.nc','UWND_aveg', UWND_aveg)
nccreate('UWND_20th.nc','UWND_diff','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('UWND_20th.nc','UWND_diff', UWND_diff)
ncdisp('UWND_20th.nc')