function [otrace]=ttshift(itrace,ndt,shift)

% [OTRACE] = TTSHIFT(ITRACE,NDT,SHIFT) shifts time series
% ITRACE, which has a sampling rate of NDT (s), by time
% SHIFT (s). 

    ntr=size(itrace,1);
    ntn=size(itrace,2);
    ntf=2^ceil(log(ntn)/log(2));
    jomega=sqrt(-1)*(0:ntf/2)*2*pi/(ntf*ndt);
    id=0;
    if ntr>1 && length(shift)==1
      shift=shift*ones(1,ntr);
    end
    for ista=1:ntr
      id=id+1;
      qdum1=fft(itrace(ista,:),ntf);
      qdum2=qdum1(1:round(ntf/2)+1).*exp(-shift(ista)*jomega);
      otrace(ista,:)=real(ifft([qdum2,conj(fliplr(qdum2(2:round(ntf/2))))]));
    end
    otrace=otrace(:,1:ntn);