code: def lbd_to_XYZ(l,b,d,degree=False):
      
      #Whether to use degrees and scalar input is handled by decorators
      return nu.array([d*nu.cos(b)*nu.cos(l),
                       d*nu.cos(b)*nu.sin(l),
                       d*nu.sin(b)]).T
docs: NAME:
  
         lbd_to_XYZ
  
      PURPOSE:
  
         transform from spherical Galactic coordinates to rectangular Galactic coordinates (works with vector inputs)
  
      INPUT:
  
         l - Galactic longitude (rad)
  
         b - Galactic lattitude (rad)
  
         d - distance (arbitrary units)
  
         degree - (bool) if True, l and b are in degrees
  
      OUTPUT:
  
         [X,Y,Z] in whatever units d was in
  
         For vector inputs [:,3]
  
      HISTORY:
  
         2009-10-24- Written - Bovy (NYU)
  
         2014-06-14 - Re-written w/ numpy functions for speed and w/ decorators for beauty - Bovy (IAS)