galpy.util.coords.XYZ_to_galcenrect

galpy.util.coords.XYZ_to_galcenrect(X, Y, Z, Xsun=1.0, Zsun=0.0, _extra_rot=True)[source]

Transform XYZ coordinates (wrt Sun) to rectangular Galactocentric coordinates.

Parameters:
  • X (float or numpy.ndarray) – X coordinate.

  • Y (float or numpy.ndarray) – Y coordinate.

  • Z (float or numpy.ndarray) – Z coordinate.

  • Xsun (float or numpy.ndarray, optional) – Cylindrical distance to the Galactic center (default is 1.0).

  • Zsun (float or numpy.ndarray, optional) – Sun’s height above the midplane (default is 0.0).

  • _extra_rot (bool, optional) – If True, perform an extra tiny rotation to align the Galactocentric coordinate frame with astropy’s definition (default is True).

Returns:

Containing:
  • Xg : X coordinate in Galactocentric frame.

  • Yg : Y coordinate in Galactocentric frame.

  • Zg : Z coordinate in Galactocentric frame.

Return type:

numpy.ndarray

Notes

  • 2010-09-24 - Written - Bovy (NYU)

  • 2016-05-12 - Edited to properly take into account the Sun’s vertical position; dropped Ysun keyword - Bovy (UofT)

  • 2018-04-18 - Tweaked to be consistent with astropy’s Galactocentric frame - Bovy (UofT)

  • 2023-07-23 - Allowed Xsun/Zsun to be arrays - Bovy (UofT)