lon=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/UWND/dat/wind850_ECMWF.nc','longitude');
lat=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/UWND/dat/wind850_ECMWF.nc','latitude');
year=1979:2014;

WIND_year=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/WIND/ncfile/WIND_ECMWF_10th_1979_2014.nc','WIND_year');
VWND=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/VWND/ncfile/VWND_ECMWF_1979_2014.nc','VWND_DJF');

VWND_ECHINA=zeros(length(year),1);
VWND_ECHINA(:)=mean(mean(VWND(111:123,46:71,:),2),1);

VWND_weak_temp=zeros(length(lon),length(lat),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_ECMWF_10th_1979_2014.mat','VWND_weak','VWND_aveg','VWND_diff')

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