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.
- cm
Attributes Summary
Number of caps in the polygon.
Solid angle of this polygon (steradians).
The 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
ndarrayorrecarray Xvalues of the new caps.- cm
ndarrayorrecarray CMvalues of the new caps.
- x
- Returns:
ManglePolygonA 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.
- copy()[source]¶
Return an exact copy of the polygon.
- Returns:
ManglePolygonA new polygon object.
- 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
- 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
ManglePolygon Polygon containing a cap to intersect the first polygon with.
- n
int Index of the cap in
other.- complement
bool, optional If
True, set the sign of the cm value ofotherto be the complement of the original value.
- other
- Returns:
ManglePolygonA polygon containing the intersected caps.