code: def rect_to_cyl(X,Y,Z):
      
      R= sc.sqrt(X**2.+Y**2.)
      phi= sc.arctan2(Y,X)
      if isinstance(phi,nu.ndarray): phi[phi<0.]+= 2.*nu.pi
      elif phi < 0.: phi+= 2.*nu.pi
      return (R,phi,Z)
docs: NAME:
  
         rect_to_cyl
  
      PURPOSE:
  
         convert from rectangular to cylindrical coordinates
  
      INPUT:
  
         X, Y, Z - rectangular coordinates
  
      OUTPUT:
  
         R,phi,z
  
      HISTORY:
  
         2010-09-24 - Written - Bovy (NYU)