maad.util.mean_dB

maad.util.mean_dB(*argv, axis=0)[source]

Compute the average of decibel values.

Parameters:
*argvndarray-like of floats

Arrays containing the sound waveform in dB

axisinteger, optional, default is 0

if average of multiple arrays, select the axis on which the average is done

Returns:
e_meanndarray-like of floats

Array containing the mean of the dB values

Examples

Example with an audio file

>>> w, fs = maad.sound.load('../data/cold_forest_daylight.wav') 
>>> Sxx_power,tn,fn,_ = maad.sound.spectrogram(w,fs)
>>> L = maad.util.power2dBSPL(Sxx_power,gain=42)
>>> L_mean = maad.util.mean_dB(L, axis=1)  
>>> fig_kwargs = {'figtitle':'Power spectrum (PSD)',
                  'xlabel':'Frequency [Hz]',
                  'ylabel':'Power [dB]',
                  }
>>> fig, ax = maad.util.plot1d(fn, L_mean.transpose(), **fig_kwargs)

Example with single values

>>> L1 = 90 # 90dB
>>> L2 = 96 # 96dB
>>> maad.util.mean_dB(L1,L2)
    93.96292

Example with arrays

>>> L1 = [90,80,70]
>>> maad.util.mean_dB(L1,L1, axis=1)
    array([85.68201724, 85.68201724])
>>> maad.util.mean_dB(L1,L1, axis=0)  
    array([90., 80., 70.])