SkyPolygonAperture#
- class photutils.aperture.SkyPolygonAperture(positions, vertex_offsets)[source]#
Bases:
SkyApertureA polygon aperture defined in sky coordinates.
The aperture has a single fixed shape, defined by angular
vertex_offsetsrelative to eachpositionsentry, but it can have multiple positions. The angular offsets are interpreted on the local tangent plane at each position.- Parameters:
- positions
SkyCoord The celestial coordinates of the aperture center(s). This can be either scalar coordinates or an array of coordinates.
- vertex_offsets
Quantity Shape
(n_vertices, 2)angular Quantity of polygon vertex offsets(d_lon, d_lat)relative topositions, applied as spherical offsets on the local tangent plane. The polygon must be simple (non-self-intersecting) with at least 3 vertices. The polygon may be convex or non-convex.
- positions
Examples
>>> import astropy.units as u >>> import numpy as np >>> from astropy.coordinates import SkyCoord >>> from photutils.aperture import SkyPolygonAperture >>> positions = SkyCoord(ra=[10.0, 20.0], dec=[30.0, 40.0], unit='deg') >>> theta = np.linspace(0, 2 * np.pi, 5, endpoint=False) >>> r = 1.0 >>> offsets = np.column_stack([r * np.cos(theta), ... r * np.sin(theta)]) * u.arcsec >>> aper = SkyPolygonAperture(positions, offsets)
Attributes Summary
The exterior angle of the regular polygon as an angular
Quantityin degrees.The angular inner (inscribed-circle) radius of the regular polygon as a
Quantity, i.e., the distance frompositionsto the midpoint of each side.The interior angle of the regular polygon as an angular
Quantityin degrees.Trueif the polygon is regular (equal-length sides and equal interior angles, with all vertices at the same angular distance frompositions).Whether the instance is scalar (i.e., a single position).
The number of vertices of the polygon.
The angular outer (circumscribed-circle) radius of the regular polygon as a
Quantity, i.e., the distance frompositionsto each vertex.The angular perimeter of the polygon as a
Quantity.The center position(s) in sky coordinates.
The shape of the instance.
The angular side length of the regular polygon as a
Quantity.The rotation angle of the regular polygon as an angular
Quantityin degrees.The (n_vertices, 2) angular Quantity of polygon vertex offsets (d_lon, d_lat) relative to
positions.The absolute sky vertices of the polygon at each aperture position, as a
SkyCoord.Methods Summary
copy()Make a deep copy of this object.
from_regular_polygon(positions, n_vertices, ...)Construct a regular
SkyPolygonAperturefrom a center, vertex count, angular circumradius, and rotation angle.from_vertices(vertices)Construct a
SkyPolygonAperturefrom a single set of absolute sky vertices.to_pixel(wcs)Convert the aperture to a
PolygonApertureobject defined in pixel coordinates.Attributes Documentation
- exterior_angle#
The exterior angle of the regular polygon as an angular
Quantityin degrees.This attribute is only defined for regular polygons. Accessing it for a non-regular polygon raises
ValueError.
- inner_radius#
The angular inner (inscribed-circle) radius of the regular polygon as a
Quantity, i.e., the distance frompositionsto the midpoint of each side.This is also called the inradius
This attribute is only defined for regular polygons. Accessing it for a non-regular polygon raises
ValueError.
- interior_angle#
The interior angle of the regular polygon as an angular
Quantityin degrees.This attribute is only defined for regular polygons. Accessing it for a non-regular polygon raises
ValueError.
- is_regular#
Trueif the polygon is regular (equal-length sides and equal interior angles, with all vertices at the same angular distance frompositions).
- isscalar#
Whether the instance is scalar (i.e., a single position).
- n_vertices#
The number of vertices of the polygon.
- outer_radius#
The angular outer (circumscribed-circle) radius of the regular polygon as a
Quantity, i.e., the distance frompositionsto each vertex.This is also called the circumradius.
This attribute is only defined for regular polygons. Accessing it for a non-regular polygon raises
ValueError.
- perimeter#
The angular perimeter of the polygon as a
Quantity.The perimeter is computed as the sum of the angular distances between consecutive vertices on the local tangent plane.
- positions#
The center position(s) in sky coordinates.
- shape#
The shape of the instance.
- side_length#
The angular side length of the regular polygon as a
Quantity.This attribute is only defined for regular polygons. Accessing it for a non-regular polygon raises
ValueError.
- theta#
The rotation angle of the regular polygon as an angular
Quantityin degrees.The angle is measured counter-clockwise from the
+lataxis on the local tangent plane to the first vertex, in the range[0, 360) deg. This assumes a right-handed coordinate system (e.g., standard celestial coordinates). This convention matches thethetaparameter offrom_regular_polygon.This attribute is only defined for regular polygons. Accessing it for a non-regular polygon raises
ValueError.
- vertex_offsets#
The (n_vertices, 2) angular Quantity of polygon vertex offsets (d_lon, d_lat) relative to
positions.
- vertices#
The absolute sky vertices of the polygon at each aperture position, as a
SkyCoord.For a scalar aperture, the returned SkyCoord has shape
(n_vertices,). For an aperture withn_positionspositions, the returned SkyCoord has shape(n_positions, n_vertices).
Methods Documentation
- classmethod from_regular_polygon(positions, n_vertices, radius, *, theta=<Quantity 0. deg>)[source]#
Construct a regular
SkyPolygonAperturefrom a center, vertex count, angular circumradius, and rotation angle.The first vertex is placed at the
+latedge of the local tangent plane (typically northward for standard right-handed celestial coordinates) fortheta == 0and is rotated counter-clockwise bytheta.- Parameters:
- positions
SkyCoord The celestial coordinates of the aperture center(s).
- n_verticesint
The number of vertices (must be at least 3).
- radius
Quantity The angular circumradius (outer radius) of the polygon (must be a positive angular Quantity).
- theta
Quantity, optional The rotation angle of the polygon, measured counter- clockwise from the
+lataxis on the local tangent plane. This assumes a right-handed coordinate system (e.g., standard celestial coordinates).
- positions
- Returns:
- aperture
SkyPolygonAperture The regular sky polygon aperture.
- aperture
- classmethod from_vertices(vertices)[source]#
Construct a
SkyPolygonAperturefrom a single set of absolute sky vertices.The aperture’s
positionsis set to an approximate centroid of the input vertices, computed as a single tangent-plane mean of the spherical offsets from the first vertex (i.e., the vertices’ spherical offsets from this centroid average to approximately zero), andvertex_offsetsis set to the spherical offsets of the vertices from this centroid.- Parameters:
- vertices
SkyCoord A SkyCoord with shape
(n_vertices,)of absolute polygon vertex coordinates.
- vertices
- Returns:
- aperture
SkyPolygonAperture A scalar sky polygon aperture whose
verticesproperty reproduces the input.
- aperture
- to_pixel(wcs)[source]#
Convert the aperture to a
PolygonApertureobject defined in pixel coordinates.The conversion uses
wcs.world_to_pixeldirectly on the absolute sky vertex coordinate, evaluated at the first aperture position.- 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:
- aperture
PolygonAperture The equivalent pixel-coordinate polygon aperture.
- aperture