def wmorlet(f0, sd, sampling_rate, ns=5, normed='area'):
    """
    returns a complex morlet wavelet in the time domain

    Parameters
    ----------
        f0 : center frequency
        sd : standard deviation of frequency
        sampling_rate : samplingrate
        ns : window length in number of standard deviations
    """
    st = 1. / (2. * np.pi * sd)
    w_sz = float(int(ns * st * sampling_rate))  # half time window size
    t = np.arange(-w_sz, w_sz + 1, dtype=float) / sampling_rate
    if normed == 'area':
        w = np.exp(-t ** 2 / (2. * st ** 2)) * np.exp(
            2j * np.pi * f0 * t) / np.sqrt(np.sqrt(np.pi) * st * sampling_rate)
    elif normed == 'max':
        w = np.exp(-t ** 2 / (2. * st ** 2)) * np.exp(
            2j * np.pi * f0 * t) * 2 * sd * np.sqrt(2 * np.pi) / sampling_rate
    else:
        assert 0, 'unknown norm %s' % normed
    return w
dataset/ETHPy150Open nipy/nitime/nitime/algorithms/wavelet.py/wmorlet/original