lon=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/VWND/dat/vwnd.mon.mean.nc','lon');
lat=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/VWND/dat/vwnd.mon.mean.nc','lat');
year=1:67;

v_temp=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/VWND/dat/vwnd.mon.mean.nc','vwnd');

VWND_temp=zeros(length(lon),length(lat),12,length(year));

for yearID=1:length(year)
    VWND_temp(:,:,:,yearID)=v_temp(:,:,3,(yearID-1)*12+1:(yearID-1)*12+12);
end

VWND_DJF=zeros(length(lon),length(lat),length(year));
VWND_DJF(:,:,1)=(VWND_temp(:,:,1,1)+VWND_temp(:,:,2,1))/2;
for yearID=2:length(year)
    VWND_DJF(:,:,yearID)=(VWND_temp(:,:,12,yearID-1)+VWND_temp(:,:,1,yearID)+VWND_temp(:,:,2,yearID))/3;
end

VWND_MAM=zeros(length(lon),length(lat),length(year));
VWND_MAM(:,:,:)=mean(VWND_temp(:,:,3:5,:),3);

save('VWND_NCEP.mat','VWND_DJF','VWND_MAM')

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