LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | Properties | List of all members
lsst.skymap.patchInfo.PatchInfo Class Reference

Public Member Functions

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

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 : `Iterable` [`int`, `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__()

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

Definition at line 63 of file patchInfo.py.

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

Member Function Documentation

◆ __eq__()

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

Definition at line 348 of file patchInfo.py.

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

◆ __getitem__()

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

Definition at line 345 of file patchInfo.py.

345  def __getitem__(self, index):
346  return self.getCellInfo(index)
347 

◆ __iter__()

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

Definition at line 335 of file patchInfo.py.

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

◆ __len__()

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

Definition at line 341 of file patchInfo.py.

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

◆ __ne__()

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

Definition at line 355 of file patchInfo.py.

355  def __ne__(self, rhs):
356  return not self.__eq__(rhs)
357 

◆ __repr__()

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

Definition at line 361 of file patchInfo.py.

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

◆ __str__()

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

Definition at line 358 of file patchInfo.py.

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

◆ getCellBorder()

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

Definition at line 202 of file patchInfo.py.

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

◆ getCellIndexPair()

def 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
    If index is out of range.

Definition at line 311 of file patchInfo.py.

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

◆ getCellInfo()

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

Parameters
----------
index : `lsst.skymap.Index2D` or `int`
    Index of cell, as `Index2D`, or `Iterable` [`int`, `int`];
    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
    If index is out of range.

Definition at line 207 of file patchInfo.py.

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

◆ getCellInnerDimensions()

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

Definition at line 260 of file patchInfo.py.

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

◆ getIndex()

def 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 88 of file patchInfo.py.

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

◆ getInnerBBox()

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

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

Definition at line 124 of file patchInfo.py.

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

◆ getInnerSkyPolygon()

def 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 148 of file patchInfo.py.

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

◆ getNumCells()

def 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 188 of file patchInfo.py.

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

◆ getOuterBBox()

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

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

Definition at line 136 of file patchInfo.py.

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

◆ getOuterSkyPolygon()

def 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 168 of file patchInfo.py.

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

◆ getSequentialCellIndex()

def 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
    If index is out of range.

Definition at line 267 of file patchInfo.py.

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

◆ getSequentialCellIndexFromPair()

def 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
    If index is out of range.

Definition at line 287 of file patchInfo.py.

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

◆ getSequentialIndex()

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

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

Definition at line 100 of file patchInfo.py.

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

◆ getWcs()

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

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

Definition at line 112 of file patchInfo.py.

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

◆ inner_sky_polygon()

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

Definition at line 165 of file patchInfo.py.

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

◆ outer_sky_polygon()

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

Definition at line 185 of file patchInfo.py.

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

Property Documentation

◆ cell_border

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

Definition at line 205 of file patchInfo.py.

◆ cell_inner_dimensions

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

Definition at line 265 of file patchInfo.py.

◆ index

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

Definition at line 98 of file patchInfo.py.

◆ inner_bbox

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

Definition at line 134 of file patchInfo.py.

◆ num_cells

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

Definition at line 200 of file patchInfo.py.

◆ outer_bbox

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

Definition at line 146 of file patchInfo.py.

◆ sequential_index

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

Definition at line 110 of file patchInfo.py.

◆ wcs

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

Definition at line 122 of file patchInfo.py.


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