def avg_angle(theta):
    """A function that finds the avage of an array of angles that are
    in the range [-180, 180].

    Parameters
    ----------
    theta : array
        An array of angles that are in the range [-180, 180] degrees

    Returns
    -------
    average : float
        The average angle
    """
    if theta.max() - theta.min() > 180:
        theta[theta < 0] += 360
    return theta.mean()
