Example #1
0
def test_morletf():
    """
    Confirm consistency in morlet wavelet filtering
    """
    # Load data
    data = np.load(os.path.dirname(pacpy.__file__) + '/tests/exampledata.npy')
    assert np.allclose(np.sum(np.abs(morletf(data, 21.5))),
                       40661855.060118973,
                       atol=10**-5)
    assert len(morletf(data, 21.5)) == len(data)
Example #2
0
def test_morletf():
    """
    Confirm consistency in morlet wavelet filtering
    """
    # Load data
    data = np.load(os.path.dirname(pacpy.__file__) + "/tests/exampledata.npy")
    assert np.allclose(np.sum(np.abs(morletf(data, 21.5))), 40125678.7918, atol=10 ** -4)
Example #3
0
def _morletT(x, f0s, w=3, fs=1000, s=1):
    """
    Calculate the time-frequency representation of the signal 'x' over the
    frequencies in 'f0s' using morlet wavelets
    Parameters
    ----------
    x : array
        time series
    f0s : array
        frequency axis
    w : float
        Length of the filter in terms of the number of cycles 
        of the oscillation whose frequency is the center of the 
        bandpass filter
    Fs : float
        Sampling rate
    s : float
        Scaling factor
    Returns
    -------
    mwt : 2-D array
        time-frequency representation of signal x
    """
    if w <= 0:
        raise ValueError(
            'Number of cycles in a filter must be a positive number.')

    T = len(x)
    F = len(f0s)
    mwt = np.zeros([F, T], dtype=complex)
    for f in range(F):
        mwt[f] = morletf(x, f0s[f], fs=fs, w=w, s=s)

    return mwt
Example #4
0
def test_morletf():
    """
    Confirm consistency in morlet wavelet filtering
    """
    # Load data
    data = np.load(os.path.dirname(pacpy.__file__) + '/tests/exampledata.npy')
    assert np.allclose(
        np.sum(np.abs(morletf(data, 21.5))), 40125678.7918, atol=10 ** -4)
Example #5
0
def _morletT(x, f0s, w=3, fs=1000, s=1):
    """
    Calculate the time-frequency representation of the signal 'x' over the
    frequencies in 'f0s' using morlet wavelets

    Parameters
    ----------
    x : array
        time series
    f0s : array
        frequency axis
    w : float
        Length of the filter in terms of the number of cycles 
        of the oscillation whose frequency is the center of the 
        bandpass filter
    Fs : float
        Sampling rate
    s : float
        Scaling factor

    Returns
    -------
    mwt : 2-D array
        time-frequency representation of signal x
    """
    if w <= 0:
        raise ValueError(
            'Number of cycles in a filter must be a positive number.')

    T = len(x)
    F = len(f0s)
    mwt = np.zeros([F, T], dtype=complex)
    for f in range(F):
        mwt[f] = morletf(x, f0s[f], fs=fs, w=w, s=s)

    return mwt