aperture_to_region#
- photutils.aperture.aperture_to_region(aperture)[source]#
Convert a given
Apertureobject to aregions.Regionorregions.Regionsobject.Because a
regions.Regionobject can only have one position, aregions.Regionobject is returned only if the inputapertureis scalar (a single position that is not in a list or array). Otherwise, aregions.Regionsobject is returned with one region per position.- Parameters:
- Returns:
- region
regions.Regionorregions.Regions An equivalent
regions.Regionobject. If the inputapertureis not scalar, then aregions.Regionsobject is returned with one region per position.
- region
- Raises:
Notes
The elliptical aperture
aandbparameters represent the semimajor and semiminor axes, respectively. Theaandbparameters are mapped to the ellipsewidthandheightregion parameters, respectively, by multiplying by 2 because they represent the full extent of the ellipse.The region
anglefor sky-based regions is defined as the angle of thewidthaxis relative to the WCS longitude axis (PA=90). However, the sky-based apertures definethetaas the position angle, relative to the North celestial pole (PA=0), of the semimajor axis (elliptical apertures) or of the width side (rectangular apertures). Therefore, for sky-based elliptical and rectangular apertures thethetaparameter is converted to the regionangleby adding 90 degrees.The following
Apertureobjects are supported, shown with their equivalentregions.Regionobject: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)> ])>