aperture_to_region#
- photutils.aperture.aperture_to_region(aperture)[source]#
Convert a given
Aperture
object to aregions.Region
orregions.Regions
object.Because a
regions.Region
object can only have one position, aregions.Regions
object will be returned if the inputaperture
has more than one position. Otherwise, aregions.Region
object will be returned.- Parameters:
- Returns:
- region
regions.Region
orregions.Regions
An equivalent
regions.Region
object. If the inputaperture
has more than one position then aregions.Regions
will be returned.
- region
Notes
The elliptical aperture
a
andb
parameters represent the semi-major and semi-minor axes, respectively. Thea
andb
parameters are mapped to the ellipsewidth
andheight
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 thewidth
axis relative to WCS longitude axis (PA=90). However, the sky-based apertures define thetheta
as the position angle of the semimajor axis relative to the North celestial pole (PA=0). Therefore, for sky-based apertures thetheta
parameter is converted to the regionangle
by adding 90 degrees.The following
Aperture
objects are supported, shown with their equivalentregions.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)>])>