% Compute filter kernel of a Ricker wavelet ("Mexican hat")
% Input:  fcenter ... center frequency of bandpass  
%         fsample ... sample rate
% Output: kRick   ... Ricker kernel
% Author G. Fischer
% ------------------------------------------------------------------------
function [kRick] = getRickerKernel(fcenter,fsample)
  tauM = 1/(2*pi*fcenter);       % time constant "center"
  t2tau=1/(tauM*fsample);        % time ratio "center to sample"
  Nkern=round(9/t2tau);          % kernel width
  np=[-Nkern:Nkern];             % kernel sampling
  tp2=np*t2tau;                  % constant
  kRick=(1-0.5*tp2.*tp2).*exp(-0.25*tp2.*tp2); % compute kernel
  scale=sum(kRick.*cos(tp2));    % get kernel scale at center frequency
  kRick = kRick/scale;           % scale kernel
end

