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 (not Quantity objects with unit “pixel”).

Given a astropy.wcs.WCS object, it can be transformed to and from a SkyCoord 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

isscalar

Whether the instance is scalar (e.g., a single (x, y) coordinate).

xy

A 2-tuple (x, y) for this coordinate.

Methods Summary

copy()

from_sky(skycoord, wcs[, origin, mode])

Create PixCoord from a SkyCoord.

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

copy()[source]
classmethod from_sky(skycoord, wcs, origin=0, mode='all')[source]

Create PixCoord from a SkyCoord.

Parameters:
skycoordSkyCoord

The sky coordinate.

wcsWCS

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').

Returns:
coordPixCoord

A new PixCoord object at the position of the input sky coordinates.

rotate(center, angle)[source]

Rotate the pixel coordinate.

Positive angle corresponds to counter-clockwise rotation.

Parameters:
centerPixCoord

The rotation center point.

angleAngle

The rotation angle.

Returns:
coordPixCoord

The rotated coordinates (which is an independent copy).

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:
otherPixCoord

The other pixel coordinate.

Returns:
separationnumpy.array

The separation in pixels.

to_sky(wcs, origin=0, mode='all')[source]

Convert to a SkyCoord.

Parameters:
wcsWCS

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').

Returns:
coordSkyCoord

A new object with sky coordinates corresponding to the pixel coordinates.