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;

u=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/UWND/dat/wind850_ECMWF.nc','u');
v=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/UWND/dat/wind850_ECMWF.nc','v');

VWND_DJF=zeros(length(lon),length(lat),length(year));

n=1;
for yearID=1:length(year)
    VWND_DJF(:,:,yearID)=(v(:,:,n)+v(:,:,n+1)+v(:,:,n+2))/3;
    n=n+3;
end


save('VWND_ECMWF_1979_2014.mat','VWND_DJF')

nccreate('VWND_ECMWF_1979_2014.nc','Year','Dimensions',{'year',length(year)},'Format','netcdf4_classic')
ncwrite('VWND_ECMWF_1979_2014.nc','Year', year)
nccreate('VWND_ECMWF_1979_2014.nc','lat','Dimensions',{'lat',length(lat)},'Format','netcdf4_classic')
ncwrite('VWND_ECMWF_1979_2014.nc','lat', lat)
ncwriteatt('VWND_ECMWF_1979_2014.nc','lat','units','degrees_north')
ncwriteatt('VWND_ECMWF_1979_2014.nc','lat','long_name','Latitude')
nccreate('VWND_ECMWF_1979_2014.nc','lon','Dimensions',{'lon',length(lon)},'Format','netcdf4_classic')
ncwrite('VWND_ECMWF_1979_2014.nc','lon', lon)
ncwriteatt('VWND_ECMWF_1979_2014.nc','lon','units','degrees_east')
ncwriteatt('VWND_ECMWF_1979_2014.nc','lon','long_name','Longitude')
nccreate('VWND_ECMWF_1979_2014.nc','VWND_DJF','Dimensions',{'lon',length(lon),'lat',length(lat),'year',length(year)},'Format','netcdf4_classic')
ncwrite('VWND_ECMWF_1979_2014.nc','VWND_DJF', VWND_DJF)
ncdisp('VWND_ECMWF_1979_2014.nc')