예제 #1
0
def test_third2oct_2darray_axis0():
    levels = np.array([[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
                       [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0],
                       [100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]])
    generated = third2oct(levels, axis=0)
    real = np.array([100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0])
    assert_array_almost_equal(generated, real)
예제 #2
0
def test_third2oct_2darray():
    levels = np.array([[100, 95, 80, 55, 65, 85, 75, 70, 90, 95, 105, 110],
                       [100, 95, 80, 55, 65, 85, 75, 70, 90, 95, 105, 110]])
    generated = third2oct(levels, axis=1)
    real = np.array([[101.22618116, 85.04751156, 90.17710468, 111.29641738],
                     [101.22618116, 85.04751156, 90.17710468, 111.29641738]])
    assert_array_almost_equal(generated, real)
예제 #3
0
def test_third2oct_2darray():
    levels = np.array([[100, 95, 80, 55, 65, 85, 75, 70, 90, 95, 105, 110],
                       [100, 95, 80, 55, 65, 85, 75, 70, 90, 95, 105, 110]])
    generated = third2oct(levels, axis=1)
    real = np.array([[101.22618116, 85.04751156, 90.17710468, 111.29641738],
                     [101.22618116, 85.04751156, 90.17710468, 111.29641738]])
    assert_array_almost_equal(generated, real)
예제 #4
0
def test_third2oct_2darray_axis1():
    levels = np.array([[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
                       [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0],
                       [100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]])
    generated = third2oct(levels, axis=1)
    real = np.array([[5.77121255, 5.77121255, 5.77121255], [14.77121255, 14.77121255, 14.77121255],
                     [104.77121255, 104.77121255, 104.77121255]])
    assert_array_almost_equal(generated, real)
예제 #5
0
def test_third2oct_2darray_axis0():
    levels = np.array([[  1.0,   1.0,   1.0,   1.0,   1.0,   1.0,   1.0,   1.0,   1.0],
                       [ 10.0,  10.0,  10.0,  10.0,  10.0,  10.0,  10.0,  10.0,  10.0],
                       [100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]
                       ])
    generated = third2oct(levels, axis=0)
    real = np.array([100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0])
    assert_array_almost_equal(generated, real)
예제 #6
0
def test_third2oct_2darray_axis1():
    levels = np.array(
        [[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
         [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0],
         [100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]])
    generated = third2oct(levels, axis=1)
    real = np.array([[5.77121255, 5.77121255, 5.77121255],
                     [14.77121255, 14.77121255, 14.77121255],
                     [104.77121255, 104.77121255, 104.77121255]])
    assert_array_almost_equal(generated, real)
예제 #7
0
def test_third2oct_3darray_axis0():

    # Array of ones with shape (3,4,5)
    levels = np.array([[[1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.]],
                       [[1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.]],
                       [[1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.]]])

    generated = third2oct(levels, axis=0)
    real = np.array([[5.77121255, 5.77121255, 5.77121255, 5.77121255, 5.77121255],
                     [5.77121255, 5.77121255, 5.77121255, 5.77121255, 5.77121255],
                     [5.77121255, 5.77121255, 5.77121255, 5.77121255, 5.77121255],
                     [5.77121255, 5.77121255, 5.77121255, 5.77121255, 5.77121255]])
    assert_array_almost_equal(generated, real)
예제 #8
0
def test_third2oct_3darray_axis0():

    # Array of ones with shape (3,4,5)
    levels = np.array([[[1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.],
                        [1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.]],
                       [[1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.],
                        [1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.]],
                       [[1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.],
                        [1., 1., 1., 1., 1.], [1., 1., 1., 1., 1.]]])

    generated = third2oct(levels, axis=0)
    real = np.array(
        [[5.77121255, 5.77121255, 5.77121255, 5.77121255, 5.77121255],
         [5.77121255, 5.77121255, 5.77121255, 5.77121255, 5.77121255],
         [5.77121255, 5.77121255, 5.77121255, 5.77121255, 5.77121255],
         [5.77121255, 5.77121255, 5.77121255, 5.77121255, 5.77121255]])
    assert_array_almost_equal(generated, real)
예제 #9
0
def test_third2oct():

    levels = np.array([10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0])
    generated = third2oct(levels)
    real = np.array([14.77121255, 14.77121255, 14.77121255])
    assert_array_almost_equal(generated, real)
예제 #10
0
def test_third2oct():

    levels = np.array([10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0])
    generated = third2oct(levels)
    real = np.array([14.77121255, 14.77121255, 14.77121255])
    assert_array_almost_equal(generated, real)
예제 #11
0
print "reference SPL:", acd.REFERENCE_PRESSURE
print "equivalent SPL:",acd.equivalent_sound_pressure_level(sigy)
print "peak SPL:",      acd.peak_sound_pressure(sigy)

""" IEC 61672
"""
import acoustics.standards as acs
print "third octave center frequency vector:",   acs.iec_61672_1_2013.NOMINAL_OCTAVE_CENTER_FREQUENCIES
print "reference frequency:",                    acs.iec_61672_1_2013.REFERENCE_FREQUENCY
print "slow time constant:",                     acs.iec_61672_1_2013.SLOW

""" third octave band
"""
import acoustics.bands as acb
print "some thrid octave frequency:", acb.third(100, 500)
print "third octave to octave:",acb.third2oct([10,10,10,10,10,10])

""" third octave analysis
"""
import acoustics.signal as ass
a,AX  = ass.third_octaves(sigy, fs)
a,AZ1 = ass.third_octaves(sigz1, fs)
a,AZ2 = ass.third_octaves(sigz2, fs)

""" show graphics using pylab
"""

import pylab as plt
plt.hold(True)

x = acoustics.bands.THIRD_OCTAVE_CENTER_FREQUENCIES