year=1986:2006;
lon=-180:2.5:177.5;
lat=-90:2:90;

UWND_temp=ncread('/Users/yangyang/Extreme_Aerosol/Meteorology/WIND850/ncfile/WIND850_daily.nc','u');

UWND=zeros(144,91,21);
UWND(:,:,:)=mean(UWND_temp,3);

WIND_year=ncread('/Users/yangyang/Aerosol_Variaiton/GEOS_Chem/ncfile/WIND_10th.nc','WIND_year');
UWND_temp=ncread('/Users/yangyang/Extreme_Aerosol/MET/ncfile/Aerosol_daily.nc','pm25');


UWND_ECHINA=zeros(21,1);
UWND_ECHINA(:)=mean(mean(UWND(117:122,57:68,:),2),1);


UWND_weak_temp=zeros(144,91,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_10th.mat','UWND_weak','UWND_aveg','UWND_diff')

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