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

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

VWND=zeros(144,91,21);
VWND(:,:,:)=mean(VWND_temp,3);

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


VWND_ECHINA=zeros(21,1);
VWND_ECHINA(:)=mean(mean(VWND(117:122,57:68,:),2),1);


VWND_weak_temp=zeros(144,91,sum(WIND_year));
VWND_ECHINA_weak=0;
n=0;
for yearID=1:length(year)
    if WIND_year(yearID)==1
        n=n+1;
        VWND_weak_temp(:,:,n)=VWND(:,:,yearID);
        VWND_ECHINA_weak=VWND_ECHINA_weak+VWND_ECHINA(yearID)/sum(WIND_year);
    end
end
VWND_weak=mean(VWND_weak_temp,3);


VWND_aveg=mean(VWND,3);
VWND_diff=VWND_weak-VWND_aveg;

VWND_ECHINA_aveg=mean(VWND_ECHINA);
VWND_ECHINA_diff=VWND_ECHINA_weak-VWND_ECHINA_aveg;

save('VWND_10th.mat','VWND_weak','VWND_aveg','VWND_diff')

nccreate('VWND_10th.nc','lat','Dimensions',{'lat',91},'Format','classic')
ncwrite('VWND_10th.nc','lat', lat)
ncwriteatt('VWND_10th.nc','lat','units','degrees_north')
ncwriteatt('VWND_10th.nc','lat','long_name','Latitude')
nccreate('VWND_10th.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('VWND_10th.nc','lon', lon)
ncwriteatt('VWND_10th.nc','lon','units','degrees_east')
ncwriteatt('VWND_10th.nc','lon','long_name','Longitude')
nccreate('VWND_10th.nc','VWND_weak','Dimensions',{'lon',144,'lat',91},'Format','classic')
ncwrite('VWND_10th.nc','VWND_weak', VWND_weak)
nccreate('VWND_10th.nc','VWND_aveg','Dimensions',{'lon',144,'lat',91},'Format','classic')
ncwrite('VWND_10th.nc','VWND_aveg', VWND_aveg)
nccreate('VWND_10th.nc','VWND_diff','Dimensions',{'lon',144,'lat',91},'Format','classic')
ncwrite('VWND_10th.nc','VWND_diff', VWND_diff)
ncdisp('VWND_10th.nc')