Coordinates (SkyCoord)

Astropy SkyCoord helpers: name resolution, constellations, cross-matching.

  • Module name: coordinates

  • Python class: astropy.coordinates.SkyCoord

  • Functions: 7

Call any function below with the astroquery_execute MCP tool. Descriptions are taken from the upstream astroquery/astropy docstrings.

Function

Summary

from_name

Given a name, query the CDS name resolver to attempt to retrieve

from_pixel

Create a new SkyCoord from pixel coordinates using a World Coordinate System.

get_constellation

Determines the constellation(s) of the coordinates this SkyCoord contains.

get_mask

Get the mask associated with these coordinates.

guess_from_table

A convenience method to create and return a new SkyCoord from the data

search_around_3d

Searches for all coordinates in this object around a supplied set of

search_around_sky

Searches for all coordinates in this object around a supplied set of

Functions

from_name

Call via MCP

astroquery_execute(
    module_name="coordinates",
    function_name="from_name",
    params={"name": "<name>"},
)
classmethod SkyCoord.from_name(name, frame='icrs', parse=False, cache=True)

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) – The name of the object to get coordinates for, e.g. 'M42'.

  • frame (str or BaseCoordinateFrame class or instance) – The frame to transform the object to.

  • parse (bool) – Whether to attempt extracting the coordinates from the name by parsing with a regex. For objects catalog names that have J-coordinates embedded in their names, e.g., ‘CRTS SSS100805 J194428-420209’, this may be much faster than a Sesame query for the same object name. The coordinates extracted in this way may differ from the database coordinates by a few deci-arcseconds, so only use this option if you do not need sub-arcsecond accuracy for coordinates.

  • cache (bool, optional) – Determines whether to cache the results or not. To update or overwrite an existing value, pass cache='update'.

Returns:

coord – Instance of the SkyCoord class.

Return type:

SkyCoord

from_pixel

Call via MCP

astroquery_execute(
    module_name="coordinates",
    function_name="from_pixel",
    params={"xp": "<xp>", "yp": "<yp>", "wcs": "<wcs>"},
)
classmethod SkyCoord.from_pixel(xp, yp, wcs, origin=0, mode='all')

Create a new SkyCoord from pixel coordinates using a World Coordinate System.

Parameters:
  • xp (float or ndarray) – The coordinates to convert.

  • yp (float or ndarray) – The coordinates to convert.

  • wcs (WCS) – The WCS to use for convert

  • origin (int) – Whether to return 0 or 1-based pixel coordinates.

  • mode ('all' or 'wcs') – Whether to do the transformation including distortions ('all') or only including only the core WCS transformation ('wcs').

Returns:

coord – A new object with sky coordinates corresponding to the input xp and yp.

Return type:

SkyCoord

See also

to_pixel

to do the inverse operation

astropy.wcs.utils.pixel_to_skycoord

the implementation of this method

get_constellation

Call via MCP

astroquery_execute(
    module_name="coordinates",
    function_name="get_constellation",
    params={},
)
SkyCoord.get_constellation(short_name=False, constellation_list='iau')

Determines the constellation(s) of the coordinates this SkyCoord contains.

Parameters:
  • short_name (bool) – If True, the returned names are the IAU-sanctioned abbreviated names. Otherwise, full names for the constellations are used.

  • constellation_list (str) – The set of constellations to use. Currently only 'iau' is supported, meaning the 88 “modern” constellations endorsed by the IAU.

Returns:

constellation – If this is a scalar coordinate, returns the name of the constellation. If it is an array |SkyCoord|, it returns an array of names.

Return type:

str or string array

Notes

To determine which constellation a point on the sky is in, this first precesses to B1875, and then uses the Delporte boundaries of the 88 modern constellations, as tabulated by Roman 1987.

get_mask

Call via MCP

astroquery_execute(
    module_name="coordinates",
    function_name="get_mask",
    params={},
)
SkyCoord.get_mask(*attrs)

Get the mask associated with these coordinates.

Parameters:

*attrs (str) – Attributes from which to get the masks to combine. Items can be dotted, like "data.lon", "data.lat". By default, get the combined mask of all components (including from differentials), ignoring possible masks of attributes.

Returns:

mask – The combined, read-only mask. If the instance is not masked, it is an array of False with the correct shape.

Return type:

ndarray of bool

Raises:

ValueError – If the coordinate frame has no associated data.

guess_from_table

Call via MCP

astroquery_execute(
    module_name="coordinates",
    function_name="guess_from_table",
    params={"table": "<table>"},
)
classmethod SkyCoord.guess_from_table(table, **coord_kwargs)

A convenience method to create and return a new SkyCoord from the data in an astropy Table.

This method matches table columns that start with the case-insensitive names of the components of the requested frames (including differentials), if they are also followed by a non-alphanumeric character. It will also match columns that end with the component name if a non-alphanumeric character is before it.

For example, the first rule means columns with names like 'RA[J2000]' or 'ra' will be interpreted as ra attributes for ICRS frames, but 'RAJ2000' or 'radius' are not. Similarly, the second rule applied to the Galactic frame means that a column named 'gal_l' will be used as the l component, but gall or 'fill' will not.

The definition of alphanumeric here is based on Unicode’s definition of alphanumeric, except without _ (which is normally considered alphanumeric). So for ASCII, this means the non-alphanumeric characters are <space>_!"#$%&'()*+,-./\:;<=>?@[]^`{|}~).

Parameters:
  • table (Table or subclass) – The table to load data from.

  • **coord_kwargs – Any additional keyword arguments are passed directly to this class’s constructor.

Returns:

newsc – The new instance.

Return type:

SkyCoord or subclass

Raises:

ValueError – If more than one match is found in the table for a component, unless the additional matches are also valid frame component names. If a “coord_kwargs” is provided for a value also found in the table.

search_around_3d

Call via MCP

astroquery_execute(
    module_name="coordinates",
    function_name="search_around_3d",
    params={"searcharoundcoords": "<searcharoundcoords>", "distlimit": "<distlimit>"},
)
SkyCoord.search_around_3d(searcharoundcoords, distlimit)

Searches for all coordinates in this object around a supplied set of points within a given 3D radius.

This is intended for use on SkyCoord objects with coordinate arrays, rather than a scalar coordinate. For a scalar coordinate, it is better to use separation_3d().

For more on how to use this (and related) functionality, see the examples in Separations, Offsets, Catalog Matching, and Related Functionality.

Parameters:
  • searcharoundcoords (SkyCoord or BaseCoordinateFrame) – The coordinates to search around to try to find matching points in this |SkyCoord|. This must be a one-dimensional coordinate array.

  • distlimit (Quantity ['length']) – The physical radius to search within. It should be broadcastable to the same shape as searcharoundcoords.

Returns:

A NamedTuple with attributes representing the indices of the elements of found pairs in the other set of coordinates and this |SkyCoord| and angular and physical separations of the pairs.

Return type:

CoordinateSearchResult

Notes

This method requires SciPy to be installed or it will fail.

In the current implementation, the return values are always sorted in the same order as the searcharoundcoords (so idxsearcharound is in ascending order). This is considered an implementation detail, though, so it could change in a future release.

See also

astropy.coordinates.search_around_3d, SkyCoord.search_around_sky

search_around_sky

Call via MCP

astroquery_execute(
    module_name="coordinates",
    function_name="search_around_sky",
    params={"searcharoundcoords": "<searcharoundcoords>", "seplimit": "<seplimit>"},
)
SkyCoord.search_around_sky(searcharoundcoords, seplimit)

Searches for all coordinates in this object around a supplied set of points within a given on-sky separation.

This is intended for use on SkyCoord objects with coordinate arrays, rather than a scalar coordinate. For a scalar coordinate, it is better to use separation().

For more on how to use this (and related) functionality, see the examples in Separations, Offsets, Catalog Matching, and Related Functionality.

Parameters:
  • searcharoundcoords (coordinate-like) – The coordinates to search around to try to find matching points in this |SkyCoord|. This must be a one-dimensional coordinate array.

  • seplimit (Quantity ['angle']) – The on-sky separation to search within. It should be broadcastable to the same shape as searcharoundcoords.

Returns:

A NamedTuple with attributes representing the indices of the elements of found pairs in the other set of coordinates and this |SkyCoord| and angular and physical separations of the pairs. If either set of sources lack distances, the physical separation is the 3D distance on the unit sphere, rather than a true distance.

Return type:

CoordinateSearchResult

Notes

This method requires SciPy to be installed or it will fail.

In the current implementation, the return values are always sorted in the same order as the searcharoundcoords (so idxsearcharound is in ascending order). This is considered an implementation detail, though, so it could change in a future release.

See also

astropy.coordinates.search_around_sky, SkyCoord.search_around_3d