示例#1
0
def test_exponential_sweep_deprecation():
    with pytest.warns(PendingDeprecationWarning,
                      match="This function will be deprecated"):
        pfs.exponential_sweep(2**10, [1e3, 20e3])

    if version.parse(pf.__version__) >= version.parse('0.5.0'):
        with pytest.raises(AttributeError):
            # remove exponential_sweep() from pyfar 0.5.0!
            pfs.exponential_sweep(2**10, [1e3, 20e3])
示例#2
0
def test_exponential_sweep_amplitude_sampling_rate():
    """Test exponential sweep with custom amplitude and sampling rate."""
    sweep = pfs.exponential_sweep(
        2**10, [1e3, 20e3], amplitude=2, sampling_rate=48000)

    assert sweep.sampling_rate == 48000
    npt.assert_allclose(
        np.max(np.abs(sweep.time)), np.array(2), rtol=1e-6, atol=1e-6)
示例#3
0
def test_exponential_sweep_rate():
    """Test exponential sweep with sweep rate."""
    sweep = pfs.exponential_sweep(None, [1e3, 2e3], sweep_rate=10)

    # duration in seconds
    T = 1 / 10 / np.log(2) * np.log(2e3 / 1e3)
    # duration in samples
    n_samples = np.round(T * 44100)
    # only test the length because it is the only thing that changes
    assert sweep.n_samples == n_samples
示例#4
0
def test_exponential_sweep_against_reference():
    """Test exponential sweep against manually verified reference."""
    sweep = pfs.exponential_sweep(2**10, [1e3, 20e3])
    reference = np.loadtxt(os.path.join(os.path.dirname(__file__),
                           "references", "signals.exponential_sweep.csv"))

    npt.assert_allclose(sweep.time, np.atleast_2d(reference))
    assert sweep.cshape == (1, )
    assert sweep.n_samples == 2**10
    assert sweep.sampling_rate == 44100
    assert sweep.fft_norm == "rms"
    assert sweep.comment == ("exponential sweep between 1000.0 and 20000.0 Hz "
                             "with 90 samples squared cosine fade-out.")
示例#5
0
# Write exponential sweep to csv for testing.
# The sweep was manually inspected.
# The time signal was inspected for smootheness and maximum amplitudes of +/-1.
# The spectrum was inspected for the ripple at the edges of the frequency range
# (typical for time domain sweep generation) and the 1/f slope.
import numpy as np
from pyfar.signals import exponential_sweep

sweep = exponential_sweep(2**10, [1e3, 20e3]).time
np.savetxt("signals.exponential_sweep.csv", sweep)
示例#6
0
def test_exponential_sweep_assertion():
    with pytest.raises(ValueError, match="The exponential sweep can not start"):
        pfs.exponential_sweep(2**10, [0, 20e3])