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,1),3);
for yearID=2:150
    WIND_DJF(:,:,yearID)=WIND_temp(:,:,12,yearID-1);
end


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

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