Galactocentric

class astropy.coordinates.Galactocentric(*args, **kwargs)[source]

Bases: astropy.coordinates.BaseCoordinateFrame

A coordinate or frame in the Galactocentric system.

This frame allows specifying the Sun-Galactic center distance, the height of the Sun above the Galactic midplane, and the solar motion relative to the Galactic center. However, as there is no modern standard definition of a Galactocentric reference frame, it is important to pay attention to the default values used in this class if precision is important in your code. The default values of the parameters of this frame are taken from the original definition of the frame in 2014. As such, the defaults are somewhat out of date relative to recent measurements made possible by, e.g., Gaia. The defaults can, however, be changed at runtime by setting the parameter set name in galactocentric_frame_defaults.

The current default parameter set is "pre-v4.0", indicating that the parameters were adopted before astropy version 4.0. A regularly-updated parameter set can instead be used by setting galactocentric_frame_defaults.set ('latest'), and other parameter set names may be added in future versions. To find out the scientific papers that the current default parameters are derived from, use galcen.frame_attribute_references (where galcen is an instance of this frame), which will update even if the default parameter set is changed.

The position of the Sun is assumed to be on the x axis of the final, right-handed system. That is, the x axis points from the position of the Sun projected to the Galactic midplane to the Galactic center – roughly towards \((l,b) = (0^\circ,0^\circ)\). For the default transformation (\({\rm roll}=0^\circ\)), the y axis points roughly towards Galactic longitude \(l=90^\circ\), and the z axis points roughly towards the North Galactic Pole (\(b=90^\circ\)).

For a more detailed look at the math behind this transformation, see the document Description of the Galactocentric Coordinate Frame.

The frame attributes are listed under Other Parameters.

Parameters
dataBaseRepresentation subclass instance

A representation object or None to have no data (or use the coordinate component arguments, see below).

xQuantity, optional

Cartesian, Galactocentric \(x\) position component.

yQuantity, optional

Cartesian, Galactocentric \(y\) position component.

zQuantity, optional

Cartesian, Galactocentric \(z\) position component.

v_xQuantity, optional

Cartesian, Galactocentric \(v_x\) velocity component.

v_yQuantity, optional

Cartesian, Galactocentric \(v_y\) velocity component.

v_zQuantity, optional

Cartesian, Galactocentric \(v_z\) velocity component.

representation_typeBaseRepresentation subclass, str, optional

A representation class or string name of a representation class. This sets the expected input representation class, thereby changing the expected keyword arguments for the data passed in. For example, passing representation_type='cartesian' will make the classes expect position data with cartesian names, i.e. x, y, z in most cases unless overriden via frame_specific_representation_info. To see this frame’s names, check out <this frame>().representation_info.

differential_typeBaseDifferential subclass, str, dict, optional

A differential class or dictionary of differential classes (currently only a velocity differential with key ‘s’ is supported). This sets the expected input differential class, thereby changing the expected keyword arguments of the data passed in. For example, passing differential_type='cartesian' will make the classes expect velocity data with the argument names v_x, v_y, v_z unless overriden via frame_specific_representation_info. To see this frame’s names, check out <this frame>().representation_info.

copybool, optional

If True (default), make copies of the input coordinate arrays. Can only be passed in as a keyword argument.

Other Parameters
galcen_coordICRS, optional, must be keyword

The ICRS coordinates of the Galactic center.

galcen_distanceQuantity, optional, must be keyword

The distance from the sun to the Galactic center.

galcen_v_sunCartesianDifferential, optional, must be keyword

The velocity of the sun in the Galactocentric frame as Cartesian velocity components.

z_sunQuantity, optional, must be keyword

The distance from the sun to the Galactic midplane.

rollAngle, optional, must be keyword

The angle to rotate about the final x-axis, relative to the orientation for Galactic. For example, if this roll angle is 0, the final x-z plane will align with the Galactic coordinates x-z plane. Unless you really know what this means, you probably should not change this!

Examples

To transform to the Galactocentric frame with the default frame attributes, pass the uninstantiated class name to the transform_to() method of a coordinate frame or SkyCoord object:

>>> import astropy.units as u
>>> import astropy.coordinates as coord
>>> c = coord.ICRS(ra=[158.3122, 24.5] * u.degree,
...                dec=[-17.3, 81.52] * u.degree,
...                distance=[11.5, 24.12] * u.kpc)
>>> c.transform_to(coord.Galactocentric) 
<Galactocentric Coordinate (galcen_coord=<ICRS Coordinate: (ra, dec) in deg
    ( 266.4051, -28.936175)>, galcen_distance=8.3 kpc, galcen_v_sun=( 11.1,  232.24,  7.25) km / s, z_sun=27.0 pc, roll=0.0 deg): (x, y, z) in kpc
    [( -9.6083819 ,  -9.40062188,  6.52056066),
     (-21.28302307,  18.76334013,  7.84693855)]>

To specify a custom set of parameters, you have to include extra keyword arguments when initializing the Galactocentric frame object:

>>> c.transform_to(coord.Galactocentric(galcen_distance=8.1*u.kpc)) 
<Galactocentric Coordinate (galcen_coord=<ICRS Coordinate: (ra, dec) in deg
    ( 266.4051, -28.936175)>, galcen_distance=8.1 kpc, galcen_v_sun=( 11.1,  232.24,  7.25) km / s, z_sun=27.0 pc, roll=0.0 deg): (x, y, z) in kpc
    [( -9.40785924,  -9.40062188,  6.52066574),
     (-21.08239383,  18.76334013,  7.84798135)]>

Similarly, transforming from the Galactocentric frame to another coordinate frame:

>>> c = coord.Galactocentric(x=[-8.3, 4.5] * u.kpc,
...                          y=[0., 81.52] * u.kpc,
...                          z=[0.027, 24.12] * u.kpc)
>>> c.transform_to(coord.ICRS) 
<ICRS Coordinate: (ra, dec, distance) in (deg, deg, kpc)
    [(  86.22349059, 28.83894138,  4.39157788e-05),
     ( 289.66802652, 49.88763881,  8.59640735e+01)]>

Or, with custom specification of the Galactic center:

>>> c = coord.Galactocentric(x=[-8.0, 4.5] * u.kpc,
...                          y=[0., 81.52] * u.kpc,
...                          z=[21.0, 24120.0] * u.pc,
...                          z_sun=21 * u.pc, galcen_distance=8. * u.kpc)
>>> c.transform_to(coord.ICRS) 
<ICRS Coordinate: (ra, dec, distance) in (deg, deg, kpc)
    [(  86.2585249 ,  28.85773187,  2.75625475e-05),
     ( 289.77285255,  50.06290457,  8.59216010e+01)]>

# TODO: this needs to be audited and removed if we change the default # defaults (yes) for v4.1. This is a hack to get around the fact that # the doctests here actually change the class state:

>>> galactocentric_frame_defaults._value = 'pre-v4.0'

Attributes Summary

default_differential

default_representation

frame_attributes

frame_specific_representation_info

galcen_coord

galcen_distance

galcen_v_sun

name

roll

z_sun

Methods Summary

get_roll0()

The additional roll angle (about the final x axis) necessary to align the final z axis to match the Galactic yz-plane.

Attributes Documentation

default_differential
default_representation
frame_attributes = {'galcen_coord': <astropy.coordinates.attributes.CoordinateAttribute object>, 'galcen_distance': <astropy.coordinates.attributes.QuantityAttribute object>, 'galcen_v_sun': <astropy.coordinates.attributes.DifferentialAttribute object>, 'roll': <astropy.coordinates.attributes.QuantityAttribute object>, 'z_sun': <astropy.coordinates.attributes.QuantityAttribute object>}
frame_specific_representation_info
galcen_coord = None
galcen_distance = None
galcen_v_sun = None
name = 'galactocentric'
roll = None
z_sun = None

Methods Documentation

classmethod get_roll0()[source]

The additional roll angle (about the final x axis) necessary to align the final z axis to match the Galactic yz-plane. Setting the roll frame attribute to -this method’s return value removes this rotation, allowing the use of the Galactocentric frame in more general contexts.