code: def vector_to_spherical(cartesian):
      
      cartesian = np.asanyarray(cartesian, dtype=np.float64)
      if not is_shape(cartesian, (-1, 3)):
          raise ValueError('Cartesian points must be (n,3)!')
  
      unit, valid = unitize(cartesian, check_valid=True)
      unit[np.abs(unit) < TOL_MERGE] = 0.0
  
      x, y, z = unit.T
      spherical = np.zeros((len(cartesian), 2), dtype=np.float64)
      spherical[valid] = np.column_stack((np.arctan2(y, x),
                                          np.arccos(z)))
      return spherical
docs: Convert a set of cartesian points to (n,2) spherical unit
      vectors.
  
      Parameters
      ------------
      cartesian : (n, 3) float
         Points in space
  
      Returns
      ------------
      spherical : (n, 2) float
         Angles, in radians