1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
"""Manage outlines on the sky.
This module provides support for working with footprints
on the sky. Primary use case would use the following
generalized steps::
#. Initialize SkyLine objects for each input image.
This object would be the union of all the input
image's individual chips WCS footprints.
#. Determine overlap between all images. The
determination would employ a recursive operation
to return the extended list of all overlap values
computed as [img1 vs [img2,img3,...,imgN],img2 vs
[img3,...,imgN],...]
#. Select the pair with the largest overlap, or the
pair which produces the largest overlap with the
first input image. This defines the initial
reference SkyLine object.
#. Perform some operation on the 2 images: for example,
match sky in intersecting regions, or aligning
second image with the first (reference) image.
#. Update the second image, either apply the sky value
or correct the WCS, then generate a new SkyLine
object for that image.
#. Create a new reference SkyLine object as the union
of the initial reference object and the newly
updated SkyLine object.
#. Repeat Steps 2-6 for all remaining input images.
This process will work reasonably fast as most operations
are performed using the SkyLine objects and WCS information
solely, not image data itself.
.. note:: Requires Python 2.7 or later.
:Authors: Pey Lian Lim, W. Hack
:Organization: Space Telescope Science Institute
:History:
* 2012-05-25 PLL updated doc. Original class structure by WJH.
Examples
--------
>>> from sphere import SkyLine
"""
from __future__ import division, print_function
# THIRD-PARTY
import pyfits
from stwcs import wcsutil
# LOCAL
from polygon import SphericalPolygon
__all__ = ['SkyLine']
class SkyLine(SphericalPolygon):
def __init__(self, fname):
"""Initialize SkyLine object instance.
Parameters
----------
self: obj
SkyLine instance.
fname: str
FITS image.
"""
# Find SCI extensions
with pyfits.open(fname) as pf:
sci_extnum = tuple([i for i,ext in enumerate(pf) if
'SCI' in ext.name.upper()])
assert len(sci_extnum) > 0, \
'SkyLine cannot find SCI ext in {}.'.format(fname)
# Initialize mosaic with first chip
all_sph = SphericalPolygon.from_wcs(
wcsutil.HSTWCS(fname, ext=sci_extnum[0]))
# Mosaic all the chips
for i in sci_extnum[1:]:
prev_sph = all_sph.__copy__()
cur_sph = SphericalPolygon.from_wcs(
wcsutil.HSTWCS(fname, ext=i))
all_sph = prev_sph.union(cur_sph)
# SkyLine = final mosaic inheriting from SphericalPolygon
SphericalPolygon.__init__(self, all_sph.points, all_sph.inside)
# Add attribute to track images in SkyLine
self._image_list = [fname]
@property
def image_list(self):
"""List of images in SkyLine."""
return self._image_list
# Overload parent class with following changes
# a. add own attr
# b. update self var in-place, no return
def add_image(self,skyline):
"""Make composite SkyLine"""
pass
def compute_overlap(self, skyline):
"""Return sphere object with intersect of 2 skylines.
Wrapper of sphere overlap method.
"""
pass
def find_intersection(self, skyline):
"""
Return WCS object of overlap of 2 skylines.
"""
pass
def within(self, pos):
"""
Return bool if pos is in skyline or not.
"""
pass
def create_wcs(self):
"""Create WCS from SkyLine object.
.. note:: Use stwcs to define a plane using multiple HSTWCS object
Returns
-------
wcs: obj
New HSTWCS objects.
"""
pass
def footprints(self):
"""Compute edges of skyline."""
pass
def test():
"""Basic use case."""
# Allow disjoint?
pass
|