summaryrefslogtreecommitdiff
path: root/lib/skyline.py
diff options
context:
space:
mode:
authorlim <lim@stsci.edu>2012-05-31 17:07:03 -0400
committerlim <lim@stsci.edu>2012-05-31 17:07:03 -0400
commit31df25ae1622ae39c06e60f7240155d4e22572e7 (patch)
treec7bc1a4e843fb97bc28e1ae2d7762a130747ce35 /lib/skyline.py
parent16ef49875672596443ba2c8f390e2f9753add1e5 (diff)
downloadstsci.sphere-31df25ae1622ae39c06e60f7240155d4e22572e7.tar.gz
lim changed SphericalPolygon.__copy__ and added methods to SkyLine
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/branches/sphere@17093 fe389314-cf27-0410-b35b-8c050e845b92 Former-commit-id: 4e5e26af63393082e5a9baae4f37704f99cd4227
Diffstat (limited to 'lib/skyline.py')
-rw-r--r--lib/skyline.py69
1 files changed, 61 insertions, 8 deletions
diff --git a/lib/skyline.py b/lib/skyline.py
index df6a390..c5d3940 100644
--- a/lib/skyline.py
+++ b/lib/skyline.py
@@ -53,6 +53,9 @@ Examples
"""
from __future__ import division, print_function
+# STDLIB
+from copy import deepcopy
+
# THIRD-PARTY
import pyfits
from stwcs import wcsutil
@@ -65,6 +68,7 @@ __version__ = '0.1a'
__vdate__ = '31-May-2012'
class SkyLineMember(object):
+
def __init__(self, fname, ext):
"""Container for SkyLine members.
@@ -132,10 +136,13 @@ class SkyLine(SphericalPolygon):
self._members = poly_list
# Put mosaic of all the chips in SkyLine
- mosaic = SphericalPolygon.multi_union(self.polygons)
+ mosaic = self.multi_union(self.polygons)
self._points = mosaic.points
self._inside = mosaic.inside
+ def __repr__(self):
+ return 'SkyLine(%r, %r, %r)' % (self.points, self.inside, self.members)
+
@property
def members(self):
"""List of SkyLineMember objects."""
@@ -146,6 +153,59 @@ class SkyLine(SphericalPolygon):
"""List of SkyLineMember polygons."""
return [m.polygon for m in self.members]
+ @classmethod
+ def from_radec(cls, ra, dec, center=None, degrees=True):
+ """See SphericalPolygon."""
+ return SphericalPolygon.from_radec(ra, dec, center=center,
+ degrees=degrees)
+
+ @classmethod
+ def from_cone(cls, ra, dec, radius, degrees=True, steps=16.0):
+ """See SphericalPolygon."""
+ return SphericalPolygon.from_cone(ra, dec, radius, degrees=degrees,
+ steps=steps)
+
+ @classmethod
+ def from_wcs(cls, fitspath, steps=1, crval=None):
+ """See SphericalPolygon."""
+ return SphericalPolygon.from_wcs(fitspath, steps=steps, crval=crval)
+
+ @classmethod
+ def multi_union(cls, polygons, method='parallel'):
+ """See SphericalPolygon."""
+ return SphericalPolygon.multi_union(polygons, method=method)
+
+ def union(self, other):
+ """
+ Updates *self* with the union of *self* and *other*.
+
+ Parameters
+ ----------
+ self: obj
+ `SkyLine` instance to be updated.
+
+ other: obj
+ `SkyLine` instance to be added.
+
+ Examples
+ --------
+ >>> s1 = SkyLine('image1.fits')
+ >>> s2 = SkyLine('image2.fits')
+ >>> s1.union(s2) # s1 is updated
+
+ See also
+ --------
+ sphere.polygon.SphericalPolygon.union
+
+ """
+# all_poly = self.multi_union(self.polygons + other.polygons)
+
+# Need to update
+# self._points
+# self._inside
+# self._members
+ pass
+
# Overload parent class with following changes
# a. add own attr
# b. update self var in-place, no return
@@ -169,13 +229,6 @@ class SkyLine(SphericalPolygon):
"""
pass
- def within(self, pos):
- """
- Return bool if pos is in skyline or not.
-
- """
- pass
-
def create_wcs(self):
"""Create WCS from SkyLine object.