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
53 cellInnerDimensions : `~collections.abc.Iterable` of 2 `int`
or \
55 Inner dimensions of each cell (x,y pixels).
56 cellBorder : `int`, optional
57 Cell border size (pixels).
58 numCellsPerPatchInner : `int`, optional
59 Number of cells per inner patch region.
60 numCellsInPatchBorder : `int`, optional
61 Number of cells
in the patch border.
64 def __init__(self, index, innerBBox, outerBBox, sequentialIndex,
66 cellInnerDimensions=(0, 0), cellBorder=0,
67 numCellsPerPatchInner=0, numCellsInPatchBorder=0):
73 if not outerBBox.contains(innerBBox):
74 raise RuntimeError(
"outerBBox=%s does not contain innerBBox=%s" % (outerBBox, innerBBox))
75 if not isinstance(cellInnerDimensions, (Iterable, Extent2I)):
76 raise ValueError(
"Input cellInnerDimensions is not an iterable.")
77 if len(cellInnerDimensions) != 2:
78 raise ValueError(
"Input cellInnerDimensions does not have two values.")
82 if numCellsPerPatchInner == 0:
87 y=numCellsPerPatchInner + 2*numCellsInPatchBorder)
90 """Return patch index: a tuple of (x, y)
99 index = property(getIndex)
102 """Return patch sequential index.
107 Sequential patch index.
111 sequential_index = property(getSequentialIndex)
114 """Return the associated tract wcs
123 wcs = property(getWcs)
126 """Get inner bounding box.
131 The inner bounding Box.
135 inner_bbox = property(getInnerBBox)
138 """Get outer bounding box.
143 The outer bounding Box.
147 outer_bbox = property(getOuterBBox)
150 """Get the inner on-sky region.
154 tractWcs : `lsst.afw.image.SkyWcs`, optional
155 WCS for the associated tract.
160 The inner sky region.
162 _tractWcs = tractWcs if tractWcs
is not None else self.
_wcs
163 return makeSkyPolygonFromBBox(bbox=self.
getInnerBBox(), wcs=_tractWcs)
170 """Get the outer on-sky region.
174 tractWcs : `lsst.afw.image.SkyWcs`, optional
175 WCS for the associated tract.
180 The outer sky region.
182 _tractWcs = tractWcs if tractWcs
is not None else self.
_wcs
183 return makeSkyPolygonFromBBox(bbox=self.
getOuterBBox(), wcs=_tractWcs)
190 """Get the number of cells in x, y.
192 May return (0, 0)
if no cells are defined.
197 The number of cells
in x, y.
201 num_cells = property(getNumCells)
206 cell_border = property(getCellBorder)
209 """Return information for the specified cell.
214 Index of cell,
as `Index2D` ,
or two integers,
215 or a sequential index
as returned by getSequentialCellIndex;
216 negative values are
not supported.
221 The cell info
for that index.
226 Raised
if index
is out of range.
229 raise IndexError(
"Patch does not contain cells.")
230 if isinstance(index, Index2D):
233 if isinstance(index, numbers.Number):
237 if (
not 0 <= _index.x < self.
_numCells.x) \
238 or (
not 0 <= _index.y < self.
_numCells.y):
239 raise IndexError(
"Cell index %s is not in range [0-%d, 0-%d]" %
247 + patchInnerBBox.getBegin()[i]
251 outerBBox =
Box2I(innerBBox)
263 """Get dimensions of inner region of the cells (all are the same)
267 cell_inner_dimensions = property(getCellInnerDimensions)
270 """Return a single integer that uniquely identifies
271 the given cell within this patch.
279 sequentialIndex : `int`
284 Raised if index
is out of range.
286 index = cellInfo.getIndex()
290 """Return a single integer that uniquely identifies
291 the given cell within this patch.
299 sequentialIndex : `int`
304 Raised if index
is out of range.
306 if isinstance(index, Index2D):
311 return nx*_index.y + _index.x
314 """Convert a sequential index into an index pair.
318 sequentialIndex : `int`
327 Raised if index
is out of range.
330 raise IndexError(
"Patch does not contain cells.")
333 x = sequentialIndex % nx
334 y = sequentialIndex // nx
339 for y
in range(yNum):
340 for x
in range(xNum):
351 return (self.
getIndex() == rhs.getIndex()) \
358 return not self.
__eq__(rhs)
361 return "PatchInfo(index=%s)" % (self.
getIndex(),)
365 return (
"PatchInfo(index=%s, innerBBox=%s, outerBBox=%s, cellInnerDimensions=%s, "
366 "cellBorder=%s, numCellsPerPatchInner=%s)") % \
371 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.
getOuterSkyPolygon(self, tractWcs=None)
getSequentialCellIndexFromPair(self, index)
getCellInnerDimensions(self)
getSequentialCellIndex(self, cellInfo)
__init__(self, index, innerBBox, outerBBox, sequentialIndex, tractWcs, cellInnerDimensions=(0, 0), cellBorder=0, numCellsPerPatchInner=0, numCellsInPatchBorder=0)
getInnerSkyPolygon(self, tractWcs=None)
getCellIndexPair(self, sequentialIndex)
ConvexPolygon is a closed convex polygon on the unit sphere.