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

u_temp=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/UWND/dat/uwnd.mon.mean.nc','uwnd');

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

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

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

UWND_MAM=zeros(length(lon),length(lat),length(year));
UWND_MAM(:,:,:)=mean(UWND_temp(:,:,3:5,:),3);

save('UWND_NCEP.mat','UWND_DJF','UWND_MAM')

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