maad.util.power2dB

maad.util.power2dB(x, db_range=None, db_gain=0)[source]

Transform power (amplitude²) signal or scalar into decibel scale within the dB range (db_range). A gain (db_gain) can be added at the end.

Parameters:
xarray-like

data to rescale in dB

db_rangescalar, optional, defaultNone

if db_range is a number, anything lower than -db_range is set to -db_range and anything larger than 0 is set to 0

db_gainscalar, optional, default is 0

Gain added to the results amplitude –> 20*log10(x) + db_gain

Returns:
yarray-like or scalar

y = 10*log10(x) + db_gain

Examples

>>> a = np.array([1,2,3,4,5])
>>> maad.util.power2dB(a**2)
    array([ 0.        ,  6.02059991,  9.54242509, 12.04119983, 13.97940009])