Esempio n. 1
0
def test_noise_func_multi_channel():
    """Test generation of noise data, multiple channels.
    """
    n_samples = 2**10
    sigma = 1
    cshape = (2, 2)
    time = stub_utils.noise_func(sigma, n_samples, cshape)

    npt.assert_array_almost_equal(np.mean(time), 0, decimal=1)
    npt.assert_array_almost_equal(np.std(time, ddof=1), sigma, decimal=1)
Esempio n. 2
0
def test_noise_func():
    """Test generation of noise data, single channel.
    """
    n_samples = 2**18
    sigma = 1
    cshape = (1, )
    time, freq = stub_utils.noise_func(sigma, n_samples, cshape)

    npt.assert_array_almost_equal(np.mean(time), 0, decimal=1)
    npt.assert_array_almost_equal(np.std(time, ddof=1), sigma, decimal=1)
    e_time = np.mean(np.abs(time)**2)
    e_freq = np.sum(np.abs(freq)**2)
    npt.assert_array_almost_equal(e_time, e_freq, decimal=4)
Esempio n. 3
0
def noise_stub():
    """Gaussian white noise signal stub.
    To be used in cases, when a dependence on the Signal class is prohibited,
    but a correct, fixed relation of the time signal and the spectrum is
    needed.

    Returns
    -------
    signal : Signal
        Stub of noise signal
    """
    sigma = 1
    n_samples = int(1e5)
    cshape = (1, )
    sampling_rate = 44100
    fft_norm = 'rms'

    time, freq = stub_utils.noise_func(sigma, n_samples, cshape)
    signal = stub_utils.signal_stub(time, freq, sampling_rate, fft_norm)

    return signal
Esempio n. 4
0
def noise_two_by_three_channel():
    """ 2-by-3 channel gaussian white noise signal stub.
    The frequency spectrum is created with np.fft.rfft.

    Returns
    -------
    signal : Signal
        Stub of noise signal
    """
    sigma = 1
    n_samples = int(1e5)
    cshape = (2, 3)
    sampling_rate = 44100
    fft_norm = 'none'

    time = stub_utils.noise_func(sigma, n_samples, cshape)
    freq = np.fft.rfft(time)
    signal = stub_utils.signal_stub(
        time, freq, sampling_rate, fft_norm)

    return signal
Esempio n. 5
0
def noise_two_by_two_channel():
    """ 2-by-2 channel gaussian white noise signal stub.
    The frequency spectrum is set to dummy value None.

    Returns
    -------
    signal : Signal
        Stub of noise signal
    """
    sigma = 1
    n_samples = int(1e5)
    cshape = (2, 2)
    sampling_rate = 44100
    fft_norm = 'rms'
    freq = None

    time = stub_utils.noise_func(sigma, n_samples, cshape)
    signal = stub_utils.signal_stub(
        time, freq, sampling_rate, fft_norm)

    return signal
Esempio n. 6
0
def noise_odd():
    """Gaussian white noise signal stub,
    odd number of samples.
    The frequency spectrum is set to dummy value None.

    Returns
    -------
    signal : Signal
        Stub of noise signal
    """
    sigma = 1
    n_samples = int(1e5 - 1)
    cshape = (1,)
    sampling_rate = 44100
    fft_norm = 'rms'
    freq = None

    time = stub_utils.noise_func(sigma, n_samples, cshape)
    signal = stub_utils.signal_stub(
        time, freq, sampling_rate, fft_norm)

    return signal