(dir1, dir2, lonlat=False)
return np.arctan2(vec_prod, scal_prod)
Returns the angular distance between dir1 and dir2.

    Parameters
    ----------
    dir1, dir2 : float, array-like
      The directions between which computing the angular distance.
      Angular if len(dir) == 2 or vector if len(dir) == 3.
      See *lonlat* for unit
    lonlat : bool, scalar or sequence
      If True, angles are assumed to be longitude and latitude in degree,
      otherwise they are interpreted as colatitude and longitude in radian.
      If a sequence, lonlat[0] applies to dir1 and lonlat[1] applies to dir2.

    Returns
    -------
    angles : float, scalar or array-like
      The angle(s) between dir1 and dir2 in radian.

    Examples
    --------
    >>> import healpy as hp
    >>> hp.rotator.angdist([.2,0], [.2, 1e-6])
    array([  1.98669331e-07])
Returns the angular distance between dir1 and dir2.
Returns the angular distance between dir1 and dir2 .
def angdist(dir1, dir2, lonlat=False):
    """Returns the angular distance between dir1 and dir2.

    Parameters
    ----------
    dir1, dir2 : float, array-like
      The directions between which computing the angular distance.
      Angular if len(dir) == 2 or vector if len(dir) == 3.
      See *lonlat* for unit
    lonlat : bool, scalar or sequence
      If True, angles are assumed to be longitude and latitude in degree,
      otherwise they are interpreted as colatitude and longitude in radian.
      If a sequence, lonlat[0] applies to dir1 and lonlat[1] applies to dir2.

    Returns
    -------
    angles : float, scalar or array-like
      The angle(s) between dir1 and dir2 in radian.

    Examples
    --------
    >>> import healpy as hp
    >>> hp.rotator.angdist([.2,0], [.2, 1e-6])
    array([  1.98669331e-07])
    """
    if hasattr(lonlat, "__len__") and len(lonlat) == 2:
        lonlat1, lonlat2 = lonlat
    else:
        lonlat1 = lonlat2 = lonlat
    dir1 = np.asarray(dir1)
    dir2 = np.asarray(dir2)
    if dir1.ndim == 2:
        if dir1.shape[0] == 2:  # theta, phi -> vec
            vec1 = dir2vec(dir1, lonlat=lonlat1)
        else:
            vec1 = np.reshape(dir1, (3, -1))
            vec1 = normalize_vec(vec1)
    elif dir1.ndim == 1:
        if dir1.shape[0] == 2:  # theta, phi -> vec
            vec1 = np.reshape(dir2vec(dir1, lonlat=lonlat1), (3, 1))
        else:
            vec1 = np.reshape(dir1, (3, 1))
            vec1 = normalize_vec(vec1)
    if dir2.ndim == 2:
        if dir2.shape[0] == 2:  # theta, phi -> vec
            vec2 = dir2vec(dir2, lonlat=lonlat2)
        else:
            vec2 = np.reshape(dir2, (3, -1))
            vec2 = normalize_vec(vec2)
    elif dir2.ndim == 1:
        if dir2.shape[0] == 2:  # theta, phi -> vec
            vec2 = np.reshape(dir2vec(dir2, lonlat=lonlat2), (3, 1))
        else:
            vec2 = np.reshape(dir2, (3, 1))
            vec2 = normalize_vec(vec2)
    # compute vec product
    vec_prod = np.sqrt((np.cross(vec1.T, vec2.T) ** 2).sum(axis=1))
    # compute scalar product
    scal_prod = (vec1 * vec2).sum(axis=0)

    return np.arctan2(vec_prod, scal_prod)
def angdist ( dir1 , dir2 , lonlat = False ) : if hasattr ( lonlat , "__len__" ) and len ( lonlat ) == 2 : lonlat1 , lonlat2 = lonlat else : lonlat1 = lonlat2 = lonlat dir1 = np . asarray ( dir1 ) dir2 = np . asarray ( dir2 ) if dir1 . ndim == 2 : if dir1 . shape [ 0 ] == 2 : # theta, phi -> vec vec1 = dir2vec ( dir1 , lonlat = lonlat1 ) else : vec1 = np . reshape ( dir1 , ( 3 , - 1 ) ) vec1 = normalize_vec ( vec1 ) elif dir1 . ndim == 1 : if dir1 . shape [ 0 ] == 2 : # theta, phi -> vec vec1 = np . reshape ( dir2vec ( dir1 , lonlat = lonlat1 ) , ( 3 , 1 ) ) else : vec1 = np . reshape ( dir1 , ( 3 , 1 ) ) vec1 = normalize_vec ( vec1 ) if dir2 . ndim == 2 : if dir2 . shape [ 0 ] == 2 : # theta, phi -> vec vec2 = dir2vec ( dir2 , lonlat = lonlat2 ) else : vec2 = np . reshape ( dir2 , ( 3 , - 1 ) ) vec2 = normalize_vec ( vec2 ) elif dir2 . ndim == 1 : if dir2 . shape [ 0 ] == 2 : # theta, phi -> vec vec2 = np . reshape ( dir2vec ( dir2 , lonlat = lonlat2 ) , ( 3 , 1 ) ) else : vec2 = np . reshape ( dir2 , ( 3 , 1 ) ) vec2 = normalize_vec ( vec2 ) # compute vec product vec_prod = np . sqrt ( ( np . cross ( vec1 . T , vec2 . T ) ** 2 ) . sum ( axis = 1 ) ) # compute scalar product scal_prod = ( vec1 * vec2 ) . sum ( axis = 0 ) return np . arctan2 ( vec_prod , scal_prod )