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

UWND=ncread('~/Aerosol_Variaiton/IRUN/read_nc/ncfile/read_nc_UWND.nc','UWND');
VWND=ncread('~/Aerosol_Variaiton/IRUN/read_nc/ncfile/read_nc_VWND.nc','VWND');
WIND_temp=sqrt(UWND.*UWND+VWND.*VWND);

WIND_DJF=zeros(144,96,150);

WIND_DJF(:,:,1)=mean(WIND_temp(:,:,[1,2],1),3);
for yearID=2:150
    WIND_DJF(:,:,yearID)=(WIND_temp(:,:,12,yearID-1)+WIND_temp(:,:,1,yearID)+WIND_temp(:,:,2,yearID))/3;
end


save('WIND.mat','WIND_DJF')

nccreate('WIND.nc','Year','Dimensions',{'time',Inf},'Format','classic')
ncwrite('WIND.nc','Year', year)
ncwriteatt('WIND.nc','Year','long_name','Year')
nccreate('WIND.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('WIND.nc','lat', lat)
ncwriteatt('WIND.nc','lat','units','degrees_north')
ncwriteatt('WIND.nc','lat','long_name','Latitude')
nccreate('WIND.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('WIND.nc','lon', lon)
ncwriteatt('WIND.nc','lon','units','degrees_east')
ncwriteatt('WIND.nc','lon','long_name','Longitude')
nccreate('WIND.nc','WIND_DJF','Dimensions',{'lon',144,'lat',96,'year',length(year)},'Format','classic')
ncwrite('WIND.nc','WIND_DJF', WIND_DJF)
ncdisp('WIND.nc')