LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Classes | Functions | Variables
lsst.afw.display.utils Namespace Reference

Classes

class  Mosaic
 

Functions

def _getDisplayFromDisplayOrFrame
 Return an afwDisplay.Display given either a display or a frame ID. More...
 
def drawBBox
 
def drawFootprint
 
def drawCoaddInputs
 

Variables

tuple __all__
 

Function Documentation

def lsst.afw.display.utils._getDisplayFromDisplayOrFrame (   display,
  frame = None 
)
private

Return an afwDisplay.Display given either a display or a frame ID.

If the two arguments are consistent, return the desired display; if they are not, raise a RuntimeError exception.

If the desired display is None, return None; if (display, frame) == ("deferToFrame", None), return the default display

Definition at line 36 of file utils.py.

36 
37 def _getDisplayFromDisplayOrFrame(display, frame=None):
38  """!Return an afwDisplay.Display given either a display or a frame ID.
39 
40  If the two arguments are consistent, return the desired display; if they are not,
41  raise a RuntimeError exception.
42 
43  If the desired display is None, return None;
44  if (display, frame) == ("deferToFrame", None), return the default display"""
45 
46  import lsst.afw.display as afwDisplay # import locally to allow this file to be imported by __init__
47 
48  if display in ("deferToFrame", None):
49  if display is None and frame is None:
50  return None
51 
52  # "deferToFrame" is the default value, and means "obey frame"
53  display = None
54 
55  if display and not hasattr(display, "frame"):
56  raise RuntimeError("display == %s doesn't support .frame" % display)
57 
58  if frame and display and display.frame != frame:
59  raise RuntimeError("Please specify display *or* frame")
60 
61  if display:
62  frame = display.frame
63 
64  display = afwDisplay.getDisplay(frame, create=True)
65 
66  return display
67 
68 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
def _getDisplayFromDisplayOrFrame
Return an afwDisplay.Display given either a display or a frame ID.
Definition: utils.py:36
def lsst.afw.display.utils.drawBBox (   bbox,
  borderWidth = 0.0,
  origin = None,
  display = "deferToFrame",
  ctype = None,
  bin = 1,
  frame = None 
)
Draw an afwImage::BBox on a display frame with the specified ctype.  Include an extra borderWidth pixels
If origin is present, it's Added to the BBox

All BBox coordinates are divided by bin, as is right and proper for overlaying on a binned image

Definition at line 281 of file utils.py.

282 def drawBBox(bbox, borderWidth=0.0, origin=None, display="deferToFrame", ctype=None, bin=1, frame=None):
283  """Draw an afwImage::BBox on a display frame with the specified ctype. Include an extra borderWidth pixels
284 If origin is present, it's Added to the BBox
285 
286 All BBox coordinates are divided by bin, as is right and proper for overlaying on a binned image
287  """
288  x0, y0 = bbox.getMinX(), bbox.getMinY()
289  x1, y1 = bbox.getMaxX(), bbox.getMaxY()
290 
291  if origin:
292  x0 += origin[0]; x1 += origin[0]
293  y0 += origin[1]; y1 += origin[1]
294 
295  x0 /= bin; y0 /= bin
296  x1 /= bin; y1 /= bin
297  borderWidth /= bin
298 
299  display = _getDisplayFromDisplayOrFrame(display, frame)
300  display.line([(x0 - borderWidth, y0 - borderWidth),
301  (x0 - borderWidth, y1 + borderWidth),
302  (x1 + borderWidth, y1 + borderWidth),
303  (x1 + borderWidth, y0 - borderWidth),
304  (x0 - borderWidth, y0 - borderWidth),
305  ], ctype=ctype)
def _getDisplayFromDisplayOrFrame
Return an afwDisplay.Display given either a display or a frame ID.
Definition: utils.py:36
def lsst.afw.display.utils.drawCoaddInputs (   exposure,
  frame = None,
  ctype = None,
  bin = 1,
  display = "deferToFrame" 
)
Draw the bounding boxes of input exposures to a coadd on a display frame with the specified ctype,
assuming display.mtv() has already been called on the given exposure on this frame.


All coordinates are divided by bin, as is right and proper for overlaying on a binned image

Definition at line 351 of file utils.py.

352 def drawCoaddInputs(exposure, frame=None, ctype=None, bin=1, display="deferToFrame"):
353  """Draw the bounding boxes of input exposures to a coadd on a display frame with the specified ctype,
354  assuming display.mtv() has already been called on the given exposure on this frame.
355 
356 
357  All coordinates are divided by bin, as is right and proper for overlaying on a binned image
358  """
359  coaddWcs = exposure.getWcs()
360  catalog = exposure.getInfo().getCoaddInputs().ccds
361 
362  offset = afwGeom.PointD() - afwGeom.PointD(exposure.getXY0())
363 
364  display = _getDisplayFromDisplayOrFrame(display, frame)
365 
366  with display.Buffering():
367  for record in catalog:
368  ccdBox = afwGeom.Box2D(record.getBBox())
369  ccdCorners = ccdBox.getCorners()
370  coaddCorners = [coaddWcs.skyToPixel(record.getWcs().pixelToSky(point)) + offset
371  for point in ccdCorners]
372  display.line([(coaddCorners[i].getX()/bin, coaddCorners[i].getY()/bin)
373  for i in range(-1, 4)], ctype=ctype)
def _getDisplayFromDisplayOrFrame
Return an afwDisplay.Display given either a display or a frame ID.
Definition: utils.py:36
A floating-point coordinate rectangle geometry.
Definition: Box.h:271
def lsst.afw.display.utils.drawFootprint (   foot,
  borderWidth = 0.5,
  origin = None,
  XY0 = None,
  frame = None,
  ctype = None,
  bin = 1,
  peaks = False,
  symb = "+",
  size = 0.4,
  ctypePeak = None,
  display = "deferToFrame" 
)
Draw an afwDetection::Footprint on a display frame with the specified ctype.  Include an extra borderWidth
pixels If origin is present, it's Added to the Footprint; if XY0 is present is Subtracted from the Footprint

If peaks is True, also show the object's Peaks using the specified symbol and size and ctypePeak

All Footprint coordinates are divided by bin, as is right and proper for overlaying on a binned image

Definition at line 307 of file utils.py.

308  peaks=False, symb="+", size=0.4, ctypePeak=None, display="deferToFrame"):
309  """Draw an afwDetection::Footprint on a display frame with the specified ctype. Include an extra borderWidth
310 pixels If origin is present, it's Added to the Footprint; if XY0 is present is Subtracted from the Footprint
311 
312 If peaks is True, also show the object's Peaks using the specified symbol and size and ctypePeak
313 
314 All Footprint coordinates are divided by bin, as is right and proper for overlaying on a binned image
315  """
316 
317  if XY0:
318  if origin:
319  raise RuntimeError("You may not specify both origin and XY0")
320  origin = (-XY0[0], -XY0[1])
321 
322  display = _getDisplayFromDisplayOrFrame(display, frame)
323  with display.Buffering():
324  borderWidth /= bin
325  for s in foot.getSpans():
326  y, x0, x1 = s.getY(), s.getX0(), s.getX1()
327 
328  if origin:
329  x0 += origin[0]; x1 += origin[0]
330  y += origin[1]
331 
332  x0 /= bin; x1 /= bin; y /= bin
333 
334  display.line([(x0 - borderWidth, y - borderWidth),
335  (x0 - borderWidth, y + borderWidth),
336  (x1 + borderWidth, y + borderWidth),
337  (x1 + borderWidth, y - borderWidth),
338  (x0 - borderWidth, y - borderWidth),
339  ], ctype=ctype)
340 
341  if peaks:
342  for p in foot.getPeaks():
343  x, y = p.getIx(), p.getIy()
344 
345  if origin:
346  x += origin[0]; y += origin[1]
347 
348  x /= bin; y /= bin
349 
350  display.dot(symb, x, y, size=size, ctype=ctypePeak)
def _getDisplayFromDisplayOrFrame
Return an afwDisplay.Display given either a display or a frame ID.
Definition: utils.py:36

Variable Documentation

tuple lsst.afw.display.utils.__all__
Initial value:
1 = (
2  "Mosaic",
3  "drawBBox", "drawFootprint", "drawCoaddInputs",
4  )

Definition at line 31 of file utils.py.