LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
LSST Data Management Base Package
Public Member Functions | List of all members
lsst.skymap.tractInfo.ExplicitTractInfo Class Reference
Inheritance diagram for lsst.skymap.tractInfo.ExplicitTractInfo:
lsst.skymap.tractInfo.TractInfo

Public Member Functions

def __init__ (self, ident, patchInnerDimensions, patchBorder, ctrCoord, radius, tractOverlap, wcs)
 
def getSequentialPatchIndex (self, patchInfo)
 
def getPatchIndexPair (self, sequentialIndex)
 
def findPatch (self, coord)
 
def findPatchList (self, coordList)
 
def getBBox (self)
 
def getCtrCoord (self)
 
def getId (self)
 
def getNumPatches (self)
 
def getPatchBorder (self)
 
def getPatchInfo (self, index)
 
def getPatchInnerDimensions (self)
 
def getTractOverlap (self)
 
def getVertexList (self)
 
def getInnerSkyPolygon (self)
 
def getOuterSkyPolygon (self)
 
def getWcs (self)
 
def __str__ (self)
 
def __repr__ (self)
 
def __iter__ (self)
 
def __len__ (self)
 
def __getitem__ (self, index)
 
def contains (self, coord)
 

Detailed Description

Information for a tract specified explicitly.

A tract is placed at the explicitly defined coordinates, with the nominated
radius.  The tracts are square (i.e., the radius is really a half-size).

Definition at line 418 of file tractInfo.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.skymap.tractInfo.ExplicitTractInfo.__init__ (   self,
  ident,
  patchInnerDimensions,
  patchBorder,
  ctrCoord,
  radius,
  tractOverlap,
  wcs 
)

Reimplemented from lsst.skymap.tractInfo.TractInfo.

Definition at line 425 of file tractInfo.py.

425  def __init__(self, ident, patchInnerDimensions, patchBorder, ctrCoord, radius, tractOverlap, wcs):
426  # We don't want TractInfo setting the bbox on the basis of vertices, but on the radius.
427  vertexList = []
428  self._radius = radius
429  super(ExplicitTractInfo, self).__init__(ident, patchInnerDimensions, patchBorder, ctrCoord,
430  vertexList, tractOverlap, wcs)
431  # Shrink the box slightly to make sure the vertices are in the tract
432  bboxD = geom.BoxD(self.getBBox())
433  bboxD.grow(-0.001)
434  finalWcs = self.getWcs()
435  self._vertexCoordList = finalWcs.pixelToSky(bboxD.getCorners())
436 
A floating-point coordinate rectangle geometry.
Definition: Box.h:413

Member Function Documentation

◆ __getitem__()

def lsst.skymap.tractInfo.TractInfo.__getitem__ (   self,
  index 
)
inherited

Definition at line 405 of file tractInfo.py.

405  def __getitem__(self, index):
406  return self.getPatchInfo(index)
407 

◆ __iter__()

def lsst.skymap.tractInfo.TractInfo.__iter__ (   self)
inherited

Definition at line 395 of file tractInfo.py.

395  def __iter__(self):
396  xNum, yNum = self.getNumPatches()
397  for y in range(yNum):
398  for x in range(xNum):
399  yield self.getPatchInfo((x, y))
400 

◆ __len__()

def lsst.skymap.tractInfo.TractInfo.__len__ (   self)
inherited

Definition at line 401 of file tractInfo.py.

401  def __len__(self):
402  xNum, yNum = self.getNumPatches()
403  return xNum*yNum
404 

◆ __repr__()

def lsst.skymap.tractInfo.TractInfo.__repr__ (   self)
inherited

Definition at line 392 of file tractInfo.py.

392  def __repr__(self):
393  return "TractInfo(id=%s, ctrCoord=%s)" % (self._id, self._ctrCoord.getVector())
394 

◆ __str__()

def lsst.skymap.tractInfo.TractInfo.__str__ (   self)
inherited

Definition at line 389 of file tractInfo.py.

389  def __str__(self):
390  return "TractInfo(id=%s)" % (self._id,)
391 

◆ contains()

def lsst.skymap.tractInfo.TractInfo.contains (   self,
  coord 
)
inherited
Does this tract contain the coordinate?

Definition at line 408 of file tractInfo.py.

408  def contains(self, coord):
409  """Does this tract contain the coordinate?"""
410  try:
411  pixels = self.getWcs().skyToPixel(coord)
413  # Point must be way off the tract
414  return False
415  return self.getBBox().contains(geom.Point2I(pixels))
416 
417 
Reports arguments outside the domain of an operation.
Definition: Runtime.h:57
Reports errors that are due to events beyond the control of the program.
Definition: Runtime.h:104

◆ findPatch()

def lsst.skymap.tractInfo.TractInfo.findPatch (   self,
  coord 
)
inherited
Find the patch containing the specified coord.

Parameters
----------
coord : `lsst.geom.SpherePoint`
    ICRS sky coordinate to search for.

Returns
-------
result : `lsst.skymap.PatchInfo`
    PatchInfo of patch whose inner bbox contains the specified coord

Raises
------
LookupError
    If coord is not in tract or we cannot determine the
    pixel coordinate (which likely means the coord is off the tract).

Definition at line 203 of file tractInfo.py.

203  def findPatch(self, coord):
204  """Find the patch containing the specified coord.
205 
206  Parameters
207  ----------
208  coord : `lsst.geom.SpherePoint`
209  ICRS sky coordinate to search for.
210 
211  Returns
212  -------
213  result : `lsst.skymap.PatchInfo`
214  PatchInfo of patch whose inner bbox contains the specified coord
215 
216  Raises
217  ------
218  LookupError
219  If coord is not in tract or we cannot determine the
220  pixel coordinate (which likely means the coord is off the tract).
221  """
222  try:
223  pixel = self.getWcs().skyToPixel(coord)
225  # Point must be way off the tract
226  raise LookupError("Unable to determine pixel position for coordinate %s" % (coord,))
227  pixelInd = geom.Point2I(pixel)
228  if not self.getBBox().contains(pixelInd):
229  raise LookupError("coord %s is not in tract %s" % (coord, self.getId()))
230  patchInd = tuple(int(pixelInd[i]/self._patchInnerDimensions[i]) for i in range(2))
231  return self.getPatchInfo(patchInd)
232 

◆ findPatchList()

def lsst.skymap.tractInfo.TractInfo.findPatchList (   self,
  coordList 
)
inherited
Find patches containing the specified list of coords.

Parameters
----------
coordList : `list` of `lsst.geom.SpherePoint`
    ICRS sky coordinates to search for.

Returns
-------
result : `list` of `lsst.skymap.PatchInfo`
    List of PatchInfo for patches that contain, or may contain, the
    specified region. The list will be empty if there is no overlap.

Notes
-----
**Warning:**

- This may give incorrect answers on regions that are larger than a
  tract.

- This uses a naive algorithm that may find some patches that do not
  overlap the region (especially if the region is not a rectangle
  aligned along patch x,y).

Definition at line 233 of file tractInfo.py.

233  def findPatchList(self, coordList):
234  """Find patches containing the specified list of coords.
235 
236  Parameters
237  ----------
238  coordList : `list` of `lsst.geom.SpherePoint`
239  ICRS sky coordinates to search for.
240 
241  Returns
242  -------
243  result : `list` of `lsst.skymap.PatchInfo`
244  List of PatchInfo for patches that contain, or may contain, the
245  specified region. The list will be empty if there is no overlap.
246 
247  Notes
248  -----
249  **Warning:**
250 
251  - This may give incorrect answers on regions that are larger than a
252  tract.
253 
254  - This uses a naive algorithm that may find some patches that do not
255  overlap the region (especially if the region is not a rectangle
256  aligned along patch x,y).
257  """
258  box2D = geom.Box2D()
259  for coord in coordList:
260  try:
261  pixelPos = self.getWcs().skyToPixel(coord)
263  # the point is so far off the tract that its pixel position cannot be computed
264  continue
265  box2D.include(pixelPos)
266  bbox = geom.Box2I(box2D)
267  bbox.grow(self.getPatchBorder())
268  bbox.clip(self.getBBox())
269  if bbox.isEmpty():
270  return ()
271 
272  llPatchInd = tuple(int(bbox.getMin()[i]/self._patchInnerDimensions[i]) for i in range(2))
273  urPatchInd = tuple(int(bbox.getMax()[i]/self._patchInnerDimensions[i]) for i in range(2))
274  return tuple(self.getPatchInfo((xInd, yInd))
275  for xInd in range(llPatchInd[0], urPatchInd[0]+1)
276  for yInd in range(llPatchInd[1], urPatchInd[1]+1))
277 
An integer coordinate rectangle.
Definition: Box.h:55

◆ getBBox()

def lsst.skymap.tractInfo.TractInfo.getBBox (   self)
inherited
Get bounding box of tract (as an geom.Box2I)

Definition at line 278 of file tractInfo.py.

278  def getBBox(self):
279  """Get bounding box of tract (as an geom.Box2I)
280  """
281  return geom.Box2I(self._bbox)
282 

◆ getCtrCoord()

def lsst.skymap.tractInfo.TractInfo.getCtrCoord (   self)
inherited
Get ICRS sky coordinate of center of tract
(as an lsst.geom.SpherePoint)

Definition at line 283 of file tractInfo.py.

283  def getCtrCoord(self):
284  """Get ICRS sky coordinate of center of tract
285  (as an lsst.geom.SpherePoint)
286  """
287  return self._ctrCoord
288 

◆ getId()

def lsst.skymap.tractInfo.TractInfo.getId (   self)
inherited
Get ID of tract

Definition at line 289 of file tractInfo.py.

289  def getId(self):
290  """Get ID of tract
291  """
292  return self._id
293 

◆ getInnerSkyPolygon()

def lsst.skymap.tractInfo.TractInfo.getInnerSkyPolygon (   self)
inherited
Get inner on-sky region as a sphgeom.ConvexPolygon.

Definition at line 368 of file tractInfo.py.

368  def getInnerSkyPolygon(self):
369  """Get inner on-sky region as a sphgeom.ConvexPolygon.
370  """
371  skyUnitVectors = [sp.getVector() for sp in self.getVertexList()]
372  return ConvexPolygon.convexHull(skyUnitVectors)
373 

◆ getNumPatches()

def lsst.skymap.tractInfo.TractInfo.getNumPatches (   self)
inherited
Get the number of patches in x, y.

Returns
-------
result : `tuple` of `int`
    The number of patches in x, y

Definition at line 294 of file tractInfo.py.

294  def getNumPatches(self):
295  """Get the number of patches in x, y.
296 
297  Returns
298  -------
299  result : `tuple` of `int`
300  The number of patches in x, y
301  """
302  return self._numPatches
303 

◆ getOuterSkyPolygon()

def lsst.skymap.tractInfo.TractInfo.getOuterSkyPolygon (   self)
inherited
Get outer on-sky region as a sphgeom.ConvexPolygon

Definition at line 374 of file tractInfo.py.

374  def getOuterSkyPolygon(self):
375  """Get outer on-sky region as a sphgeom.ConvexPolygon
376  """
377  return makeSkyPolygonFromBBox(bbox=self.getBBox(), wcs=self.getWcs())
378 
def makeSkyPolygonFromBBox(bbox, wcs)
Definition: patchInfo.py:29

◆ getPatchBorder()

def lsst.skymap.tractInfo.TractInfo.getPatchBorder (   self)
inherited

Definition at line 304 of file tractInfo.py.

304  def getPatchBorder(self):
305  return self._patchBorder
306 

◆ getPatchIndexPair()

def lsst.skymap.tractInfo.TractInfo.getPatchIndexPair (   self,
  sequentialIndex 
)
inherited

Definition at line 197 of file tractInfo.py.

197  def getPatchIndexPair(self, sequentialIndex):
198  nx, ny = self.getNumPatches()
199  x = sequentialIndex % nx
200  y = (sequentialIndex - x) // nx
201  return (x, y)
202 

◆ getPatchInfo()

def lsst.skymap.tractInfo.TractInfo.getPatchInfo (   self,
  index 
)
inherited
Return information for the specified patch.

Parameters
----------
index : `tuple` of `int`
    Index of patch, as a pair of ints;
    or a sequential index as returned by getSequentialPatchIndex;
    negative values are not supported.

Returns
-------
result : `lsst.skymap.PatchInfo`
    The patch info for that index.

Raises
------
IndexError
    If index is out of range.

Definition at line 307 of file tractInfo.py.

307  def getPatchInfo(self, index):
308  """Return information for the specified patch.
309 
310  Parameters
311  ----------
312  index : `tuple` of `int`
313  Index of patch, as a pair of ints;
314  or a sequential index as returned by getSequentialPatchIndex;
315  negative values are not supported.
316 
317  Returns
318  -------
319  result : `lsst.skymap.PatchInfo`
320  The patch info for that index.
321 
322  Raises
323  ------
324  IndexError
325  If index is out of range.
326  """
327  if isinstance(index, numbers.Number):
328  index = self.getPatchIndexPair(index)
329  if (not 0 <= index[0] < self._numPatches[0]) \
330  or (not 0 <= index[1] < self._numPatches[1]):
331  raise IndexError("Patch index %s is not in range [0-%d, 0-%d]" %
332  (index, self._numPatches[0]-1, self._numPatches[1]-1))
333  innerMin = geom.Point2I(*[index[i] * self._patchInnerDimensions[i] for i in range(2)])
334  innerBBox = geom.Box2I(innerMin, self._patchInnerDimensions)
335  if not self._bbox.contains(innerBBox):
336  raise RuntimeError(
337  "Bug: patch index %s valid but inner bbox=%s not contained in tract bbox=%s" %
338  (index, innerBBox, self._bbox))
339  outerBBox = geom.Box2I(innerBBox)
340  outerBBox.grow(self.getPatchBorder())
341  outerBBox.clip(self._bbox)
342  return PatchInfo(
343  index=index,
344  innerBBox=innerBBox,
345  outerBBox=outerBBox,
346  )
347 

◆ getPatchInnerDimensions()

def lsst.skymap.tractInfo.TractInfo.getPatchInnerDimensions (   self)
inherited
Get dimensions of inner region of the patches (all are the same)

Definition at line 348 of file tractInfo.py.

348  def getPatchInnerDimensions(self):
349  """Get dimensions of inner region of the patches (all are the same)
350  """
351  return self._patchInnerDimensions
352 

◆ getSequentialPatchIndex()

def lsst.skymap.tractInfo.TractInfo.getSequentialPatchIndex (   self,
  patchInfo 
)
inherited
Return a single integer that uniquely identifies the given patch
within this tract.

Definition at line 189 of file tractInfo.py.

189  def getSequentialPatchIndex(self, patchInfo):
190  """Return a single integer that uniquely identifies the given patch
191  within this tract.
192  """
193  x, y = patchInfo.getIndex()
194  nx, ny = self.getNumPatches()
195  return nx*y + x
196 

◆ getTractOverlap()

def lsst.skymap.tractInfo.TractInfo.getTractOverlap (   self)
inherited
Get minimum overlap of adjacent sky tracts.

Definition at line 353 of file tractInfo.py.

353  def getTractOverlap(self):
354  """Get minimum overlap of adjacent sky tracts.
355  """
356  return self._tractOverlap
357 

◆ getVertexList()

def lsst.skymap.tractInfo.TractInfo.getVertexList (   self)
inherited
Get list of ICRS sky coordinates of vertices that define the
boundary of the inner region.

Notes
-----
**warning:** this is not a deep copy.

Definition at line 358 of file tractInfo.py.

358  def getVertexList(self):
359  """Get list of ICRS sky coordinates of vertices that define the
360  boundary of the inner region.
361 
362  Notes
363  -----
364  **warning:** this is not a deep copy.
365  """
366  return self._vertexCoordList
367 

◆ getWcs()

def lsst.skymap.tractInfo.TractInfo.getWcs (   self)
inherited
Get WCS of tract.

Returns
-------
wcs : `lsst.afw.geom.SkyWcs`
    The WCS of this tract

Definition at line 379 of file tractInfo.py.

379  def getWcs(self):
380  """Get WCS of tract.
381 
382  Returns
383  -------
384  wcs : `lsst.afw.geom.SkyWcs`
385  The WCS of this tract
386  """
387  return self._wcs
388 

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