def ceilpow2(n):
    """
    # from pyCBC this one works... mine didnt work.
    convenience function to determine a power-of-2 upper frequency limit"""
    from math import frexp
    signif, exponent = frexp(n)
    if signif < 0:
        return 1
    if signif == 0.5:
        exponent -= 1
    return 1 << exponent
