SkyRectangularAperture#

class photutils.aperture.SkyRectangularAperture(positions, w, h, theta=<Quantity 0. deg>)[source]#

Bases: SkyAperture

A rectangular aperture defined in sky coordinates.

The aperture has a single fixed size/shape, but it can have multiple positions (see the positions input).

Parameters:
positionsSkyCoord

The celestial coordinates of the aperture center(s). This can be either scalar coordinates or an array of coordinates.

wscalar Quantity

The full width of the rectangle in angular units. For theta=0 the width side is along the North-South axis.

hscalar Quantity

The full height of the rectangle in angular units. For theta=0 the height side is along the East-West axis.

thetascalar Quantity, optional

The position angle (in angular units) of the rectangle “width” side, measured from North (PA=0) toward East. This is counterclockwise on an image displayed with North up and East to the left. North and East are the directions of increasing latitude and longitude in the coordinate frame of positions (e.g., ICRS or Galactic). When the aperture is converted to pixels with a WCS whose celestial frame differs from that frame, the angle is converted to the equivalent angle in the WCS frame, so the aperture keeps the same orientation on the sky.

Raises:
TypeErrorTypeError

If either width (w) or height (h) is not a Quantity.

ValueErrorValueError

If either width (w) or height (h) is not positive.

Examples

>>> from astropy.coordinates import SkyCoord
>>> import astropy.units as u
>>> from photutils.aperture import SkyRectangularAperture
>>> positions = SkyCoord(ra=[10.0, 20.0], dec=[30.0, 40.0], unit='deg')
>>> aper = SkyRectangularAperture(positions, 1.0*u.arcsec, 0.5*u.arcsec)

Attributes Summary

h

The full height in angular units.

isscalar

Whether the instance is scalar (i.e., a single position).

positions

The center position(s) in sky coordinates.

shape

The shape of the instance.

theta

The position angle (in angular units) of the rectangle "width" side.

w

The full width in angular units.

Methods Summary

copy()

Make a deep copy of this object.

to_pixel(wcs)

Convert the aperture to a RectangularAperture object defined in pixel coordinates.

to_polygon()

Return a SkyPolygonAperture with the four corners of this rectangle as its vertices.

Attributes Documentation

h#

The full height in angular units.

isscalar#

Whether the instance is scalar (i.e., a single position).

positions#

The center position(s) in sky coordinates.

shape#

The shape of the instance.

theta#

The position angle (in angular units) of the rectangle “width” side.

w#

The full width in angular units.

Methods Documentation

copy()#

Make a deep copy of this object.

Returns:
resultAperture

A deep copy of the Aperture object.

to_pixel(wcs)[source]#

Convert the aperture to a RectangularAperture object defined in pixel coordinates.

Parameters:
wcsWCS object

A world coordinate system (WCS) transformation that supports the astropy shared interface for WCS (e.g., astropy.wcs.WCS, gwcs.wcs.WCS).

Returns:
apertureRectangularAperture object

A RectangularAperture object.

Notes

The aperture shape parameters are converted using the local WCS properties (pixel scale, rotation angle) evaluated at the first aperture position. Because aperture objects require scalar shape parameters, only a single reference position is used for the conversion. For apertures with multiple positions used with a WCS that has spatially-varying distortions, this may produce inaccurate results for positions far from the first position.

to_polygon()[source]#

Return a SkyPolygonAperture with the four corners of this rectangle as its vertices.

Returns:
apertureSkyPolygonAperture

A sky polygon aperture exactly equivalent to the rectangle.