def inangle(theta, angle, atol):
    """
    Input:  (theta) angle inquestion
            (angle) reference angle
            (atol)  tolerance about (angle)
    Output:         True or False, depending on whether
                    theta is in [angle-atol,angle+atol)
    """
    lower = angle - atol
    upper = angle + atol
    if (lower >= 0) & (upper <= 360):
        if (theta >= lower) & (theta < upper):
            return True
    if lower < 0:
        lower %= 360
        if (theta > upper) & (theta >= lower):
            return True
        elif (theta >= 0) & (theta < upper):
            return True
    if upper > 360:
        upper %= 360
        if (theta >= lower) & (theta < 0):
            return True
        if (theta >= 0) & (theta < upper):
            return True
    return False
