ManglePolygon¶
-
class
pydl.pydlutils.mangle.ManglePolygon(*args, **kwargs)[source]¶ Bases:
objectSimple object to represent a polygon.
A polygon may be instantiated with a row (
FITS_record) from aFITS_polygonobject, anotherManglePolygonobject (copy constructor), keyword arguments, or with no arguments at all, in which case it represents the whole sky.Attributes
cm ( ndarray) The size of each cap in the polygon.id ( int) An arbitrary ID number.pixel ( int) Pixel this polygon is in.use_caps ( int) Bitmask indicating which caps to use.weight ( float) Weight factor assigned to the polygon.Attributes Summary
ncapsNumber of caps in the polygon. strSolid angle of this polygon (steradians). xThe orientation of each cap in the polygon. Methods Summary
add_caps(x, cm)Create a new polygon that contains additional caps. cmminf()The index of the smallest cap in the polygon, accounting for negative caps and use_caps.copy()Return an exact copy of the polygon. garea()Compute the area of a polygon. gzeroar()If at least one cap has zero area, then the whole polygon has zero area. polyn(other, n[, complement])Intersection of a polygon with the nth cap of another polygon.Attributes Documentation
-
ncaps¶ Number of caps in the polygon.
-
str¶ Solid angle of this polygon (steradians).
-
x¶ The orientation of each cap in the polygon. The direction is specified by a unit 3-vector.
Methods Documentation
-
add_caps(x, cm)[source]¶ Create a new polygon that contains additional caps. The caps are appended to the existing polygon’s caps.
Parameters: x :
ndarrayorrecarrayXvalues of the new caps.cm :
ndarrayorrecarrayCMvalues of the new caps.Returns: A new polygon object.
-
cmminf()[source]¶ The index of the smallest cap in the polygon, accounting for negative caps and
use_caps.Returns: intInteger index of the smallest cap.
-
garea()[source]¶ Compute the area of a polygon.
See [1] for the detailed area formula, which is summarized here:
- An empty polygon with no caps is defined to be the whole sky.
- A polygon with one cap has area
2*pi*self.cm. - A polygon with at least one cap with an area less than \(2\pi\) has an area less than \(2\pi\).
- If every cap has an area greater than \(2\pi\), split the polygon into two smaller polygons and sum the two areas.
Returns: floatThe area of the polygon.
References
[1] Hamilton, A. J. S.; Tegmark, Max, 2004 MNRAS 349, 115.
-
gzeroar()[source]¶ If at least one cap has zero area, then the whole polygon has zero area.
Returns: boolTrueif the area is zero.
-
polyn(other, n, complement=False)[source]¶ Intersection of a polygon with the
nth cap of another polygon.Parameters: other :
ManglePolygonPolygon containing a cap to intersect the first polygon with.
n :
intIndex of the cap in
other.complement :
bool, optionalIf
True, set the sign of the cm value ofotherto be the complement of the original value.Returns: A polygon containing the intersected caps.
-