aperture_to_region#

photutils.aperture.aperture_to_region(aperture)[source]#

Convert a given Aperture object to a regions.Region or regions.Regions object.

Because a regions.Region object can only have one position, a regions.Regions object will be returned if the input aperture has more than one position. Otherwise, a regions.Region object will be returned.

Parameters:
apertureAperture

An Aperture object to convert.

Returns:
regionregions.Region or regions.Regions

An equivalent regions.Region object. If the input aperture has more than one position then a regions.Regions will be returned.

Notes

The elliptical aperture a and b parameters represent the semi-major and semi-minor axes, respectively. The a and b parameters are mapped to the ellipse width and height region parameters, respectively, by multiplying by 2 because they represent the full extent of the ellipse.

The region angle for sky-based regions is defined as the angle of the width axis relative to WCS longitude axis (PA=90). However, the sky-based apertures define the theta as the position angle of the semimajor axis relative to the North celestial pole (PA=0). Therefore, for sky-based apertures the theta parameter is converted to the region angle by adding 90 degrees.

The following Aperture objects are supported, shown with their equivalent regions.Region object:

Examples

>>> from photutils.aperture import CircularAperture, aperture_to_region
>>> aperture = CircularAperture((10, 20), r=5)
>>> region = aperture_to_region(aperture)
>>> region
<CirclePixelRegion(center=PixCoord(x=10.0, y=20.0), radius=5.0)>
>>> aperture = CircularAperture(((10, 20), (30, 40)), r=5)
>>> region = aperture_to_region(aperture)
>>> region
<Regions([<CirclePixelRegion(center=PixCoord(x=10.0, y=20.0), radius=5.0)>,
<CirclePixelRegion(center=PixCoord(x=30.0, y=40.0), radius=5.0)>])>