code: def galcenrect_to_XYZ_jac(*args,**kwargs):
      
      Xsun= kwargs.get('Xsun',1.)
      dgc= nu.sqrt(Xsun**2.+kwargs.get('Zsun',0.)**2.)
      costheta, sintheta= Xsun/dgc, kwargs.get('Zsun',0.)/dgc
      out= sc.zeros((6,6))
      out[0,0]= -costheta
      out[0,2]= -sintheta
      out[1,1]= 1.
      out[2,0]= -nu.sign(Xsun)*sintheta
      out[2,2]= nu.sign(Xsun)*costheta
      if len(args) == 3: return out[:3,:3]
      out[3,3]= -costheta
      out[3,5]= -sintheta
      out[4,4]= 1.
      out[5,3]= -nu.sign(Xsun)*sintheta
      out[5,5]= nu.sign(Xsun)*costheta
      return out
docs: NAME:
  
         galcenrect_to_XYZ_jac
      PURPOSE:
  
         calculate the Jacobian of the Galactocentric rectangular to Galactic coordinates
  
      INPUT:
  
         X,Y,Z- Galactocentric rectangular coordinates
  
         vX, vY, vZ- Galactocentric rectangular velocities
  
         if 6 inputs: X,Y,Z,vX,vY,vZ
  
         if 3: X,Y,Z
  
         Xsun - cylindrical distance to the GC
         
         Zsun - Sun's height above the midplane
  
      OUTPUT:
  
         jacobian d(galcen.)/d(Galactic)
  
      HISTORY:
  
         2013-12-09 - Written - Bovy (IAS)