@exporter.export
@preprocess_xarray
def angle_to_direction(input_angle, full=False, level=3):
    'Convert the meteorological angle to directional text.\n\n    Works for angles greater than or equal to 360 (360 -> N | 405 -> NE)\n    and rounds to the nearest angle (355 -> N | 404 -> NNE)\n\n    Parameters\n    ----------\n    input_angle : numeric or array-like numeric\n        Angles such as 0, 25, 45, 360, 410, etc\n    full : boolean\n        True returns full text (South), False returns abbrieviated text (S)\n    level : int\n        Level of detail (3 = N/NNE/NE/ENE/E... 2 = N/NE/E/SE... 1 = N/E/S/W)\n\n    Returns\n    -------\n    direction\n        The directional text\n\n    '
    try:
        origin_units = input_angle.units
        input_angle = input_angle.m
    except AttributeError:
        origin_units = units.degree
    if ((not hasattr(input_angle, '__len__')) or isinstance(input_angle, str)):
        input_angle = [input_angle]
        scalar = True
    else:
        scalar = False
    input_angle = np.array(input_angle).astype(float)
    with np.errstate(invalid='ignore'):
        input_angle[np.where((input_angle < 0))] = np.nan
    input_angle = (input_angle * origin_units)
    normalizer = np.array((input_angle.m / MAX_DEGREE_ANGLE.m), dtype=int)
    norm_angles = abs((input_angle - (MAX_DEGREE_ANGLE * normalizer)))
    if (level == 3):
        nskip = 1
    elif (level == 2):
        nskip = 2
    elif (level == 1):
        nskip = 4
    else:
        err_msg = 'Level of complexity cannot be less than 1 or greater than 3!'
        raise ValueError(err_msg)
    angle_dict = {((i * BASE_DEGREE_MULTIPLIER.m) * nskip): dir_str for (i, dir_str) in enumerate(DIR_STRS[::nskip])}
    angle_dict[MAX_DEGREE_ANGLE.m] = 'N'
    angle_dict[UND_ANGLE] = UND
    multiplier = np.round((((norm_angles / BASE_DEGREE_MULTIPLIER) / nskip) - 0.001)).m
    round_angles = ((multiplier * BASE_DEGREE_MULTIPLIER.m) * nskip)
    round_angles[np.where(np.isnan(round_angles))] = UND_ANGLE
    dir_str_arr = itemgetter(*round_angles)(angle_dict)
    if full:
        dir_str_arr = ','.join(dir_str_arr)
        dir_str_arr = _unabbrieviate_direction(dir_str_arr)
        if (not scalar):
            dir_str = dir_str_arr.split(',')
        else:
            dir_str = dir_str_arr.replace(',', ' ')
    else:
        dir_str = dir_str_arr
    return dir_str
Convert the meteorological angle to directional text.

Works for angles greater than or equal to 360 (360 -> N | 405 -> NE)
and rounds to the nearest angle (355 -> N | 404 -> NNE)

Parameters
----------
input_angle : numeric or array-like numeric
    Angles such as 0, 25, 45, 360, 410, etc
full : boolean
    True returns full text (South), False returns abbrieviated text (S)
level : int
    Level of detail (3 = N/NNE/NE/ENE/E... 2 = N/NE/E/SE... 1 = N/E/S/W)

Returns
-------
direction
    The directional text
@exporter.export
@preprocess_xarray
def angle_to_direction(input_angle, full=False, level=3):
    'Convert the meteorological angle to directional text.\n\n    Works for angles greater than or equal to 360 (360 -> N | 405 -> NE)\n    and rounds to the nearest angle (355 -> N | 404 -> NNE)\n\n    Parameters\n    ----------\n    input_angle : numeric or array-like numeric\n        Angles such as 0, 25, 45, 360, 410, etc\n    full : boolean\n        True returns full text (South), False returns abbrieviated text (S)\n    level : int\n        Level of detail (3 = N/NNE/NE/ENE/E... 2 = N/NE/E/SE... 1 = N/E/S/W)\n\n    Returns\n    -------\n    direction\n        The directional text\n\n    '
    try:
        origin_units = input_angle.units
        input_angle = input_angle.m
    except AttributeError:
        origin_units = units.degree
    if ((not hasattr(input_angle, '__len__')) or isinstance(input_angle, str)):
        input_angle = [input_angle]
        scalar = True
    else:
        scalar = False
    input_angle = np.array(input_angle).astype(float)
    with np.errstate(invalid='ignore'):
        input_angle[np.where((input_angle < 0))] = np.nan
    input_angle = (input_angle * origin_units)
    normalizer = np.array((input_angle.m / MAX_DEGREE_ANGLE.m), dtype=int)
    norm_angles = abs((input_angle - (MAX_DEGREE_ANGLE * normalizer)))
    if (level == 3):
        nskip = 1
    elif (level == 2):
        nskip = 2
    elif (level == 1):
        nskip = 4
    else:
        err_msg = 'Level of complexity cannot be less than 1 or greater than 3!'
        raise ValueError(err_msg)
    angle_dict = {((i * BASE_DEGREE_MULTIPLIER.m) * nskip): dir_str for (i, dir_str) in enumerate(DIR_STRS[::nskip])}
    angle_dict[MAX_DEGREE_ANGLE.m] = 'N'
    angle_dict[UND_ANGLE] = UND
    multiplier = np.round((((norm_angles / BASE_DEGREE_MULTIPLIER) / nskip) - 0.001)).m
    round_angles = ((multiplier * BASE_DEGREE_MULTIPLIER.m) * nskip)
    round_angles[np.where(np.isnan(round_angles))] = UND_ANGLE
    dir_str_arr = itemgetter(*round_angles)(angle_dict)
    if full:
        dir_str_arr = ','.join(dir_str_arr)
        dir_str_arr = _unabbrieviate_direction(dir_str_arr)
        if (not scalar):
            dir_str = dir_str_arr.split(',')
        else:
            dir_str = dir_str_arr.replace(',', ' ')
    else:
        dir_str = dir_str_arr
    return dir_str