PixCoord

class regions.PixCoord(x, y)[source]

Bases: object

Pixel coordinates.

This class can represent scalar or array pixel coordinates.

The data members are either numbers or Numpy arrays (not Quantity objects with unit “pixel”).

Given a astropy.wcs.WCS object, it can be transformed to and from a SkyCoord object.

Parameters:
x : float or array-like

Pixel coordinate x value

y : float or array-like

Pixel coordinate y value

Examples

Usage examples are provided in the Coordinates section of the docs.

Attributes Summary

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

Methods Summary

copy(self)
from_sky(skycoord, wcs[, origin, mode]) Create PixCoord from SkyCoord.
rotate(self, center, angle) Make a rotated pixel coordinate.
separation(self, other) Separation to another pixel coordinate.
to_sky(self, wcs[, origin, mode]) Convert this PixCoord to SkyCoord.

Attributes Documentation

isscalar
xy

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

Methods Documentation

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

Create PixCoord from SkyCoord.

Calls astropy.coordinates.SkyCoord.to_pixel(). See parameter description there.

rotate(self, center, angle)[source]

Make a rotated pixel coordinate.

Rotates counter-clockwise for positive angle.

Parameters:
center : PixCoord

Rotation center point

angle : Angle

Rotation angle

Returns:
coord : PixCoord

Rotated coordinates (an independent copy)

separation(self, other)[source]

Separation to another pixel coordinate.

This is the two-dimensional cartesian separation \(d\) with

\[d = \sqrt{(x_1 - x_2) ^ 2 + (y_1 - y_2) ^ 2}\]
Parameters:
other : PixCoord

Other pixel coordinate

Returns:
separation : numpy.array

Separation in pixels

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

Convert this PixCoord to SkyCoord.

Calls astropy.coordinates.SkyCoord.from_pixel(). See parameter description there.