code: def cart2spol(X):
      
      x,y,z,vx,vy,vz=X
      r=np.sqrt(x*x+y*y+z*z)
      p=np.arctan2(y,x)
      t=np.arccos(z/r)
      vr=(vx*np.cos(p)+vy*np.sin(p))*np.sin(t)+np.cos(t)*vz
      vp=-vx*np.sin(p)+vy*np.cos(p)
      vt=(vx*np.cos(p)+vy*np.sin(p))*np.cos(t)-np.sin(t)*vz
      return np.array([r,p,t,vr,vp,vt])
docs: Performs coordinate transformation from cartesian
      to spherical polar coordinates with (r,phi,theta) having
      usual meanings.