LSST Applications g0265f82a02+d6b5cd48b5,g02d81e74bb+a41d3748ce,g1470d8bcf6+6be6c9203b,g2079a07aa2+14824f138e,g212a7c68fe+a4f2ea4efa,g2305ad1205+72971fe858,g295015adf3+ab2c85acae,g2bbee38e9b+d6b5cd48b5,g337abbeb29+d6b5cd48b5,g3ddfee87b4+31b3a28dff,g487adcacf7+082e807817,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+b2918d57ae,g5a732f18d5+66d966b544,g64a986408d+a41d3748ce,g858d7b2824+a41d3748ce,g8a8a8dda67+a6fc98d2e7,g99cad8db69+7fe4acdf18,g9ddcbc5298+d4bad12328,ga1e77700b3+246acaaf9c,ga8c6da7877+84af8b3ff8,gb0e22166c9+3863383f4c,gb6a65358fc+d6b5cd48b5,gba4ed39666+9664299f35,gbb8dafda3b+d8d527deb2,gc07e1c2157+b2dbe6b631,gc120e1dc64+61440b2abb,gc28159a63d+d6b5cd48b5,gcf0d15dbbd+31b3a28dff,gdaeeff99f8+a38ce5ea23,ge6526c86ff+39927bb362,ge79ae78c31+d6b5cd48b5,gee10cc3b42+a6fc98d2e7,gf1cff7945b+a41d3748ce,v24.1.5.rc1
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Properties | List of all members
lsst.skymap.patchInfo.PatchInfo Class Reference

Public Member Functions

 __init__ (self, index, innerBBox, outerBBox, sequentialIndex, tractWcs, cellInnerDimensions=(0, 0), cellBorder=0, numCellsPerPatchInner=0, numCellsInPatchBorder=0)
 
 getIndex (self)
 
 getSequentialIndex (self)
 
 getWcs (self)
 
 getInnerBBox (self)
 
 getOuterBBox (self)
 
 getInnerSkyPolygon (self, tractWcs=None)
 
 inner_sky_polygon (self)
 
 getOuterSkyPolygon (self, tractWcs=None)
 
 outer_sky_polygon (self)
 
 getNumCells (self)
 
 getCellBorder (self)
 
 getCellInfo (self, index)
 
 getCellInnerDimensions (self)
 
 getSequentialCellIndex (self, cellInfo)
 
 getSequentialCellIndexFromPair (self, index)
 
 getCellIndexPair (self, sequentialIndex)
 
 __iter__ (self)
 
 __len__ (self)
 
 __getitem__ (self, index)
 
 __eq__ (self, rhs)
 
 __ne__ (self, rhs)
 
 __str__ (self)
 
 __repr__ (self)
 

Protected Attributes

 _index
 
 _sequentialIndex
 
 _innerBBox
 
 _outerBBox
 
 _wcs
 
 _cellInnerDimensions
 
 _cellBorder
 
 _numCellsInPatchBorder
 
 _numCells
 

Properties

 index = property(getIndex)
 
 sequential_index = property(getSequentialIndex)
 
 wcs = property(getWcs)
 
 inner_bbox = property(getInnerBBox)
 
 outer_bbox = property(getOuterBBox)
 
 num_cells = property(getNumCells)
 
 cell_border = property(getCellBorder)
 
 cell_inner_dimensions = property(getCellInnerDimensions)
 

Detailed Description

Information about a patch within a tract of a sky map.

If cellInnerDimensions and cellBorder are set then the patch
will be gridded with cells.

See `TractInfo` for more information.

Parameters
----------
index : `lsst.skymap.Index2D`
    x,y index of patch (a pair of ints)
innerBBox : `lsst.geom.Box2I`
    inner bounding box
outerBBox : `lsst.geom.Box2I`
    inner bounding box
sequentialIndex : `int`
    Patch sequential index
tractWcs : `lsst.afw.geom.SkyWcs`
    Tract WCS object.
cellInnerDimensions : `~collections.abc.Iterable` of 2 `int` or \
        `lsst.geom.Extent2I`, optional
    Inner dimensions of each cell (x,y pixels).
cellBorder : `int`, optional
    Cell border size (pixels).
numCellsPerPatchInner : `int`, optional
    Number of cells per inner patch region.
numCellsInPatchBorder : `int`, optional
    Number of cells in the patch border.

Definition at line 33 of file patchInfo.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.skymap.patchInfo.PatchInfo.__init__ ( self,
index,
innerBBox,
outerBBox,
sequentialIndex,
tractWcs,
cellInnerDimensions = (0, 0),
cellBorder = 0,
numCellsPerPatchInner = 0,
numCellsInPatchBorder = 0 )

Definition at line 64 of file patchInfo.py.

67 numCellsPerPatchInner=0, numCellsInPatchBorder=0):
68 self._index = index
69 self._sequentialIndex = sequentialIndex
70 self._innerBBox = innerBBox
71 self._outerBBox = outerBBox
72 self._wcs = tractWcs
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.")
79 self._cellInnerDimensions = Extent2I(*cellInnerDimensions)
80 self._cellBorder = cellBorder
81 self._numCellsInPatchBorder = numCellsInPatchBorder
82 if numCellsPerPatchInner == 0:
83 self._numCells = Index2D(x=0, y=0)
84 else:
85 # There are numCellsInPatchBorder extra boundary cell on each side
86 self._numCells = Index2D(x=numCellsPerPatchInner + 2*numCellsInPatchBorder,
87 y=numCellsPerPatchInner + 2*numCellsInPatchBorder)
88

Member Function Documentation

◆ __eq__()

lsst.skymap.patchInfo.PatchInfo.__eq__ ( self,
rhs )

Definition at line 350 of file patchInfo.py.

350 def __eq__(self, rhs):
351 return (self.getIndex() == rhs.getIndex()) \
352 and (self.getInnerBBox() == rhs.getInnerBBox()) \
353 and (self.getOuterBBox() == rhs.getOuterBBox()) \
354 and (self.getNumCells() == rhs.getNumCells()) \
355 and (self.getCellBorder() == rhs.getCellBorder())
356

◆ __getitem__()

lsst.skymap.patchInfo.PatchInfo.__getitem__ ( self,
index )

Definition at line 347 of file patchInfo.py.

347 def __getitem__(self, index):
348 return self.getCellInfo(index)
349

◆ __iter__()

lsst.skymap.patchInfo.PatchInfo.__iter__ ( self)

Definition at line 337 of file patchInfo.py.

337 def __iter__(self):
338 xNum, yNum = self.getNumCells()
339 for y in range(yNum):
340 for x in range(xNum):
341 yield self.getCellInfo(Index2D(x=x, y=y))
342

◆ __len__()

lsst.skymap.patchInfo.PatchInfo.__len__ ( self)

Definition at line 343 of file patchInfo.py.

343 def __len__(self):
344 xNum, yNum = self.getNumCells()
345 return xNum*yNum
346

◆ __ne__()

lsst.skymap.patchInfo.PatchInfo.__ne__ ( self,
rhs )

Definition at line 357 of file patchInfo.py.

357 def __ne__(self, rhs):
358 return not self.__eq__(rhs)
359

◆ __repr__()

lsst.skymap.patchInfo.PatchInfo.__repr__ ( self)

Definition at line 363 of file patchInfo.py.

363 def __repr__(self):
364 if self.getNumCells()[0] > 0:
365 return ("PatchInfo(index=%s, innerBBox=%s, outerBBox=%s, cellInnerDimensions=%s, "
366 "cellBorder=%s, numCellsPerPatchInner=%s)") % \
367 (self.getIndex(), self.getInnerBBox(), self.getOuterBBox(),
368 self.getCellInnerDimensions(), self.getCellBorder(),
369 self.getNumCells()[0])
370 else:
371 return "PatchInfo(index=%s, innerBBox=%s, outerBBox=%s)" % \
372 (self.getIndex(), self.getInnerBBox(), self.getOuterBBox())

◆ __str__()

lsst.skymap.patchInfo.PatchInfo.__str__ ( self)

Definition at line 360 of file patchInfo.py.

360 def __str__(self):
361 return "PatchInfo(index=%s)" % (self.getIndex(),)
362

◆ getCellBorder()

lsst.skymap.patchInfo.PatchInfo.getCellBorder ( self)

Definition at line 203 of file patchInfo.py.

203 def getCellBorder(self):
204 return self._cellBorder
205

◆ getCellIndexPair()

lsst.skymap.patchInfo.PatchInfo.getCellIndexPair ( self,
sequentialIndex )
Convert a sequential index into an index pair.

Parameters
----------
sequentialIndex : `int`

Returns
-------
x, y : `lsst.skymap.Index2D`

Raises
------
IndexError
    Raised if index is out of range.

Definition at line 313 of file patchInfo.py.

313 def getCellIndexPair(self, sequentialIndex):
314 """Convert a sequential index into an index pair.
315
316 Parameters
317 ----------
318 sequentialIndex : `int`
319
320 Returns
321 -------
322 x, y : `lsst.skymap.Index2D`
323
324 Raises
325 ------
326 IndexError
327 Raised if index is out of range.
328 """
329 if self._numCells.x == 0 or self._numCells.y == 0:
330 raise IndexError("Patch does not contain cells.")
331
332 nx, ny = self.getNumCells()
333 x = sequentialIndex % nx
334 y = sequentialIndex // nx
335 return Index2D(x=x, y=y)
336

◆ getCellInfo()

lsst.skymap.patchInfo.PatchInfo.getCellInfo ( self,
index )
Return information for the specified cell.

Parameters
----------
index : `lsst.skymap.Index2D` or `~collections.abc.Iterable` of 2 `int`
    Index of cell, as `Index2D` ,or two integers,
    or a sequential index as returned by getSequentialCellIndex;
    negative values are not supported.

Returns
-------
result : `lsst.skymap.CellInfo`
    The cell info for that index.

Raises
------
IndexError
    Raised if index is out of range.

Definition at line 208 of file patchInfo.py.

208 def getCellInfo(self, index):
209 """Return information for the specified cell.
210
211 Parameters
212 ----------
213 index : `lsst.skymap.Index2D` or `~collections.abc.Iterable` of 2 `int`
214 Index of cell, as `Index2D` ,or two integers,
215 or a sequential index as returned by getSequentialCellIndex;
216 negative values are not supported.
217
218 Returns
219 -------
220 result : `lsst.skymap.CellInfo`
221 The cell info for that index.
222
223 Raises
224 ------
225 IndexError
226 Raised if index is out of range.
227 """
228 if self._numCells.x == 0 or self._numCells.y == 0:
229 raise IndexError("Patch does not contain cells.")
230 if isinstance(index, Index2D):
231 _index = index
232 else:
233 if isinstance(index, numbers.Number):
234 _index = self.getCellIndexPair(index)
235 else:
236 _index = Index2D(*index)
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]" %
240 (_index, self._numCells.x - 1, self._numCells.y - 1))
241 # We offset the index by numCellsInPatchBorder because the cells
242 # start outside the inner dimensions.
243 # The cells are defined relative to the patch bounding box (within the
244 # tract).
245 patchInnerBBox = self.getInnerBBox()
246 innerMin = Point2I(*[(_index[i] - self._numCellsInPatchBorder)*self._cellInnerDimensions[i]
247 + patchInnerBBox.getBegin()[i]
248 for i in range(2)])
249
250 innerBBox = Box2I(innerMin, self._cellInnerDimensions)
251 outerBBox = Box2I(innerBBox)
252 outerBBox.grow(self._cellBorder)
253
254 return CellInfo(
255 index=_index,
256 innerBBox=innerBBox,
257 outerBBox=outerBBox,
258 sequentialIndex=self.getSequentialCellIndexFromPair(_index),
259 tractWcs=self._wcs
260 )
261

◆ getCellInnerDimensions()

lsst.skymap.patchInfo.PatchInfo.getCellInnerDimensions ( self)
Get dimensions of inner region of the cells (all are the same)

Definition at line 262 of file patchInfo.py.

262 def getCellInnerDimensions(self):
263 """Get dimensions of inner region of the cells (all are the same)
264 """
265 return self._cellInnerDimensions
266

◆ getIndex()

lsst.skymap.patchInfo.PatchInfo.getIndex ( self)
Return patch index: a tuple of (x, y)

Returns
-------
result : `lsst.skymap.Index2D`
    Patch index (x, y).

Definition at line 89 of file patchInfo.py.

89 def getIndex(self):
90 """Return patch index: a tuple of (x, y)
91
92 Returns
93 -------
94 result : `lsst.skymap.Index2D`
95 Patch index (x, y).
96 """
97 return self._index
98

◆ getInnerBBox()

lsst.skymap.patchInfo.PatchInfo.getInnerBBox ( self)
Get inner bounding box.

Returns
-------
bbox : `lsst.geom.Box2I`
    The inner bounding Box.

Definition at line 125 of file patchInfo.py.

125 def getInnerBBox(self):
126 """Get inner bounding box.
127
128 Returns
129 -------
130 bbox : `lsst.geom.Box2I`
131 The inner bounding Box.
132 """
133 return self._innerBBox
134

◆ getInnerSkyPolygon()

lsst.skymap.patchInfo.PatchInfo.getInnerSkyPolygon ( self,
tractWcs = None )
Get the inner on-sky region.

Parameters
----------
tractWcs : `lsst.afw.image.SkyWcs`, optional
    WCS for the associated tract.

Returns
-------
result : `lsst.sphgeom.ConvexPolygon`
    The inner sky region.

Definition at line 149 of file patchInfo.py.

149 def getInnerSkyPolygon(self, tractWcs=None):
150 """Get the inner on-sky region.
151
152 Parameters
153 ----------
154 tractWcs : `lsst.afw.image.SkyWcs`, optional
155 WCS for the associated tract.
156
157 Returns
158 -------
159 result : `lsst.sphgeom.ConvexPolygon`
160 The inner sky region.
161 """
162 _tractWcs = tractWcs if tractWcs is not None else self._wcs
163 return makeSkyPolygonFromBBox(bbox=self.getInnerBBox(), wcs=_tractWcs)
164

◆ getNumCells()

lsst.skymap.patchInfo.PatchInfo.getNumCells ( self)
Get the number of cells in x, y.

May return (0, 0) if no cells are defined.

Returns
-------
result : `lsst.skymap.Index2D`
    The number of cells in x, y.

Definition at line 189 of file patchInfo.py.

189 def getNumCells(self):
190 """Get the number of cells in x, y.
191
192 May return (0, 0) if no cells are defined.
193
194 Returns
195 -------
196 result : `lsst.skymap.Index2D`
197 The number of cells in x, y.
198 """
199 return self._numCells
200

◆ getOuterBBox()

lsst.skymap.patchInfo.PatchInfo.getOuterBBox ( self)
Get outer bounding box.

Returns
-------
bbox : `lsst.geom.Box2I`
    The outer bounding Box.

Definition at line 137 of file patchInfo.py.

137 def getOuterBBox(self):
138 """Get outer bounding box.
139
140 Returns
141 -------
142 bbox : `lsst.geom.Box2I`
143 The outer bounding Box.
144 """
145 return self._outerBBox
146

◆ getOuterSkyPolygon()

lsst.skymap.patchInfo.PatchInfo.getOuterSkyPolygon ( self,
tractWcs = None )
Get the outer on-sky region.

Parameters
----------
tractWcs : `lsst.afw.image.SkyWcs`, optional
    WCS for the associated tract.

Returns
-------
result : `lsst.sphgeom.ConvexPolygon`
    The outer sky region.

Definition at line 169 of file patchInfo.py.

169 def getOuterSkyPolygon(self, tractWcs=None):
170 """Get the outer on-sky region.
171
172 Parameters
173 ----------
174 tractWcs : `lsst.afw.image.SkyWcs`, optional
175 WCS for the associated tract.
176
177 Returns
178 -------
179 result : `lsst.sphgeom.ConvexPolygon`
180 The outer sky region.
181 """
182 _tractWcs = tractWcs if tractWcs is not None else self._wcs
183 return makeSkyPolygonFromBBox(bbox=self.getOuterBBox(), wcs=_tractWcs)
184

◆ getSequentialCellIndex()

lsst.skymap.patchInfo.PatchInfo.getSequentialCellIndex ( self,
cellInfo )
Return a single integer that uniquely identifies
the given cell within this patch.

Parameters
----------
cellInfo : `lsst.skymap.CellInfo`

Returns
-------
sequentialIndex : `int`

Raises
------
IndexError
    Raised if index is out of range.

Definition at line 269 of file patchInfo.py.

269 def getSequentialCellIndex(self, cellInfo):
270 """Return a single integer that uniquely identifies
271 the given cell within this patch.
272
273 Parameters
274 ----------
275 cellInfo : `lsst.skymap.CellInfo`
276
277 Returns
278 -------
279 sequentialIndex : `int`
280
281 Raises
282 ------
283 IndexError
284 Raised if index is out of range.
285 """
286 index = cellInfo.getIndex()
287 return self.getSequentialCellIndexFromPair(index)
288

◆ getSequentialCellIndexFromPair()

lsst.skymap.patchInfo.PatchInfo.getSequentialCellIndexFromPair ( self,
index )
Return a single integer that uniquely identifies
the given cell within this patch.

Parameters
----------
index : `lsst.skymap.Index2D`

Returns
-------
sequentialIndex : `int`

Raises
------
IndexError
    Raised if index is out of range.

Definition at line 289 of file patchInfo.py.

289 def getSequentialCellIndexFromPair(self, index):
290 """Return a single integer that uniquely identifies
291 the given cell within this patch.
292
293 Parameters
294 ----------
295 index : `lsst.skymap.Index2D`
296
297 Returns
298 -------
299 sequentialIndex : `int`
300
301 Raises
302 ------
303 IndexError
304 Raised if index is out of range.
305 """
306 if isinstance(index, Index2D):
307 _index = index
308 else:
309 _index = Index2D(*index)
310 nx, ny = self.getNumCells()
311 return nx*_index.y + _index.x
312

◆ getSequentialIndex()

lsst.skymap.patchInfo.PatchInfo.getSequentialIndex ( self)
Return patch sequential index.

Returns
-------
result : `int`
    Sequential patch index.

Definition at line 101 of file patchInfo.py.

101 def getSequentialIndex(self):
102 """Return patch sequential index.
103
104 Returns
105 -------
106 result : `int`
107 Sequential patch index.
108 """
109 return self._sequentialIndex
110

◆ getWcs()

lsst.skymap.patchInfo.PatchInfo.getWcs ( self)
Return the associated tract wcs

Returns
-------
wcs : `lsst.afw.geom.SkyWcs`
    Tract WCS.

Definition at line 113 of file patchInfo.py.

113 def getWcs(self):
114 """Return the associated tract wcs
115
116 Returns
117 -------
118 wcs : `lsst.afw.geom.SkyWcs`
119 Tract WCS.
120 """
121 return self._wcs
122

◆ inner_sky_polygon()

lsst.skymap.patchInfo.PatchInfo.inner_sky_polygon ( self)

Definition at line 166 of file patchInfo.py.

166 def inner_sky_polygon(self):
167 return self.getInnerSkyPolygon()
168

◆ outer_sky_polygon()

lsst.skymap.patchInfo.PatchInfo.outer_sky_polygon ( self)

Definition at line 186 of file patchInfo.py.

186 def outer_sky_polygon(self):
187 return self.getOuterSkyPolygon()
188

Member Data Documentation

◆ _cellBorder

lsst.skymap.patchInfo.PatchInfo._cellBorder
protected

Definition at line 80 of file patchInfo.py.

◆ _cellInnerDimensions

lsst.skymap.patchInfo.PatchInfo._cellInnerDimensions
protected

Definition at line 79 of file patchInfo.py.

◆ _index

lsst.skymap.patchInfo.PatchInfo._index
protected

Definition at line 68 of file patchInfo.py.

◆ _innerBBox

lsst.skymap.patchInfo.PatchInfo._innerBBox
protected

Definition at line 70 of file patchInfo.py.

◆ _numCells

lsst.skymap.patchInfo.PatchInfo._numCells
protected

Definition at line 83 of file patchInfo.py.

◆ _numCellsInPatchBorder

lsst.skymap.patchInfo.PatchInfo._numCellsInPatchBorder
protected

Definition at line 81 of file patchInfo.py.

◆ _outerBBox

lsst.skymap.patchInfo.PatchInfo._outerBBox
protected

Definition at line 71 of file patchInfo.py.

◆ _sequentialIndex

lsst.skymap.patchInfo.PatchInfo._sequentialIndex
protected

Definition at line 69 of file patchInfo.py.

◆ _wcs

lsst.skymap.patchInfo.PatchInfo._wcs
protected

Definition at line 72 of file patchInfo.py.

Property Documentation

◆ cell_border

lsst.skymap.patchInfo.PatchInfo.cell_border = property(getCellBorder)
static

Definition at line 206 of file patchInfo.py.

◆ cell_inner_dimensions

lsst.skymap.patchInfo.PatchInfo.cell_inner_dimensions = property(getCellInnerDimensions)
static

Definition at line 267 of file patchInfo.py.

◆ index

lsst.skymap.patchInfo.PatchInfo.index = property(getIndex)
static

Definition at line 99 of file patchInfo.py.

◆ inner_bbox

lsst.skymap.patchInfo.PatchInfo.inner_bbox = property(getInnerBBox)
static

Definition at line 135 of file patchInfo.py.

◆ num_cells

lsst.skymap.patchInfo.PatchInfo.num_cells = property(getNumCells)
static

Definition at line 201 of file patchInfo.py.

◆ outer_bbox

lsst.skymap.patchInfo.PatchInfo.outer_bbox = property(getOuterBBox)
static

Definition at line 147 of file patchInfo.py.

◆ sequential_index

lsst.skymap.patchInfo.PatchInfo.sequential_index = property(getSequentialIndex)
static

Definition at line 111 of file patchInfo.py.

◆ wcs

lsst.skymap.patchInfo.PatchInfo.wcs = property(getWcs)
static

Definition at line 123 of file patchInfo.py.


The documentation for this class was generated from the following file: