High-level object providing a flexible interface for celestial coordinate representation, manipulation, and transformation between systems.
The SkyCoord class accepts a wide variety of inputs for initialization. At a minimum these must provide one or more celestial coordinate values with unambiguous units. Inputs may be scalars or lists/tuples/arrays, yielding scalar or array coordinates (can be checked via SkyCoord.isscalar). Typically one also specifies the coordinate frame, though this is not required. The general pattern for spherical representations is:
SkyCoord(COORD, [FRAME], keyword_args ...)SkyCoord(LON, LAT, [FRAME], keyword_args ...)SkyCoord(LON, LAT, [DISTANCE], frame=FRAME, unit=UNIT, keyword_args ...)SkyCoord([FRAME], <lon_attr>=LON, <lat_attr>=LAT, keyword_args ...)
It is also possible to input coordinate values in other representations such as cartesian or cylindrical. In this case one includes the keyword argument representation_type='cartesian' (for example) along with data in x, y, and z.
Type of coordinate frame this SkyCoord should represent. Defaults to to ICRS if not given or given as None.
unit: Unit, str, or tuple of Unit or str, optional
Units for supplied coordinate values. If only one unit is supplied then it applies to all values. Note that passing only one unit might lead to unit conversion errors if the coordinate values are expected to have mixed physical meanings (e.g., angles and distances).
obstime: astropy:time-like, optional
Time(s) of observation.
equinox: astropy:time-like, optional
Coordinate frame equinox time.
representation_type: str or BaseRepresentation class
Specifies the representation, e.g. ‘spherical’, ‘cartesian’, or ‘cylindrical’. This affects the positional args and other keyword args which must correspond to the given representation.
copy: bool, optional
If True (default), a copy of any coordinate data is made. This argument can only be passed in as a keyword argument.
﹡﹡keyword_args
Other keyword arguments as applicable for user-defined coordinate frames. Common options include:
ra, dec: angle-like, optional
RA and Dec for frames where ra and dec are keys in the frame’s representation_component_names, including ICRS, FK5, FK4, and FK4NoETerms.
Proper motion components in the Galactic frame, in angle per time units.
x, y, z: float or Quantity [‘length’], optional
Cartesian coordinates values
u, v, w: float or Quantity [‘length’], optional
Cartesian coordinates values for the Galactic frame.
radial_velocity: Quantity [‘speed’], optional
The component of the velocity along the line-of-sight (i.e., the radial direction), in velocity units.
Examples:
The examples below illustrate common ways of initializing a SkyCoord object. For a complete description of the allowed syntax see the full coordinates documentation. First some imports:
>>> from astropy.coordinates import SkyCoord # High-level coordinates>>> from astropy.coordinates import ICRS, Galactic, FK4, FK5 # Low-level frames>>> from astropy.coordinates import Angle, Latitude, Longitude # Angles>>> import astropy.units as u
The coordinate values and frame specification can now be provided using positional and keyword arguments:
>>> c = SkyCoord(10, 20, unit="deg") # defaults to ICRS frame>>> c = SkyCoord([1, 2, 3], [-30, 45, 8], frame="icrs", unit="deg") # 3 coords>>> coords = ["1:12:43.2 +31:12:43", "1 12 43.2 +31 12 43"]>>> c = SkyCoord(coords, frame=FK4, unit=(u.hourangle, u.deg), obstime="J1992.21")>>> c = SkyCoord("1h12m43.2s +1d12m43s", frame=Galactic) # Units from string>>> c = SkyCoord(frame="galactic", l="1h12m43.2s", b="+1d12m43s")>>> ra = Longitude([1, 2, 3], unit=u.deg) # Could also use Angle>>> dec = np.array([4.5, 5.2, 6.3]) ﹡ u.deg # Astropy Quantity>>> c = SkyCoord(ra, dec, frame='icrs')>>> c = SkyCoord(frame=ICRS, ra=ra, dec=dec, obstime='2001-01-02T12:34:56')>>> c = FK4(1 ﹡ u.deg, 2 ﹡ u.deg) # Uses defaults for obstime, equinox>>> c = SkyCoord(c, obstime='J2010.11', equinox='B1965') # Override defaults>>> c = SkyCoord(w=0, u=1, v=2, unit='kpc', frame='galactic',... representation_type='cartesian')>>> c = SkyCoord([ICRS(ra=1﹡u.deg, dec=2﹡u.deg), ICRS(ra=3﹡u.deg, dec=4﹡u.deg)])
Velocity components (proper motions or radial velocities) can also be provided in a similar manner:
>>> c = SkyCoord(ra=1﹡u.deg, dec=2﹡u.deg, radial_velocity=10﹡u.km/u.s)>>> c = SkyCoord(ra=1﹡u.deg, dec=2﹡u.deg, pm_ra_cosdec=2﹡u.mas/u.yr, pm_dec=1﹡u.mas/u.yr)
As shown, the frame can be a BaseCoordinateFrame class or the corresponding string alias – lower-case versions of the class name that allow for creating a SkyCoord object and transforming frames without explicitly importing the frame classes.