RectangularAperture

class photutils.aperture.RectangularAperture(positions, w, h, theta=0.0)[source]

Bases: photutils.aperture.RectangularMaskMixin, photutils.aperture.PixelAperture

A rectangular aperture defined in pixel coordinates.

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

Parameters
positionsarray_like or Quantity

The pixel coordinates of the aperture center(s) in one of the following formats:

  • single (x, y) pair as a tuple, list, or ndarray

  • tuple, list, or ndarray of (x, y) pairs

  • Quantity instance of (x, y) pairs in pixel units

wfloat

The full width of the rectangle in pixels. For theta=0 the width side is along the x axis.

hfloat

The full height of the rectangle in pixels. For theta=0 the height side is along the y axis.

thetafloat, optional

The rotation angle in radians of the rectangle “width” side from the positive x axis. The rotation angle increases counterclockwise. The default is 0.

Raises
ValueErrorValueError

If either width (w) or height (h) is negative.

Examples

>>> from photutils import RectangularAperture
>>> aper = RectangularAperture([10., 20.], 5., 3.)
>>> aper = RectangularAperture((10., 20.), 5., 3., theta=np.pi)
>>> pos1 = (10., 20.)  # (x, y)
>>> pos2 = (30., 40.)
>>> pos3 = (50., 60.)
>>> aper = RectangularAperture([pos1, pos2, pos3], 5., 3.)
>>> aper = RectangularAperture((pos1, pos2, pos3), 5., 3., theta=np.pi)

Attributes Summary

area

Return the exact area of the aperture shape.

h

Check that value is a strictly positive (>= 0) scalar.

positions

Validate and set positions for pixel-based apertures.

theta

Check that value is a scalar.

w

Check that value is a strictly positive (>= 0) scalar.

Methods Summary

to_sky(wcs)

Convert the aperture to a SkyRectangularAperture object defined in celestial coordinates.

Attributes Documentation

area
h

Check that value is a strictly positive (>= 0) scalar.

positions

Validate and set positions for pixel-based apertures.

In all cases, pixel positions are converted to a 2D ndarray (without units).

theta

Check that value is a scalar.

w

Check that value is a strictly positive (>= 0) scalar.

Methods Documentation

to_sky(wcs)[source]

Convert the aperture to a SkyRectangularAperture object defined in celestial 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
apertureSkyRectangularAperture object

A SkyRectangularAperture object.