23__all__ = [
"PatchInfo"]
28from lsst.geom import Extent2I, Point2I, Box2I
29from .detail
import makeSkyPolygonFromBBox, Index2D
30from .cellInfo
import CellInfo
34 """Information about a patch within a tract of a sky map.
36 If cellInnerDimensions and cellBorder are set then the patch
37 will be gridded
with cells.
39 See `TractInfo`
for more information.
44 x,y index of patch (a pair of ints)
49 sequentialIndex : `int`
50 Patch sequential index
54 Inner dimensions of each cell (x,y pixels).
55 cellBorder : `int`, optional
56 Cell border size (pixels).
57 numCellsPerPatchInner : `int`, optional
58 Number of cells per inner patch region.
59 numCellsInPatchBorder : `int`, optional
60 Number of cells
in the patch border.
63 def __init__(self, index, innerBBox, outerBBox, sequentialIndex,
65 cellInnerDimensions=(0, 0), cellBorder=0,
66 numCellsPerPatchInner=0, numCellsInPatchBorder=0):
72 if not outerBBox.contains(innerBBox):
73 raise RuntimeError(
"outerBBox=%s does not contain innerBBox=%s" % (outerBBox, innerBBox))
74 if not isinstance(cellInnerDimensions, (Iterable, Extent2I)):
75 raise ValueError(
"Input cellInnerDimensions is not an iterable.")
76 if len(cellInnerDimensions) != 2:
77 raise ValueError(
"Input cellInnerDimensions does not have two values.")
81 if numCellsPerPatchInner == 0:
86 y=numCellsPerPatchInner + 2*numCellsInPatchBorder)
89 """Return patch index: a tuple of (x, y)
98 index = property(getIndex)
101 """Return patch sequential index.
106 Sequential patch index.
110 sequential_index = property(getSequentialIndex)
113 """Return the associated tract wcs
122 wcs = property(getWcs)
125 """Get inner bounding box.
130 The inner bounding Box.
134 inner_bbox = property(getInnerBBox)
137 """Get outer bounding box.
142 The outer bounding Box.
146 outer_bbox = property(getOuterBBox)
149 """Get the inner on-sky region.
153 tractWcs : `lsst.afw.image.SkyWcs`, optional
154 WCS for the associated tract.
159 The inner sky region.
161 _tractWcs = tractWcs if tractWcs
is not None else self.
_wcs
162 return makeSkyPolygonFromBBox(bbox=self.
getInnerBBox(), wcs=_tractWcs)
169 """Get the outer on-sky region.
173 tractWcs : `lsst.afw.image.SkyWcs`, optional
174 WCS for the associated tract.
179 The outer sky region.
181 _tractWcs = tractWcs if tractWcs
is not None else self.
_wcs
182 return makeSkyPolygonFromBBox(bbox=self.
getOuterBBox(), wcs=_tractWcs)
189 """Get the number of cells in x, y.
191 May return (0, 0)
if no cells are defined.
196 The number of cells
in x, y.
200 num_cells = property(getNumCells)
205 cell_border = property(getCellBorder)
208 """Return information for the specified cell.
213 Index of cell,
as `Index2D`,
or `Iterable` [`int`, `int`];
214 or a sequential index
as returned by getSequentialCellIndex;
215 negative values are
not supported.
220 The cell info
for that index.
225 If index
is out of range.
228 raise IndexError(
"Patch does not contain cells.")
229 if isinstance(index, Index2D):
232 if isinstance(index, numbers.Number):
236 if (
not 0 <= _index.x < self.
_numCells.x) \
237 or (
not 0 <= _index.y < self.
_numCells.y):
238 raise IndexError(
"Cell index %s is not in range [0-%d, 0-%d]" %
245 + patchInnerBBox.getBegin()[i]
249 outerBBox =
Box2I(innerBBox)
261 """Get dimensions of inner region of the cells (all are the same)
265 cell_inner_dimensions = property(getCellInnerDimensions)
268 """Return a single integer that uniquely identifies
269 the given cell within this patch.
277 sequentialIndex : `int`
282 If index is out of range.
284 index = cellInfo.getIndex()
288 """Return a single integer that uniquely identifies
289 the given cell within this patch.
297 sequentialIndex : `int`
302 If index is out of range.
304 if isinstance(index, Index2D):
309 return nx*_index.y + _index.x
312 """Convert a sequential index into an index pair.
316 sequentialIndex : `int`
325 If index is out of range.
328 raise IndexError(
"Patch does not contain cells.")
331 x = sequentialIndex % nx
332 y = sequentialIndex // nx
337 for y
in range(yNum):
338 for x
in range(xNum):
349 return (self.
getIndex() == rhs.getIndex()) \
356 return not self.
__eq__(rhs)
359 return "PatchInfo(index=%s)" % (self.
getIndex(),)
363 return (
"PatchInfo(index=%s, innerBBox=%s, outerBBox=%s, cellInnerDimensions=%s, "
364 "cellBorder=%s, numCellsPerPatchInner=%s)") % \
369 return "PatchInfo(index=%s, innerBBox=%s, outerBBox=%s)" % \
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
An integer coordinate rectangle.
def getOuterSkyPolygon(self, tractWcs=None)
def getCellInnerDimensions(self)
def getCellInfo(self, index)
def __init__(self, index, innerBBox, outerBBox, sequentialIndex, tractWcs, cellInnerDimensions=(0, 0), cellBorder=0, numCellsPerPatchInner=0, numCellsInPatchBorder=0)
def outer_sky_polygon(self)
def getSequentialCellIndex(self, cellInfo)
def getCellIndexPair(self, sequentialIndex)
def getSequentialCellIndexFromPair(self, index)
def inner_sky_polygon(self)
def getInnerSkyPolygon(self, tractWcs=None)
def getSequentialIndex(self)
def __getitem__(self, index)
ConvexPolygon is a closed convex polygon on the unit sphere.