Bases: object
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. Typically one also specifies the coordinate frame, though this is not required. The general pattern is 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='cartesian' (for example) along with data in x, y, and z.
Parameters: | frame : BaseCoordinateFrame class or string, optional
unit : Unit, string, or tuple of Unit or str, optional
obstime : valid Time initializer, optional
equinox : valid Time initializer, optional
representation : str or Representation class
**keyword_args
|
---|
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], "icrs", unit="deg") # 3 coords
>>> coords = ["1:12:43.2 +1:12:43", "1 12 43.2 +1 12 43"]
>>> c = SkyCoord(coords, FK4, unit=(u.deg, u.hourangle), obstime="J1992.21")
>>> c = SkyCoord("1h12m43.2s +1d12m43s", Galactic) # Units from string
>>> c = SkyCoord("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(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='cartesian')
As shown, the frame can be a BaseCoordinateFrame class or the corresponding string alias. The frame classes that are built in to astropy are ICRS, FK5, FK4, FK4NoETerms, and Galactic. The string aliases are simply lower-case versions of the class name, and allow for creating a SkyCoord object and transforming frames without explicitly importing the frame classes.
Attributes Summary
frame | |
representation |
Methods Summary
from_name(name[, frame]) | Given a name, query the CDS name resolver to attempt to retrieve coordinate information for that object. |
match_to_catalog_3d(catalogcoord[, nthneighbor]) | Finds the nearest 3-dimensional matches of this coordinate to a set of catalog coordinates. |
match_to_catalog_sky(catalogcoord[, nthneighbor]) | Finds the nearest on-sky matches of this coordinate in a set of catalog coordinates. |
position_angle(other) | Computes the on-sky position angle (East of North) between this SkyCoord and another. |
separation(other) | Computes on-sky separation between this coordinate and another. |
separation_3d(other) | Computes three dimensional separation between this coordinate and another. |
to_string([style]) | A string representation of the coordinates. |
transform_to(frame) | Transform this coordinate to a new frame. |
Attributes Documentation
Methods Documentation
Given a name, query the CDS name resolver to attempt to retrieve coordinate information for that object. The search database, sesame url, and query timeout can be set through configuration items in astropy.coordinates.name_resolve – see docstring for get_icrs_coordinates for more information.
Parameters: | name : str
frame : str or BaseCoordinateFrame class or instance
|
---|---|
Returns: | coord : SkyCoord
|
Finds the nearest 3-dimensional matches of this coordinate to a set of catalog coordinates.
This finds the 3-dimensional closest neighbor, which is only different from the on-sky distance if distance is set in this object or the catalogcoord object.
Parameters: | catalogcoord : SkyCoord or BaseCoordinateFrame
nthneighbor : int, optional
|
---|---|
Returns: | idx : integer array
sep2d : Angle
dist3d : Quantity
|
Notes
This method requires SciPy to be installed or it will fail.
Finds the nearest on-sky matches of this coordinate in a set of catalog coordinates.
Parameters: | catalogcoord : SkyCoord or BaseCoordinateFrame
nthneighbor : int, optional
|
---|---|
Returns: | idx : integer array
sep2d : Angle
dist3d : Quantity
|
Notes
This method requires SciPy to be installed or it will fail.
Computes the on-sky position angle (East of North) between this SkyCoord and another.
Parameters: | other : SkyCoord
|
---|---|
Returns: | pa : Angle
|
Examples
>>> c1 = SkyCoord(0*u.deg, 0*u.deg)
>>> c2 = SkyCoord(1*u.deg, 0*u.deg)
>>> c1.position_angle(c2).degree
90.0
>>> c3 = SkyCoord(1*u.deg, 1*u.deg)
>>> c1.position_angle(c3).degree
44.995636455344844
Computes on-sky separation between this coordinate and another.
Parameters: | other : SkyCoord or BaseCoordinateFrame
|
---|---|
Returns: | sep : Angle
|
Notes
The separation is calculated using the Vincenty formula, which is stable at all locations, including poles and antipodes [R4].
[R4] | http://en.wikipedia.org/wiki/Great-circle_distance |
Computes three dimensional separation between this coordinate and another.
Parameters: | other : SkyCoord or BaseCoordinateFrame
|
---|---|
Returns: | sep : Distance
|
Raises: | ValueError
|
A string representation of the coordinates.
The default styles definitions are:
'decimal': 'lat': {'decimal': True, 'unit': "deg"}
'lon': {'decimal': True, 'unit': "deg"}
'dms': 'lat': {'unit': "deg"}
'lon': {'unit': "deg"}
'hmsdms': 'lat': {'alwayssign': True, 'pad': True, 'unit': "deg"}
'lon': {'pad': True, 'unit': "hour"}
See to_string() for details and keyword arguments (the two angles forming the coordinates are are both Angle instances). Keyword arguments have precedence over the style defaults and are passed to to_string().
Parameters: | style : {‘hmsdms’, ‘dms’, ‘decimal’}
kwargs
|
---|
Transform this coordinate to a new frame.
Parameters: | frame : str or BaseCoordinateFrame class / instance or SkyCoord instance
|
---|---|
Returns: | coord : SkyCoord
|
Raises: | ValueError
|