maad.util.amplitude2dB

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

Transform amplitude data (signal, scalar) into decibel scale within the dB range (db_range). A gain (db_gain) could be added at the end.

Parameters:
xarray-like or scalar

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 = 20*log10(x) + db_gain

Examples

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