log2round

sofia_redux.scan.utilities.utils.log2round(x)[source]

Returns the rounded value of log_2(x).

Parameters:
xint or float or numpy.ndarray

The input value(s).

Returns:
log2int or numpy.ndarray (int)

Examples

>>> print(log2round(1024))
10
>>> halfway = int(2 ** 9.5)
>>> print(log2round(halfway))
9
>>> print(log2round(halfway + 1))
10