<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def angle_to_name(angle, segments=8, abbr=False):
 """Convert angle in to direction name. Args: angle (float):
 Angle in degrees to convert to direction name segments (int):
 Number of segments to split compass in to abbr (bool):
 Whether to return abbreviated direction string Returns: str: Direction name for ``angle`` """

    if segments == 4:
        string = COMPASS_NAMES[int((angle + 45) / 90) % 4 * 2]
    elif segments == 8:
        string = COMPASS_NAMES[int((angle + 22.5) / 45) % 8 * 2]
    elif segments == 16:
        string = COMPASS_NAMES[int((angle + 11.25) / 22.5) % 16]
    else:
        raise ValueError('Segments parameter must be 4, 8 or 16 not %r'
                         % segments)
    if abbr:
        return ''.join(i[0].capitalize() for i in string.split('-'))
    else:
        return string