def _third_octave_levels(sig, fs):
    '3rd octave filtering, squaring, smoothing, level calculation and\n    downsampling to temporal resolution: 0,5 ms, i.e. sampling rate: 2 kHz\n\n    See ISO 532-1 section 6.3\n\n    Parameters\n    ----------\n    sig : numpy.ndarray\n        time signal sampled at 48 kHz[pa]\n    fs : int\n        time signal sampling frequency\n\n    Outputs\n    -------\n    third_octave_levels : numpy.ndarray\n        Set of time signals filtered per third octave bands\n    '
    if (fs != 48000):
        raise ValueError('ERROR: Sampling frequency shall be equal to 48 kHz')
    n_level_band = 28
    n_filter_coeff = 6
    dec_factor = int((fs / 2000))
    coeff = np.zeros(n_filter_coeff)
    third_octave_filter_ref = np.array([[1, 2, 1, 1, (- 2), 1], [1, 0, (- 1), 1, (- 2), 1], [1, (- 2), 1, 1, (- 2), 1]])
    third_octave_filter = np.array([[[0, 0, 0, 0, (- 0.00067026), 0.000659453], [0, 0, 0, 0, (- 0.000375071), 0.000361926], [0, 0, 0, 0, (- 0.000306523), 0.000297634]], [[0, 0, 0, 0, (- 0.000847258), 0.000830131], [0, 0, 0, 0, (- 0.000476448), 0.000455616], [0, 0, 0, 0, (- 0.000388773), 0.000374685]], [[0, 0, 0, 0, (- 0.0010721), 0.00104496], [0, 0, 0, 0, (- 0.000606567), 0.000573553], [0, 0, 0, 0, (- 0.000494004), 0.000471677]], [[0, 0, 0, 0, (- 0.00135836), 0.00131535], [0, 0, 0, 0, (- 0.000774327), 0.000722007], [0, 0, 0, 0, (- 0.000629154), 0.000593771]], [[0, 0, 0, 0, (- 0.0017238), 0.00165564], [0, 0, 0, 0, (- 0.00099178), 0.000908866], [0, 0, 0, 0, (- 0.000803529), 0.000747455]], [[0, 0, 0, 0, (- 0.00219188), 0.00208388], [0, 0, 0, 0, (- 0.00127545), 0.00114406], [0, 0, 0, 0, (- 0.00102976), 0.0009409]], [[0, 0, 0, 0, (- 0.00279386), 0.00262274], [0, 0, 0, 0, (- 0.00164828), 0.00144006], [0, 0, 0, 0, (- 0.0013252), 0.00118438]], [[0, 0, 0, 0, (- 0.00357182), 0.00330071], [0, 0, 0, 0, (- 0.00214252), 0.00181258], [0, 0, 0, 0, (- 0.00171397), 0.00149082]], [[0, 0, 0, 0, (- 0.00458305), 0.00415355], [0, 0, 0, 0, (- 0.00280413), 0.00228135], [0, 0, 0, 0, (- 0.00223006), 0.00187646]], [[0, 0, 0, 0, (- 0.00590655), 0.00522622], [0, 0, 0, 0, (- 0.00369947), 0.00287118], [0, 0, 0, 0, (- 0.00292205), 0.00236178]], [[0, 0, 0, 0, (- 0.00765243), 0.00657493], [0, 0, 0, 0, (- 0.0049254), 0.00361318], [0, 0, 0, 0, (- 0.00386007), 0.0029724]], [[0, 0, 0, 0, (- 0.0100023), 0.0082961], [0, 0, 0, 0, (- 0.00663788), 0.00455999], [0, 0, 0, 0, (- 0.00515982), 0.00375306]], [[0, 0, 0, 0, (- 0.013123), 0.010422], [0, 0, 0, 0, (- 0.00902274), 0.00573132], [0, 0, 0, 0, (- 0.00694543), 0.00471734]], [[0, 0, 0, 0, (- 0.0173693), 0.0130947], [0, 0, 0, 0, (- 0.0124176), 0.00720526], [0, 0, 0, 0, (- 0.00946002), 0.00593145]], [[0, 0, 0, 0, (- 0.0231934), 0.0164308], [0, 0, 0, 0, (- 0.0173009), 0.00904761], [0, 0, 0, 0, (- 0.0130358), 0.00744926]], [[0, 0, 0, 0, (- 0.0313292), 0.020637], [0, 0, 0, 0, (- 0.0244342), 0.0113731], [0, 0, 0, 0, (- 0.0182108), 0.00936778]], [[0, 0, 0, 0, (- 0.0428261), 0.0259325], [0, 0, 0, 0, (- 0.0349619), 0.0143046], [0, 0, 0, 0, (- 0.0257855), 0.0117912]], [[0, 0, 0, 0, (- 0.0591733), 0.0325054], [0, 0, 0, 0, (- 0.0506072), 0.0179513], [0, 0, 0, 0, (- 0.0369401), 0.0148094]], [[0, 0, 0, 0, (- 0.0826348), 0.0405894], [0, 0, 0, 0, (- 0.0740348), 0.0224476], [0, 0, 0, 0, (- 0.0534977), 0.0185371]], [[0, 0, 0, 0, (- 0.117018), 0.0508116], [0, 0, 0, 0, (- 0.109516), 0.0281387], [0, 0, 0, 0, (- 0.0785097), 0.0232872]], [[0, 0, 0, 0, (- 0.167714), 0.0637872], [0, 0, 0, 0, (- 0.163378), 0.0353729], [0, 0, 0, 0, (- 0.116419), 0.0293723]], [[0, 0, 0, 0, (- 0.242528), 0.0798576], [0, 0, 0, 0, (- 0.245161), 0.044337], [0, 0, 0, 0, (- 0.173972), 0.0370015]], [[0, 0, 0, 0, (- 0.353142), 0.099633], [0, 0, 0, 0, (- 0.369163), 0.0553535], [0, 0, 0, 0, (- 0.261399), 0.0465428]], [[0, 0, 0, 0, (- 0.516316), 0.124177], [0, 0, 0, 0, (- 0.555473), 0.0689403], [0, 0, 0, 0, (- 0.393998), 0.0586715]], [[0, 0, 0, 0, (- 0.756635), 0.155023], [0, 0, 0, 0, (- 0.834281), 0.0858123], [0, 0, 0, 0, (- 0.594547), 0.074396]], [[0, 0, 0, 0, (- 1.10165), 0.191713], [0, 0, 0, 0, (- 1.23939), 0.105243], [0, 0, 0, 0, (- 0.891666), 0.0940354]], [[0, 0, 0, 0, (- 1.58477), 0.239049], [0, 0, 0, 0, (- 1.80505), 0.128794], [0, 0, 0, 0, (- 1.325), 0.121333]], [[0, 0, 0, 0, (- 2.5063), 0.142308], [0, 0, 0, 0, (- 2.19464), 0.27647], [0, 0, 0, 0, (- 1.90231), 0.147304]]])
    filter_gain = np.array([4.30764e-11, 8.5934e-11, 1.71424e-10, 3.41944e-10, 6.82035e-10, 1.36026e-09, 2.71261e-09, 5.4087e-09, 1.07826e-08, 2.1491e-08, 4.28228e-08, 8.54316e-08, 1.70009e-07, 3.38215e-07, 6.7199e-07, 1.33531e-06, 2.65172e-06, 5.25477e-06, 1.0378e-05, 2.0487e-05, 4.05198e-05, 7.97914e-05, 0.000156511, 0.000304954, 0.000599157, 0.00116544, 0.00227488, 0.00391006])
    freq = [25, 31.5, 40, 50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800, 1000, 1250, 1600, 2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000, 12500]
    n_time = len(sig[::dec_factor])
    time_axis = np.linspace(0, (len(sig) / fs), num=n_time)
    third_octave_level = np.zeros((n_level_band, n_time))
    for i_bands in range(n_level_band):
        tiny_value = (10 ** (- 12))
        i_ref = (4 * (10 ** (- 10)))
        coeff = (third_octave_filter_ref - third_octave_filter[i_bands, :, :])
        sig_filt = (filter_gain[i_bands] * signal.sosfilt(coeff, sig))
        center_freq = ((10 ** ((i_bands - 16) / 10)) * 1000)
        sig_filt = _square_and_smooth(sig_filt, center_freq, 48000)
        third_octave_level[i_bands, :] = (10 * np.log10(((sig_filt[::dec_factor] + tiny_value) / i_ref)))
    return (third_octave_level, time_axis, freq)
3rd octave filtering, squaring, smoothing, level calculation and
downsampling to temporal resolution: 0,5 ms, i.e. sampling rate: 2 kHz

See ISO 532-1 section 6.3

Parameters
----------
sig : numpy.ndarray
    time signal sampled at 48 kHz[pa]
fs : int
    time signal sampling frequency

Outputs
-------
third_octave_levels : numpy.ndarray
    Set of time signals filtered per third octave bands
def _third_octave_levels(sig, fs):
    '3rd octave filtering, squaring, smoothing, level calculation and\n    downsampling to temporal resolution: 0,5 ms, i.e. sampling rate: 2 kHz\n\n    See ISO 532-1 section 6.3\n\n    Parameters\n    ----------\n    sig : numpy.ndarray\n        time signal sampled at 48 kHz[pa]\n    fs : int\n        time signal sampling frequency\n\n    Outputs\n    -------\n    third_octave_levels : numpy.ndarray\n        Set of time signals filtered per third octave bands\n    '
    if (fs != 48000):
        raise ValueError('ERROR: Sampling frequency shall be equal to 48 kHz')
    n_level_band = 28
    n_filter_coeff = 6
    dec_factor = int((fs / 2000))
    coeff = np.zeros(n_filter_coeff)
    third_octave_filter_ref = np.array([[1, 2, 1, 1, (- 2), 1], [1, 0, (- 1), 1, (- 2), 1], [1, (- 2), 1, 1, (- 2), 1]])
    third_octave_filter = np.array([[[0, 0, 0, 0, (- 0.00067026), 0.000659453], [0, 0, 0, 0, (- 0.000375071), 0.000361926], [0, 0, 0, 0, (- 0.000306523), 0.000297634]], [[0, 0, 0, 0, (- 0.000847258), 0.000830131], [0, 0, 0, 0, (- 0.000476448), 0.000455616], [0, 0, 0, 0, (- 0.000388773), 0.000374685]], [[0, 0, 0, 0, (- 0.0010721), 0.00104496], [0, 0, 0, 0, (- 0.000606567), 0.000573553], [0, 0, 0, 0, (- 0.000494004), 0.000471677]], [[0, 0, 0, 0, (- 0.00135836), 0.00131535], [0, 0, 0, 0, (- 0.000774327), 0.000722007], [0, 0, 0, 0, (- 0.000629154), 0.000593771]], [[0, 0, 0, 0, (- 0.0017238), 0.00165564], [0, 0, 0, 0, (- 0.00099178), 0.000908866], [0, 0, 0, 0, (- 0.000803529), 0.000747455]], [[0, 0, 0, 0, (- 0.00219188), 0.00208388], [0, 0, 0, 0, (- 0.00127545), 0.00114406], [0, 0, 0, 0, (- 0.00102976), 0.0009409]], [[0, 0, 0, 0, (- 0.00279386), 0.00262274], [0, 0, 0, 0, (- 0.00164828), 0.00144006], [0, 0, 0, 0, (- 0.0013252), 0.00118438]], [[0, 0, 0, 0, (- 0.00357182), 0.00330071], [0, 0, 0, 0, (- 0.00214252), 0.00181258], [0, 0, 0, 0, (- 0.00171397), 0.00149082]], [[0, 0, 0, 0, (- 0.00458305), 0.00415355], [0, 0, 0, 0, (- 0.00280413), 0.00228135], [0, 0, 0, 0, (- 0.00223006), 0.00187646]], [[0, 0, 0, 0, (- 0.00590655), 0.00522622], [0, 0, 0, 0, (- 0.00369947), 0.00287118], [0, 0, 0, 0, (- 0.00292205), 0.00236178]], [[0, 0, 0, 0, (- 0.00765243), 0.00657493], [0, 0, 0, 0, (- 0.0049254), 0.00361318], [0, 0, 0, 0, (- 0.00386007), 0.0029724]], [[0, 0, 0, 0, (- 0.0100023), 0.0082961], [0, 0, 0, 0, (- 0.00663788), 0.00455999], [0, 0, 0, 0, (- 0.00515982), 0.00375306]], [[0, 0, 0, 0, (- 0.013123), 0.010422], [0, 0, 0, 0, (- 0.00902274), 0.00573132], [0, 0, 0, 0, (- 0.00694543), 0.00471734]], [[0, 0, 0, 0, (- 0.0173693), 0.0130947], [0, 0, 0, 0, (- 0.0124176), 0.00720526], [0, 0, 0, 0, (- 0.00946002), 0.00593145]], [[0, 0, 0, 0, (- 0.0231934), 0.0164308], [0, 0, 0, 0, (- 0.0173009), 0.00904761], [0, 0, 0, 0, (- 0.0130358), 0.00744926]], [[0, 0, 0, 0, (- 0.0313292), 0.020637], [0, 0, 0, 0, (- 0.0244342), 0.0113731], [0, 0, 0, 0, (- 0.0182108), 0.00936778]], [[0, 0, 0, 0, (- 0.0428261), 0.0259325], [0, 0, 0, 0, (- 0.0349619), 0.0143046], [0, 0, 0, 0, (- 0.0257855), 0.0117912]], [[0, 0, 0, 0, (- 0.0591733), 0.0325054], [0, 0, 0, 0, (- 0.0506072), 0.0179513], [0, 0, 0, 0, (- 0.0369401), 0.0148094]], [[0, 0, 0, 0, (- 0.0826348), 0.0405894], [0, 0, 0, 0, (- 0.0740348), 0.0224476], [0, 0, 0, 0, (- 0.0534977), 0.0185371]], [[0, 0, 0, 0, (- 0.117018), 0.0508116], [0, 0, 0, 0, (- 0.109516), 0.0281387], [0, 0, 0, 0, (- 0.0785097), 0.0232872]], [[0, 0, 0, 0, (- 0.167714), 0.0637872], [0, 0, 0, 0, (- 0.163378), 0.0353729], [0, 0, 0, 0, (- 0.116419), 0.0293723]], [[0, 0, 0, 0, (- 0.242528), 0.0798576], [0, 0, 0, 0, (- 0.245161), 0.044337], [0, 0, 0, 0, (- 0.173972), 0.0370015]], [[0, 0, 0, 0, (- 0.353142), 0.099633], [0, 0, 0, 0, (- 0.369163), 0.0553535], [0, 0, 0, 0, (- 0.261399), 0.0465428]], [[0, 0, 0, 0, (- 0.516316), 0.124177], [0, 0, 0, 0, (- 0.555473), 0.0689403], [0, 0, 0, 0, (- 0.393998), 0.0586715]], [[0, 0, 0, 0, (- 0.756635), 0.155023], [0, 0, 0, 0, (- 0.834281), 0.0858123], [0, 0, 0, 0, (- 0.594547), 0.074396]], [[0, 0, 0, 0, (- 1.10165), 0.191713], [0, 0, 0, 0, (- 1.23939), 0.105243], [0, 0, 0, 0, (- 0.891666), 0.0940354]], [[0, 0, 0, 0, (- 1.58477), 0.239049], [0, 0, 0, 0, (- 1.80505), 0.128794], [0, 0, 0, 0, (- 1.325), 0.121333]], [[0, 0, 0, 0, (- 2.5063), 0.142308], [0, 0, 0, 0, (- 2.19464), 0.27647], [0, 0, 0, 0, (- 1.90231), 0.147304]]])
    filter_gain = np.array([4.30764e-11, 8.5934e-11, 1.71424e-10, 3.41944e-10, 6.82035e-10, 1.36026e-09, 2.71261e-09, 5.4087e-09, 1.07826e-08, 2.1491e-08, 4.28228e-08, 8.54316e-08, 1.70009e-07, 3.38215e-07, 6.7199e-07, 1.33531e-06, 2.65172e-06, 5.25477e-06, 1.0378e-05, 2.0487e-05, 4.05198e-05, 7.97914e-05, 0.000156511, 0.000304954, 0.000599157, 0.00116544, 0.00227488, 0.00391006])
    freq = [25, 31.5, 40, 50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800, 1000, 1250, 1600, 2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000, 12500]
    n_time = len(sig[::dec_factor])
    time_axis = np.linspace(0, (len(sig) / fs), num=n_time)
    third_octave_level = np.zeros((n_level_band, n_time))
    for i_bands in range(n_level_band):
        tiny_value = (10 ** (- 12))
        i_ref = (4 * (10 ** (- 10)))
        coeff = (third_octave_filter_ref - third_octave_filter[i_bands, :, :])
        sig_filt = (filter_gain[i_bands] * signal.sosfilt(coeff, sig))
        center_freq = ((10 ** ((i_bands - 16) / 10)) * 1000)
        sig_filt = _square_and_smooth(sig_filt, center_freq, 48000)
        third_octave_level[i_bands, :] = (10 * np.log10(((sig_filt[::dec_factor] + tiny_value) / i_ref)))
    return (third_octave_level, time_axis, freq)