(vectors, lonlat=False)
vec2ang: vectors [x, y, z] -> theta[rad], phi[rad]

    Parameters
    ----------
    vectors : float, array-like
      the vector(s) to convert, shape is (3,) or (N, 3)
    lonlat : bool, optional
      If True, return angles will be longitude and latitude in degree,
      otherwise, angles will be co-latitude and longitude in radians (default)

    Returns
    -------
    theta, phi : float, tuple of two arrays
      the colatitude and longitude in radians

    See Also
    --------
    ang2vec, rotator.vec2dir, rotator.dir2vec
vec2ang: vectors [x, y, z] -> theta[rad], phi[rad]
vec2ang : vectors [ x y z ] - > theta [ rad ] phi [ rad ]
def vec2ang(vectors, lonlat=False):
    """vec2ang: vectors [x, y, z] -> theta[rad], phi[rad]

    Parameters
    ----------
    vectors : float, array-like
      the vector(s) to convert, shape is (3,) or (N, 3)
    lonlat : bool, optional
      If True, return angles will be longitude and latitude in degree,
      otherwise, angles will be co-latitude and longitude in radians (default)

    Returns
    -------
    theta, phi : float, tuple of two arrays
      the colatitude and longitude in radians

    See Also
    --------
    ang2vec, rotator.vec2dir, rotator.dir2vec
    """
    vectors = vectors.reshape(-1, 3)
    dnorm = np.sqrt(np.sum(np.square(vectors), axis=1))
    theta = np.arccos(vectors[:, 2] / dnorm)
    phi = np.arctan2(vectors[:, 1], vectors[:, 0])
    phi[phi < 0] += 2 * np.pi
    if lonlat:
        return thetaphi2lonlat(theta, phi)
    else:
        return theta, phi
def vec2ang ( vectors , lonlat = False ) : vectors = vectors . reshape ( - 1 , 3 ) dnorm = np . sqrt ( np . sum ( np . square ( vectors ) , axis = 1 ) ) theta = np . arccos ( vectors [ : , 2 ] / dnorm ) phi = np . arctan2 ( vectors [ : , 1 ] , vectors [ : , 0 ] ) phi [ phi < 0 ] += 2 * np . pi if lonlat : return thetaphi2lonlat ( theta , phi ) else : return theta , phi