PixCoord¶
- class regions.PixCoord(x, y)[source]¶
Bases:
object
A class for pixel coordinates.
This class can represent a scalar or an array of pixel coordinates.
PixCoord
objects can be added or subtracted to each other. They can also be compared for equality.The data members are either numbers or
ndarray
(notQuantity
objects with unit “pixel”).Given a
astropy.wcs.WCS
object, it can be transformed to and from aSkyCoord
object.- Parameters:
- xfloat or array-like
Pixel coordinate x value.
- yfloat or array-like
Pixel coordinate y value.
Examples
Usage examples are provided in the Coordinates section of the documentation.
Attributes Summary
Whether the instance is scalar (e.g., a single (x, y) coordinate).
A 2-tuple
(x, y)
for this coordinate.Methods Summary
copy
()from_sky
(skycoord, wcs[, origin, mode])rotate
(center, angle)Rotate the pixel coordinate.
separation
(other)Calculate the separation to another pixel coordinate.
to_sky
(wcs[, origin, mode])Convert to a
SkyCoord
.Attributes Documentation
- isscalar¶
Whether the instance is scalar (e.g., a single (x, y) coordinate).
- xy¶
A 2-tuple
(x, y)
for this coordinate.
Methods Documentation
- classmethod from_sky(skycoord, wcs, origin=0, mode='all')[source]¶
Create
PixCoord
from aSkyCoord
.- Parameters:
- skycoord
SkyCoord
The sky coordinate.
- wcs
WCS
The WCS to use to convert pixels to world coordinates.
- originint, optional
Whether to return 0 or 1-based pixel coordinates.
- mode{‘all’, ‘wcs’}, optional
Whether to do the transformation including distortions (
'all'
) or only including only the core WCS transformation ('wcs'
).
- skycoord
- Returns:
- rotate(center, angle)[source]¶
Rotate the pixel coordinate.
Positive
angle
corresponds to counter-clockwise rotation.
- separation(other)[source]¶
Calculate the separation to another pixel coordinate.
This is the two-dimensional Cartesian separation \(d\) where
\[d = \sqrt{(x_1 - x_2) ^ 2 + (y_1 - y_2) ^ 2}\]- Parameters:
- other
PixCoord
The other pixel coordinate.
- other
- Returns:
- separation
numpy.array
The separation in pixels.
- separation
- to_sky(wcs, origin=0, mode='all')[source]¶
Convert to a
SkyCoord
.- Parameters:
- wcs
WCS
The WCS to use to convert pixels to world coordinates.
- originint, optional
Whether to return 0 or 1-based pixel coordinates.
- mode{‘all’, ‘wcs’}, optional
Whether to do the transformation including distortions (
'all'
) or only including only the core WCS transformation ('wcs'
).
- wcs
- Returns:
- coord
SkyCoord
A new object with sky coordinates corresponding to the pixel coordinates.
- coord