import math


def compass(azimuth, radians=False):
    """
    Get named direction from azimuth.
    """
    if radians:
        azimuth *= 180.0 / math.pi
    names = (
        'N', 'NNE', 'NE', 'ENE',
        'E', 'ESE', 'SE', 'SSE',
        'S', 'SSW', 'SW', 'WSW',
        'W', 'WNW', 'NW', 'NNW',
    )
    return names[int((azimuth / 22.5 + 0.5) % 16.0)]