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.tractInfo.TractInfo Class Reference
Inheritance diagram for lsst.skymap.tractInfo.TractInfo:
lsst.skymap.healpixSkyMap.HealpixTractInfo lsst.skymap.tractInfo.ExplicitTractInfo

Public Member Functions

def __init__ (self, id, tractBuilder, ctrCoord, vertexCoordList, tractOverlap, wcs)
 
def getSequentialPatchIndex (self, patchInfo)
 
def getSequentialPatchIndexFromPair (self, index)
 
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)
 

Properties

 bbox = property(getBBox)
 
 ctr_coord = property(getCtrCoord)
 
 tract_id = property(getId)
 
 num_patches = property(getNumPatches)
 
 patch_border = property(getPatchBorder)
 
 patch_inner_dimensions = property(getPatchInnerDimensions)
 
 tract_overlap = property(getTractOverlap)
 
 vertex_list = property(getVertexList)
 
 inner_sky_polygon = property(getInnerSkyPolygon)
 
 outer_sky_polygon = property(getOuterSkyPolygon)
 
 wcs = property(getWcs)
 

Detailed Description

Information about a tract in a SkyMap sky pixelization

Parameters
----------
id : `int`
    tract ID
tractBuilder : Subclass of `lsst.skymap.BaseTractBuilder`
    Object used to compute patch geometry.
ctrCoord : `lsst.geom.SpherePoint`
    ICRS sky coordinate of center of inner region of tract; also used as
    the CRVAL for the WCS.
vertexCoordList : `list` of `lsst.geom.SpherePoint`
    Vertices that define the boundaries of the inner region.
tractOverlap : `lsst.geom.Angle`
    Minimum overlap between adjacent sky tracts; this defines the minimum
    distance the tract extends beyond the inner region in all directions.
wcs : `lsst.afw.image.SkyWcs`
    WCS for tract. The reference pixel will be shifted as required so that
    the lower left-hand pixel (index 0,0) has pixel position 0.0, 0.0.

Notes
-----
The tract is subdivided into rectangular patches. Each patch has the
following properties:

- An inner region defined by an inner bounding box. The inner regions of
  the patches exactly tile the tract, and all inner regions have the same
  dimensions. The tract is made larger as required to make this work.

- An outer region defined by an outer bounding box. The outer region
  extends beyond the inner region by patchBorder pixels in all directions,
  except there is no border at the edges of the tract.
  Thus patches overlap each other but never extend off the tract.
  If you do not want any overlap between adjacent patches then set
  patchBorder to 0.

- An index that consists of a pair of integers:

  * 0 <= x index < numPatches[0]

  * 0 <= y index < numPatches[1]

  Patch 0,0 is at the minimum corner of the tract bounding box.

- It is not enforced that ctrCoord is the center of vertexCoordList, but
  SkyMap relies on it.

Definition at line 34 of file tractInfo.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.skymap.tractInfo.TractInfo.__init__ (   self,
  id,
  tractBuilder,
  ctrCoord,
  vertexCoordList,
  tractOverlap,
  wcs 
)

Reimplemented in lsst.skymap.tractInfo.ExplicitTractInfo.

Definition at line 82 of file tractInfo.py.

82  def __init__(self, id, tractBuilder, ctrCoord, vertexCoordList, tractOverlap, wcs):
83  self._id = id
84  self._ctrCoord = ctrCoord
85  self._vertexCoordList = tuple(vertexCoordList)
86  self._tractOverlap = tractOverlap
87  self._tractBuilder = tractBuilder
88 
89  minBBox = self._minimumBoundingBox(wcs)
90  initialBBox, self._numPatches = self._tractBuilder.setupPatches(minBBox, wcs)
91  self._bbox, self._wcs = self._finalOrientation(initialBBox, wcs)
92 

Member Function Documentation

◆ __getitem__()

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

Definition at line 393 of file tractInfo.py.

393  def __getitem__(self, index):
394  return self.getPatchInfo(index)
395 

◆ __iter__()

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

Definition at line 383 of file tractInfo.py.

383  def __iter__(self):
384  xNum, yNum = self.getNumPatches()
385  for y in range(yNum):
386  for x in range(xNum):
387  yield self.getPatchInfo(Index2D(x=x, y=y))
388 

◆ __len__()

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

Definition at line 389 of file tractInfo.py.

389  def __len__(self):
390  xNum, yNum = self.getNumPatches()
391  return xNum*yNum
392 

◆ __repr__()

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

Definition at line 380 of file tractInfo.py.

380  def __repr__(self):
381  return "TractInfo(id=%s, ctrCoord=%s)" % (self._id, self._ctrCoord.getVector())
382 

◆ __str__()

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

Definition at line 377 of file tractInfo.py.

377  def __str__(self):
378  return "TractInfo(id=%s)" % (self._id,)
379 

◆ contains()

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

Definition at line 396 of file tractInfo.py.

396  def contains(self, coord):
397  """Does this tract contain the coordinate?"""
398  try:
399  pixel = self.getWcs().skyToPixel(coord)
401  # Point must be way off the tract
402  return False
403  if not np.isfinite(pixel.getX()) or not np.isfinite(pixel.getY()):
404  # Point is definitely off the tract
405  return False
406  return self.getBBox().contains(geom.Point2I(pixel))
407 
408 
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 
)
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 186 of file tractInfo.py.

186  def findPatch(self, coord):
187  """Find the patch containing the specified coord.
188 
189  Parameters
190  ----------
191  coord : `lsst.geom.SpherePoint`
192  ICRS sky coordinate to search for.
193 
194  Returns
195  -------
196  result : `lsst.skymap.PatchInfo`
197  PatchInfo of patch whose inner bbox contains the specified coord
198 
199  Raises
200  ------
201  LookupError
202  If coord is not in tract or we cannot determine the
203  pixel coordinate (which likely means the coord is off the tract).
204  """
205  try:
206  pixel = self.wcs.skyToPixel(coord)
208  # Point must be way off the tract
209  raise LookupError("Unable to determine pixel position for coordinate %s" % (coord,))
210  pixelInd = geom.Point2I(pixel)
211  if not self._bbox.contains(pixelInd):
212  raise LookupError("coord %s is not in tract %s" % (coord, self.tract_id))
213  # This should probably be the same as above because we only
214  # care about the INNER dimensions.
215  patchInd = tuple(int(pixelInd[i]/self.patch_inner_dimensions[i]) for i in range(2))
216  return self.getPatchInfo(patchInd)
217 

◆ findPatchList()

def lsst.skymap.tractInfo.TractInfo.findPatchList (   self,
  coordList 
)
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 218 of file tractInfo.py.

218  def findPatchList(self, coordList):
219  """Find patches containing the specified list of coords.
220 
221  Parameters
222  ----------
223  coordList : `list` of `lsst.geom.SpherePoint`
224  ICRS sky coordinates to search for.
225 
226  Returns
227  -------
228  result : `list` of `lsst.skymap.PatchInfo`
229  List of PatchInfo for patches that contain, or may contain, the
230  specified region. The list will be empty if there is no overlap.
231 
232  Notes
233  -----
234  **Warning:**
235 
236  - This may give incorrect answers on regions that are larger than a
237  tract.
238 
239  - This uses a naive algorithm that may find some patches that do not
240  overlap the region (especially if the region is not a rectangle
241  aligned along patch x,y).
242  """
243  box2D = geom.Box2D()
244  for coord in coordList:
245  try:
246  pixelPos = self.wcs.skyToPixel(coord)
248  # the point is so far off the tract that its pixel position cannot be computed
249  continue
250  box2D.include(pixelPos)
251  bbox = geom.Box2I(box2D)
252  bbox.grow(self.getPatchBorder())
253  bbox.clip(self._bbox)
254  if bbox.isEmpty():
255  return ()
256 
257  llPatchInd = tuple(int(bbox.getMin()[i]/self.patch_inner_dimensions[i]) for i in range(2))
258  urPatchInd = tuple(int(bbox.getMax()[i]/self.patch_inner_dimensions[i]) for i in range(2))
259  return tuple(self.getPatchInfo((xInd, yInd))
260  for xInd in range(llPatchInd[0], urPatchInd[0]+1)
261  for yInd in range(llPatchInd[1], urPatchInd[1]+1))
262 
A floating-point coordinate rectangle geometry.
Definition: Box.h:413
An integer coordinate rectangle.
Definition: Box.h:55

◆ getBBox()

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

Definition at line 263 of file tractInfo.py.

263  def getBBox(self):
264  """Get bounding box of tract (as an geom.Box2I)
265  """
266  return geom.Box2I(self._bbox)
267 

◆ getCtrCoord()

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

Definition at line 270 of file tractInfo.py.

270  def getCtrCoord(self):
271  """Get ICRS sky coordinate of center of tract
272  (as an lsst.geom.SpherePoint)
273  """
274  return self._ctrCoord
275 

◆ getId()

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

Definition at line 278 of file tractInfo.py.

278  def getId(self):
279  """Get ID of tract
280  """
281  return self._id
282 

◆ getInnerSkyPolygon()

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

Definition at line 350 of file tractInfo.py.

350  def getInnerSkyPolygon(self):
351  """Get inner on-sky region as a sphgeom.ConvexPolygon.
352  """
353  skyUnitVectors = [sp.getVector() for sp in self.getVertexList()]
354  return ConvexPolygon.convexHull(skyUnitVectors)
355 

◆ getNumPatches()

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

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

Definition at line 285 of file tractInfo.py.

285  def getNumPatches(self):
286  """Get the number of patches in x, y.
287 
288  Returns
289  -------
290  result : `lsst.skymap.Index2D`
291  The number of patches in x, y
292  """
293  return self._numPatches
294 

◆ getOuterSkyPolygon()

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

Definition at line 358 of file tractInfo.py.

358  def getOuterSkyPolygon(self):
359  """Get outer on-sky region as a sphgeom.ConvexPolygon
360  """
361  return makeSkyPolygonFromBBox(bbox=self.getBBox(), wcs=self.getWcs())
362 
def makeSkyPolygonFromBBox(bbox, wcs)
Definition: utils.py:61

◆ getPatchBorder()

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

Definition at line 297 of file tractInfo.py.

297  def getPatchBorder(self):
298  return self._tractBuilder.getPatchBorder()
299 

◆ getPatchIndexPair()

def lsst.skymap.tractInfo.TractInfo.getPatchIndexPair (   self,
  sequentialIndex 
)
Convert sequential index into patch index (x,y) pair.

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

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

Definition at line 173 of file tractInfo.py.

173  def getPatchIndexPair(self, sequentialIndex):
174  """Convert sequential index into patch index (x,y) pair.
175 
176  Parameters
177  ----------
178  sequentialIndex : `int`
179 
180  Returns
181  -------
182  x, y : `lsst.skymap.Index2D`
183  """
184  return self._tractBuilder.getPatchIndexPair(sequentialIndex)
185 

◆ getPatchInfo()

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

Parameters
----------
index : `typing.NamedTuple` ['x': `int`, 'y': `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 302 of file tractInfo.py.

302  def getPatchInfo(self, index):
303  """Return information for the specified patch.
304 
305  Parameters
306  ----------
307  index : `typing.NamedTuple` ['x': `int`, 'y': `int`]
308  Index of patch, as a pair of ints;
309  or a sequential index as returned by getSequentialPatchIndex;
310  negative values are not supported.
311 
312  Returns
313  -------
314  result : `lsst.skymap.PatchInfo`
315  The patch info for that index.
316 
317  Raises
318  ------
319  IndexError
320  If index is out of range.
321  """
322  return self._tractBuilder.getPatchInfo(index, self._wcs)
323 

◆ getPatchInnerDimensions()

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

Definition at line 324 of file tractInfo.py.

324  def getPatchInnerDimensions(self):
325  """Get dimensions of inner region of the patches (all are the same)
326  """
327  return self._tractBuilder.getPatchInnerDimensions()
328 

◆ getSequentialPatchIndex()

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

Parameters
----------
patchInfo : `lsst.skymap.PatchInfo`

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

Definition at line 145 of file tractInfo.py.

145  def getSequentialPatchIndex(self, patchInfo):
146  """Return a single integer that uniquely identifies
147  the given patch within this tract.
148 
149  Parameters
150  ----------
151  patchInfo : `lsst.skymap.PatchInfo`
152 
153  Returns
154  -------
155  sequentialIndex : `int`
156  """
157  return self._tractBuilder.getSequentialPatchIndex(patchInfo)
158 

◆ getSequentialPatchIndexFromPair()

def lsst.skymap.tractInfo.TractInfo.getSequentialPatchIndexFromPair (   self,
  index 
)
Return a single integer that uniquely identifies
the patch index within the tract.

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

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

Definition at line 159 of file tractInfo.py.

159  def getSequentialPatchIndexFromPair(self, index):
160  """Return a single integer that uniquely identifies
161  the patch index within the tract.
162 
163  Parameters
164  ----------
165  index : `lsst.skymap.Index2D`
166 
167  Returns
168  -------
169  sequentialIndex : `int`
170  """
171  return self._tractBuilder.getSequentialPatchIndexFromPair(index)
172 

◆ getTractOverlap()

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

Definition at line 331 of file tractInfo.py.

331  def getTractOverlap(self):
332  """Get minimum overlap of adjacent sky tracts.
333  """
334  return self._tractOverlap
335 

◆ getVertexList()

def lsst.skymap.tractInfo.TractInfo.getVertexList (   self)
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 338 of file tractInfo.py.

338  def getVertexList(self):
339  """Get list of ICRS sky coordinates of vertices that define the
340  boundary of the inner region.
341 
342  Notes
343  -----
344  **warning:** this is not a deep copy.
345  """
346  return self._vertexCoordList
347 

◆ getWcs()

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

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

Definition at line 365 of file tractInfo.py.

365  def getWcs(self):
366  """Get WCS of tract.
367 
368  Returns
369  -------
370  wcs : `lsst.afw.geom.SkyWcs`
371  The WCS of this tract
372  """
373  return self._wcs
374 

Property Documentation

◆ bbox

lsst.skymap.tractInfo.TractInfo.bbox = property(getBBox)
static

Definition at line 268 of file tractInfo.py.

◆ ctr_coord

lsst.skymap.tractInfo.TractInfo.ctr_coord = property(getCtrCoord)
static

Definition at line 276 of file tractInfo.py.

◆ inner_sky_polygon

lsst.skymap.tractInfo.TractInfo.inner_sky_polygon = property(getInnerSkyPolygon)
static

Definition at line 356 of file tractInfo.py.

◆ num_patches

lsst.skymap.tractInfo.TractInfo.num_patches = property(getNumPatches)
static

Definition at line 295 of file tractInfo.py.

◆ outer_sky_polygon

lsst.skymap.tractInfo.TractInfo.outer_sky_polygon = property(getOuterSkyPolygon)
static

Definition at line 363 of file tractInfo.py.

◆ patch_border

lsst.skymap.tractInfo.TractInfo.patch_border = property(getPatchBorder)
static

Definition at line 300 of file tractInfo.py.

◆ patch_inner_dimensions

lsst.skymap.tractInfo.TractInfo.patch_inner_dimensions = property(getPatchInnerDimensions)
static

Definition at line 329 of file tractInfo.py.

◆ tract_id

lsst.skymap.tractInfo.TractInfo.tract_id = property(getId)
static

Definition at line 283 of file tractInfo.py.

◆ tract_overlap

lsst.skymap.tractInfo.TractInfo.tract_overlap = property(getTractOverlap)
static

Definition at line 336 of file tractInfo.py.

◆ vertex_list

lsst.skymap.tractInfo.TractInfo.vertex_list = property(getVertexList)
static

Definition at line 348 of file tractInfo.py.

◆ wcs

lsst.skymap.tractInfo.TractInfo.wcs = property(getWcs)
static

Definition at line 375 of file tractInfo.py.


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