pow2round

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

Returns the value rounded to the closest 2^N integer.

Parameters:
xint or float or numpy.ndarray

The input value(s).

Returns:
resultint or numpy.ndarray (int)

Examples

>>> print(pow2round(1023))
1024
>>> halfway = int(2 ** 9.5)
>>> print(pow2round(halfway))
512
>>> print(pow2round(halfway + 1))
1024