# RCAIDE/Methods/Noise/Metrics/PNL_noise_metric.py
#
#
# Created: Jul 2023, M. Clarke
# ----------------------------------------------------------------------------------------------------------------------
# IMPORT
# ----------------------------------------------------------------------------------------------------------------------
# Python package imports
import numpy as np
# ----------------------------------------------------------------------------------------------------------------------
# PNL_noise_metric
# ----------------------------------------------------------------------------------------------------------------------
[docs]
def PNL_noise_metric(SPL_1_3_spectrum):
"""This method calculates de Perceived Noise Level PNL from a 1/3 octave band noise spectra
Assumptions:
None
Source:
None
Inputs:
SPL_1_3_spectrum - Sound Pressure Level in 1/3 octave band [dB]
Outputs:
PNL - Perceived Noise Level [dB]
Properties Used:
N/A
"""
#Definition of the noisinees matrix for each octave band
noy = [[1, 50, 91, 64, 52, 49, 55, 0.043478, 0.030103, 0.07952, 0.058098],
[2, 63, 85.9, 60, 51, 44, 51, 0.04057, 0.030103, 0.06816, 0.058098],
[3, 80, 87.3, 56, 49, 39, 46, 0.036831, 0.030103, 0.06816, 0.052288],
[4, 100, 79.9, 53, 47, 34, 42, 0.036831, 0.030103, 0.05964, 0.047534],
[5, 125, 79.8, 51, 46, 30, 39, 0.035336, 0.030103, 0.053013, 0.043573],
[6, 160, 76, 48, 45, 27, 36, 0.033333, 0.030103, 0.053013, 0.043573],
[7, 200, 74, 46, 43, 24, 33, 0.033333, 0.030103, 0.053013, 0.040221],
[8, 250, 74.9, 44, 42, 21, 30, 0.032051, 0.030103, 0.053013, 0.037349],
[9, 315, 94.6, 42, 41, 18, 27, 0.030675, 0.030103, 0.053013, 0.034859],
[10, 400, 9999999, 40, 40, 16, 25, 0.030103, 0, 0.053013, 0.034859],
[11, 500, 9999999, 40, 40, 16, 25, 0.030103, 0, 0.053013, 0.034859],
[12, 630, 9999999, 40, 40, 16, 25, 0.030103, 0, 0.053013, 0.034859],
[13, 800 , 9999999, 40, 40, 16, 25, 0.030103, 0, 0.053013, 0.034859],
[14, 1000, 9999999, 40, 40, 16, 25, 0.030103, 0, 0.053013, 0.034859],
[15, 1250, 9999999, 38, 38, 15, 23, 0.030103, 0, 0.05964, 0.034859],
[16, 1600, 9999999, 34, 34, 12, 21, 0.02996, 0, 0.053013, 0.040221],
[17, 2000, 9999999, 32, 32, 9, 18, 0.02996, 0, 0.053013, 0.037349],
[18, 2500, 9999999, 30, 30, 5, 15, 0.02996, 0, 0.047712, 0.034859],
[19, 3150, 9999999, 29, 29, 4, 14, 0.02996, 0, 0.047712, 0.034859],
[20, 4000, 9999999, 29, 29, 5, 14, 0.02996, 0, 0.053013, 0.034859],
[21, 5000, 9999999, 30, 30, 6, 15, 0.02996, 0, 0.053013, 0.034859],
[22, 6300, 9999999, 31, 31, 10, 17, 0.02996, 0, 0.06816, 0.037349],
[23, 8000, 44.3, 37, 34, 17, 23, 0.042285, 0.02996, 0.07952, 0.037349],
[24, 10000, 50.7, 41, 37, 21, 29, 0.042285, 0.02996, 0.05964, 0.043573]]
# Defining the necessary arrays for the calculation
n_cpts = len(SPL_1_3_spectrum[:,0,0,0])
n_mic_x = len(SPL_1_3_spectrum[0,:,0,0])
n_mic_y = len(SPL_1_3_spectrum[0,:,:,0])
n_f = len(SPL_1_3_spectrum[0,0,0,:])
SPL_noy = np.zeros((n_cpts,n_mic_x,n_mic_y,n_f))
PNL = np.zeros((n_cpts,n_mic_x,n_mic_y ))
#-------------------------------------------
# STEP 1 - Convert SPL to Perceived Noisiness
#-------------------------------------------
for n_x in range(n_mic_x):
for n_y in range(n_mic_x):
for j in range(n_cpts):
for i in range(5,29):
if SPL_1_3_spectrum[j][n_x][n_y][i]>=noy[1][2]:
SPL_noy[j][n_x][n_y][i] = 10**(noy[i-5][8]*(SPL_1_3_spectrum[j][n_x][n_y][i]-noy[i-5][4]))
if SPL_1_3_spectrum[j][n_x][n_y][i]>=noy[i-5][3] and SPL_1_3_spectrum[j][n_x][n_y][i]<noy[i-5][2]:
SPL_noy[j][n_x][n_y][i] = 10**(noy[i-5][7]*(SPL_1_3_spectrum[j][n_x][n_y][i]-noy[i-5][3]))
if SPL_1_3_spectrum[j][n_x][n_y][i]>=noy[i-5][6] and SPL_1_3_spectrum[j][n_x][n_y][i]<noy[i-5][3]:
SPL_noy[j][n_x][n_y][i] = 0.3*(10**(noy[i-5][10]*(SPL_1_3_spectrum[j][n_x][n_y][i]-noy[i-5][6])))
if SPL_1_3_spectrum[j][n_x][n_y][i]>=noy[i-5][5] and SPL_1_3_spectrum[j][n_x][n_y][i]<noy[i-5][6]:
SPL_noy[j][n_x][n_y][i] = 0.1*(10**(noy[i-5][9]*(SPL_1_3_spectrum[j][n_x][n_y][i]-noy[i-5][5])))
#-------------------------------------------
# STEP 2 - Combine perceived noiseness values
#-------------------------------------------
max_noy = np.max(SPL_noy[j][n_x][n_y][:])
Perceived_noisinees = 0.85*max_noy+0.15*np.sum(SPL_noy[j][n_x][n_y][:])
#-----------------------------------------------------------------
# STEP 3 - Convert Perceived Noiseness into Perceived Noise Level
#------------------------------------------------------------------
if Perceived_noisinees==0:
Perceived_noisinees = 0.0625
PNL[j,n_x, n_y] = 40+(10/np.log10(2))*np.log10(Perceived_noisinees)
return PNL