Angle between two R-dimensional vectors.

    Angle calculated as:

    .. math::

        \\arccos\\left[
        \\frac{\\mathsf{vec1}\cdot\\mathsf{vec2}}
        {\\left\\|\\mathsf{vec1}\\right\\|
            \\left\\|\\mathsf{vec2}\\right\\|}
        \\right]

    Parameters
    ----------
    vec1
        length-R |npfloat_| --
        First vector

    vec2
        length-R |npfloat_| --
        Second vector

    Returns
    -------
    angle
        |npfloat_| --
        Angle between the two vectors in degrees

def vec_angle(vec1, vec2):
    """ Angle between two R-dimensional vectors.

    Angle calculated as:

    .. math::

        \\arccos\\left[
        \\frac{\\mathsf{vec1}\cdot\\mathsf{vec2}}
        {\\left\\|\\mathsf{vec1}\\right\\|
            \\left\\|\\mathsf{vec2}\\right\\|}
        \\right]

    Parameters
    ----------
    vec1
        length-R |npfloat_| --
        First vector

    vec2
        length-R |npfloat_| --
        Second vector

    Returns
    -------
    angle
        |npfloat_| --
        Angle between the two vectors in degrees

    """

    # Imports
    import numpy as np
    from scipy import linalg as spla
    from ..const import PRM

    # Check shape and equal length
    if len(vec1.shape) != 1:
        raise ValueError("'vec1' is not a vector")
    ## end if
    if len(vec2.shape) != 1:
        raise ValueError("'vec2' is not a vector")
    ## end if
    if vec1.shape[0] != vec2.shape[0]:
        raise ValueError("Vector lengths are not equal")
    ## end if

    # Check magnitudes
    if spla.norm(vec1) < PRM.ZERO_VEC_TOL:
        raise ValueError("'vec1' norm is too small")
    ## end if
    if spla.norm(vec2) < PRM.ZERO_VEC_TOL:
        raise ValueError("'vec2' norm is too small")
    ## end if

    # Calculate the angle and return. Do in multiple steps to test for
    #  possible >1 or <-1 values from numerical precision errors.
    dotp = np.dot(vec1, vec2) / spla.norm(vec1) / spla.norm(vec2)

    if dotp > 1:
        angle = 0. # pragma: no cover
    elif dotp < -1:
        angle = 180. # pragma: no cover
    else:
        angle = np.degrees(np.arccos(dotp))
    ## end if

    return angle