LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
interface.py
Go to the documentation of this file.
1 from __future__ import print_function
2 from builtins import range
3 from builtins import object
4 #
5 # LSST Data Management System
6 # Copyright 2008, 2009, 2010, 2015 LSST Corporation.
7 #
8 # This product includes software developed by the
9 # LSST Project (http://www.lsst.org/).
10 #
11 # This program is free software: you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation, either version 3 of the License, or
14 # (at your option) any later version.
15 #
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the LSST License Statement and
22 # the GNU General Public License along with this program. If not,
23 # see <http://www.lsstcorp.org/LegalNotices/>.
24 #
25 
26 ##
27 ## \file
28 ## \brief Support for talking to image displays from python
29 
30 import re
31 import sys
32 import importlib
33 import lsst.afw.geom as afwGeom
34 import lsst.afw.image as afwImage
35 import lsst.log
36 
37 logger = lsst.log.Log.getLogger("afw.display.interface")
38 
39 __all__ = (
40  "WHITE", "BLACK", "RED", "GREEN", "BLUE", "CYAN", "MAGENTA", "YELLOW", "ORANGE",
41  "Display", "Event", "noop_callback", "h_callback",
42  "setDefaultBackend", "getDefaultBackend",
43  "setDefaultFrame", "getDefaultFrame", "incrDefaultFrame",
44  "setDefaultMaskTransparency", "setDefaultMaskPlaneColor",
45  "getDisplay", "delAllDisplays",
46 )
47 
48 #
49 # Symbolic names for mask/line colours. N.b. ds9 supports any X11 colour for masks
50 #
51 WHITE = "white"
52 BLACK = "black"
53 RED = "red"
54 GREEN = "green"
55 BLUE = "blue"
56 CYAN = "cyan"
57 MAGENTA = "magenta"
58 YELLOW = "yellow"
59 ORANGE = "orange"
60 
61 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
62 
63 def _makeDisplayImpl(display, backend, *args, **kwargs):
64  """!Return the DisplayImpl for the named backend
65 
66  \param display Name of device. Should be importable, either absolutely or relative to lsst.display
67  \param backend The desired backend
68  \param args Arguments passed to DisplayImpl.__init__
69  \param kwargs Keywords arguments passed to DisplayImpl.__init__
70 
71  E.g.
72  import lsst.afw.display as afwDisplay
73  display = afwDisplay.Display(display=1, backend="ds9")
74  would call
75  _makeDisplayImpl(..., "ds9", 1)
76  and import the ds9 implementation of DisplayImpl from lsst.display.ds9
77  """
78  _disp = None
79  exc = None
80  for dt in ("lsst.display.%s" % backend, backend, ".%s" % backend, "lsst.afw.display.%s" % backend):
81  exc = None
82  # only specify the root package if we are not doing an absolute import
83  impargs = {}
84  if dt.startswith("."):
85  impargs["package"] = "lsst.display"
86  try:
87  _disp = importlib.import_module(dt, **impargs)
88  break
89  except (ImportError, SystemError) as e:
90  # SystemError can be raised in Python 3.5 if a relative import
91  # is attempted when the root package, lsst.display, does not exist.
92  # Copy the exception into outer scope
93  exc = e
94 
95  if not _disp or not hasattr(_disp.DisplayImpl, "_show"):
96  if exc is not None:
97  # re-raise the final exception
98  raise exc
99  else:
100  raise ImportError("Could not load the requested backend: {}".format(backend))
101 
102  if display:
103  _impl = _disp.DisplayImpl(display, *args, **kwargs)
104  if not hasattr(_impl, "frame"):
105  _impl.frame = display.frame
106 
107  return _impl
108  else:
109  return True
110 
111 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
112 
113 class Display(object):
114  _displays = {}
115  _defaultBackend = None
116  _defaultFrame = 0
117  _defaultMaskPlaneColor = dict(
118  BAD=RED,
119  CR=MAGENTA,
120  EDGE=YELLOW,
121  INTERPOLATED=GREEN,
122  SATURATED=GREEN,
123  DETECTED=BLUE,
124  DETECTED_NEGATIVE=CYAN,
125  SUSPECT=YELLOW,
126  NO_DATA=ORANGE,
127  # deprecated names
128  INTRP=GREEN,
129  SAT=GREEN,
130  )
131  _defaultMaskTransparency = {}
132 
133  def __init__(self, frame=None, backend=None, *args, **kwargs):
134  """!Create an object able to display images and overplot glyphs
135 
136  \param frame An identifier for the display
137  \param backend The backend to use (defaults to value set by setDefaultBackend())
138  \param args Arguments to pass to the backend
139  \param kwargs Arguments to pass to the backend
140  """
141  if frame is None:
142  frame = getDefaultFrame()
143 
144  if backend is None:
145  if Display._defaultBackend is None:
146  try:
147  setDefaultBackend("ds9")
148  except RuntimeError:
149  setDefaultBackend("virtualDevice")
150 
151  backend = Display._defaultBackend
152 
153  self.frame = frame
154  self._impl = _makeDisplayImpl(self, backend, *args, **kwargs)
155  self.name = backend
156 
157  self._xy0 = None # the data displayed on the frame's XY0
158  self.setMaskTransparency(Display._defaultMaskTransparency)
160  self.setMaskPlaneColor(Display._defaultMaskPlaneColor)
161 
162  self._callbacks = {}
163 
164  for ik in range(ord('a'), ord('z') + 1):
165  k = "%c" % ik
166  self.setCallback(k, noRaise=True)
167  self.setCallback(k.upper(), noRaise=True)
168 
169  for k in ('Return', 'Shift_L', 'Shift_R'):
170  self.setCallback(k)
171 
172  for k in ('q', 'Escape'):
173  self.setCallback(k, lambda k, x, y: True)
174 
175  def _h_callback(k, x, y):
176  h_callback(k, x, y)
177 
178  for k in sorted(self._callbacks.keys()):
179  doc = self._callbacks[k].__doc__
180  print(" %-6s %s" % (k, doc.split("\n")[0] if doc else "???"))
181 
182  self.setCallback('h', _h_callback)
183 
184  Display._displays[frame] = self
185 
186  def __enter__(self):
187  """!Support for python's with statement"""
188  return self
189 
190  def __exit__(self, *args):
191  """!Support for python's with statement"""
192  self.close()
193 
194  def __del__(self):
195  self.close()
196 
197  def __getattr__(self, name, *args, **kwargs):
198  """Try to call self._impl.name(*args, *kwargs)"""
199 
200  if not (hasattr(self, "_impl") and self._impl):
201  raise AttributeError("Device has no _impl attached")
202 
203  try:
204  return getattr(self._impl, name)
205  except AttributeError:
206  raise AttributeError("Device %s has no attribute \"%s\"" % (self.name, name))
207 
208  def close(self):
209  if hasattr(self, "_impl") and self._impl:
210  del self._impl
211  self._impl = None
212 
213  if self.frame in Display._displays:
214  del Display._displays[self.frame]
215 
216  @property
217  def verbose(self):
218  """!The backend's verbosity"""
219  return self._impl.verbose
220 
221  @verbose.setter
222  def verbose(self, value):
223  if self._impl:
224  self._impl.verbose = value
225 
226  def __str__(self):
227  return "Display[%s]" % (self.frame)
228 
229  #
230  # Handle Displays, including the default one (the frame to use when a user specifies None)
231  #
232  @staticmethod
233  def setDefaultBackend(backend):
234  try:
235  _makeDisplayImpl(None, backend)
236  except Exception as e:
237  raise RuntimeError("Unable to set backend to %s: \"%s\"" % (backend, e))
238 
239  Display._defaultBackend = backend
240 
241  @staticmethod
243  return Display._defaultBackend
244 
245  @staticmethod
246  def setDefaultFrame(frame=0):
247  """Set the default frame for display"""
248  Display._defaultFrame = frame
249 
250  @staticmethod
252  """Get the default frame for display"""
253  return Display._defaultFrame
254 
255  @staticmethod
257  """Increment the default frame for display"""
258  Display._defaultFrame += 1
259  return Display._defaultFrame
260 
261  @staticmethod
262  def setDefaultMaskTransparency(maskPlaneTransparency={}):
263  if hasattr(maskPlaneTransparency, "copy"):
264  maskPlaneTransparency = maskPlaneTransparency.copy()
265 
266  Display._defaultMaskTransparency = maskPlaneTransparency
267 
268  @staticmethod
269  def setDefaultMaskPlaneColor(name=None, color=None):
270  """!Set the default mapping from mask plane names to colours
271  \param name name of mask plane, or a dict mapping names to colours
272  \param color Desired color, or None if name is a dict
273 
274  If name is None, use the hard-coded default dictionary
275  """
276 
277  if name is None:
278  name = Display._defaultMaskPlaneColor
279 
280  if isinstance(name, dict):
281  assert color == None
282  for k, v in name.items():
284  return
285  #
286  # Set the individual colour values
287  #
288  Display._defaultMaskPlaneColor[name] = color
289 
290  @staticmethod
291  def getDisplay(frame=None, backend=None, create=True, verbose=False, *args, **kwargs):
292  """!Return the Display indexed by frame, creating it if needs be
293 
294  \param frame The desired frame (None => use defaultFrame (see setDefaultFrame))
295  \param backend create the specified frame using this backend (or the default if None) \
296  if it doesn't already exist. If backend == "", it's an error to specify a non-existent frame
297  \param create create the display if it doesn't already exist.
298  \param verbose Allow backend to be chatty
299  \param args arguments passed to Display constructor
300  \param kwargs keyword arguments passed to Display constructor
301  """
302 
303  if frame is None:
304  frame = Display._defaultFrame
305 
306  if not frame in Display._displays:
307  if backend == "":
308  raise RuntimeError("Frame %s does not exist" % frame)
309 
310  Display._displays[frame] = Display(frame, backend, verbose=verbose, *args, **kwargs)
311 
312  Display._displays[frame].verbose = verbose
313  return Display._displays[frame]
314 
315  @staticmethod
317  """!Delete and close all known display
318  """
319  for disp in list(Display._displays.values()):
320  disp.close()
321  Display._displays = {}
322 
323  def maskColorGenerator(self, omitBW=True):
324  """!A generator for "standard" colours
325 
326  \param omitBW Don't include Black and White
327 
328  e.g.
329  colorGenerator = interface.maskColorGenerator(omitBW=True)
330  for p in planeList:
331  print p, next(colorGenerator)
332  """
333  _maskColors = [WHITE, BLACK, RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, ORANGE]
334 
335  i = -1
336  while True:
337  i += 1
338  color = _maskColors[i%len(_maskColors)]
339  if omitBW and color in (BLACK, WHITE):
340  continue
341 
342  yield color
343 
344  def setMaskPlaneColor(self, name, color=None):
345  """!Request that mask plane name be displayed as color
346 
347  \param name Name of mask plane or a dictionary of name -> colourName
348  \param color The name of the colour to use (must be None if name is a dict)
349 
350  Colours may be specified as any X11-compliant string (e.g. <tt>"orchid"</tt>), or by one
351  of the following constants defined in \c afwDisplay: \c BLACK, \c WHITE, \c RED, \c BLUE,
352  \c GREEN, \c CYAN, \c MAGENTA, \c YELLOW.
353 
354  The advantage of using the symbolic names is that the python interpreter can detect typos.
355 
356  """
357 
358  if isinstance(name, dict):
359  assert color == None
360  for k, v in name.items():
361  self.setMaskPlaneColor(k, v)
362  return
363 
364  self._maskPlaneColors[name] = color
365 
366  def getMaskPlaneColor(self, name):
367  """!Return the colour associated with the specified mask plane name"""
368 
369  return self._maskPlaneColors.get(name)
370 
371  def setMaskTransparency(self, transparency=None, name=None):
372  """!Specify display's mask transparency (percent); or None to not set it when loading masks"""
373 
374  if isinstance(transparency, dict):
375  assert name == None
376  for k, v in transparency.items():
377  self.setMaskTransparency(k, v)
378  return
379 
380  if transparency is not None and (transparency < 0 or transparency > 100):
381  print("Mask transparency should be in the range [0, 100]; clipping", file=sys.stderr)
382  if transparency < 0:
383  transparency = 0
384  else:
385  transparency = 100
386 
387  if transparency is not None:
388  self._impl._setMaskTransparency(transparency, name)
389 
390  def getMaskTransparency(self, name=None):
391  """!Return the current display's mask transparency"""
392 
393  return self._impl._getMaskTransparency(name)
394 
395  def show(self):
396  """!Uniconify and Raise display. N.b. throws an exception if frame doesn't exit"""
397  return self._impl._show()
398 
399  def mtv(self, data, title="", wcs=None):
400  """!Display an Image or Mask on a DISPLAY display
401 
402  Historical note: the name "mtv" comes from Jim Gunn's forth imageprocessing
403  system, Mirella (named after Mirella Freni); The "m" stands for Mirella.
404  """
405  if hasattr(data, "getXY0"):
406  self._xy0 = data.getXY0()
407  else:
408  self._xy0 = None
409 
410  if re.search("::Exposure<", repr(data)): # it's an Exposure; display the MaskedImage with the WCS
411  if wcs:
412  raise RuntimeError("You may not specify a wcs with an Exposure")
413  data, wcs = data.getMaskedImage(), data.getWcs()
414  elif re.search("::DecoratedImage<", repr(data)): # it's a DecoratedImage; display it
415  data, wcs = data.getImage(), afwImage.makeWcs(data.getMetadata())
416  self._xy0 = data.getXY0() # DecoratedImage doesn't have getXY0()
417 
418  if re.search("::Image<", repr(data)): # it's an Image; display it
419  self._impl._mtv(data, None, wcs, title)
420  elif re.search("::Mask<", repr(data)): # it's a Mask; display it, bitplane by bitplane
421  #
422  # Some displays can't display a Mask without an image; so display an Image too,
423  # with pixel values set to the mask
424  #
425  self._impl._mtv(afwImage.ImageU(data.getArray()), data, wcs, title)
426  elif re.search("::MaskedImage<", repr(data)): # it's a MaskedImage; display Image and overlay Mask
427  self._impl._mtv(data.getImage(), data.getMask(True), wcs, title)
428  else:
429  raise RuntimeError("Unsupported type %s" % repr(data))
430  #
431  # Graphics commands
432  #
433  class _Buffering(object):
434  """A class intended to be used with python's with statement"""
435  def __init__(self, _impl):
436  self._impl = _impl
437  def __enter__(self):
438  self._impl._buffer(True)
439  def __exit__(self, *args):
440  self._impl._buffer(False)
441  self._impl._flush()
442 
443  def Buffering(self):
444  """Return a class intended to be used with python's with statement
445  E.g.
446  with display.Buffering():
447  display.dot("+", xc, yc)
448  """
449  return self._Buffering(self._impl)
450 
451  def flush(self):
452  """!Flush the buffers"""
453  self._impl._flush()
454 
455  def erase(self):
456  """!Erase the specified DISPLAY frame
457  """
458  self._impl._erase()
459 
460  def dot(self, symb, c, r, size=2, ctype=None, origin=afwImage.PARENT, *args, **kwargs):
461  """!Draw a symbol onto the specified DISPLAY frame at (col,row) = (c,r) [0-based coordinates]
462 
463  Possible values are:
464  + Draw a +
465  x Draw an x
466  * Draw a *
467  o Draw a circle
468  @:Mxx,Mxy,Myy Draw an ellipse with moments (Mxx, Mxy, Myy) (argument size is ignored)
469  An object derived from afwGeom.ellipses.BaseCore Draw the ellipse (argument size is ignored)
470  Any other value is interpreted as a string to be drawn. Strings obey the fontFamily (which may be extended
471  with other characteristics, e.g. "times bold italic". Text will be drawn rotated by textAngle (textAngle is
472  ignored otherwise).
473 
474  N.b. objects derived from BaseCore include Axes and Quadrupole.
475  """
476  if isinstance(symb, int):
477  symb = "%d" % (symb)
478 
479  if origin == afwImage.PARENT and self._xy0 is not None:
480  x0, y0 = self._xy0
481  r -= y0
482  c -= x0
483 
484  if isinstance(symb, afwGeom.ellipses.BaseCore) or re.search(r"^@:", symb):
485  try:
486  mat = re.search(r"^@:([^,]+),([^,]+),([^,]+)", symb)
487  except TypeError:
488  pass
489  else:
490  if mat:
491  mxx, mxy, myy = [float(_) for _ in mat.groups()]
492  symb = afwGeom.ellipses.Quadrupole(mxx, myy, mxy)
493 
494  symb = afwGeom.ellipses.Axes(symb)
495 
496  self._impl._dot(symb, c, r, size, ctype, **kwargs)
497 
498  def line(self, points, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5):
499  """!Draw a set of symbols or connect the points, a list of (col,row)
500  If symbs is True, draw points at the specified points using the desired symbol,
501  otherwise connect the dots. Ctype is the name of a colour (e.g. 'red')
502 
503  If symbs supports indexing (which includes a string -- caveat emptor) the elements are used to label the points
504  """
505  if symbs:
506  try:
507  symbs[1]
508  except:
509  symbs = len(points)*list(symbs)
510 
511  for i, xy in enumerate(points):
512  self.dot(symbs[i], *xy, size=size, ctype=ctype)
513  else:
514  if len(points) > 0:
515  if origin == afwImage.PARENT and self._xy0 is not None:
516  x0, y0 = self._xy0
517  _points = list(points) # make a mutable copy
518  for i, p in enumerate(points):
519  _points[i] = (p[0] - x0, p[1] - y0)
520  points = _points
521 
522  self._impl._drawLines(points, ctype)
523  #
524  # Set gray scale
525  #
526  def scale(self, algorithm, min, max=None, unit=None, *args, **kwargs):
527  """!Set the range of the scaling from DN in the image to the image display
528  \param algorithm Desired scaling (e.g. "linear" or "asinh")
529  \param min Minimum value, or "minmax" or "zscale"
530  \param max Maximum value (must be None for minmax|zscale)
531  \param unit Units for min and max (e.g. Percent, Absolute, Sigma; None if min==minmax|zscale)
532  \param *args Optional arguments
533  \param **kwargs Optional keyword arguments
534  """
535  if min in ("minmax", "zscale"):
536  assert max == None, "You may not specify \"%s\" and max" % min
537  assert unit == None, "You may not specify \"%s\" and unit" % min
538  elif max is None:
539  raise RuntimeError("Please specify max")
540 
541  self._impl._scale(algorithm, min, max, unit, *args, **kwargs)
542  #
543  # Zoom and Pan
544  #
545  def zoom(self, zoomfac=None, colc=None, rowc=None, origin=afwImage.PARENT):
546  """!Zoom frame by specified amount, optionally panning also"""
547 
548  if (rowc and colc is None) or (colc and rowc is None):
549  raise RuntimeError("Please specify row and column center to pan about")
550 
551  if rowc is not None:
552  if origin == afwImage.PARENT and self._xy0 is not None:
553  x0, y0 = self._xy0
554  rowc -= x0
555  colc -= y0
556 
557  self._impl._pan(colc, rowc)
558 
559  if zoomfac == None and rowc == None:
560  zoomfac = 2
561 
562  if zoomfac is not None:
563  self._impl._zoom(zoomfac)
564 
565  def pan(self, colc=None, rowc=None, origin=afwImage.PARENT):
566  """!Pan to (rowc, colc); see also zoom"""
567 
568  self.zoom(None, colc, rowc, origin)
569 
570  def interact(self):
571  """!Enter an interactive loop, listening for key presses in display and firing callbacks.
572  Exit with q, \c CR, \c ESC, or any other callback function that returns a ``True`` value.
573  """
574  interactFinished = False
575 
576  while not interactFinished:
577  ev = self._impl._getEvent()
578  if not ev:
579  continue
580  k, x, y = ev.k, ev.x, ev.y # for now
581 
582  if k not in self._callbacks:
583  logger.warn("No callback registered for {0}".format(k))
584  else:
585  try:
586  interactFinished = self._callbacks[k](k, x, y)
587  except Exception as e:
588  logger.error("Display._callbacks[{0}]({0},{1},{2}) failed: {3}".format(k, x, y, e))
589 
590  def setCallback(self, k, func=None, noRaise=False):
591  """!Set the callback for key k to be func, returning the old callback
592  """
593 
594  if k in "f":
595  if noRaise:
596  return
597  raise RuntimeError(
598  "Key '%s' is already in use by display, so I can't add a callback for it" % k)
599 
600  ofunc = self._callbacks.get(k)
601  self._callbacks[k] = func if func else noop_callback
602 
603  self._impl._setCallback(k, self._callbacks[k])
604 
605  return ofunc
606 
607  def getActiveCallbackKeys(self, onlyActive=True):
608  """!Return all callback keys
609  \param onlyActive If true only return keys that do something
610  """
611 
612  return sorted([k for k, func in self._callbacks.items() if
613  not (onlyActive and func == noop_callback)])
614 
615 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
616 #
617 # Callbacks for display events
618 #
619 class Event(object):
620  """!A class to handle events such as key presses in image display windows"""
621  def __init__(self, k, x=float('nan'), y=float('nan')):
622  self.k = k
623  self.x = x
624  self.y = y
625 
626  def __str__(self):
627  return "%s (%.2f, %.2f)" % (self.k, self.x, self.y)
628 #
629 # Default fallback function
630 #
631 def noop_callback(k, x, y):
632  """!Callback function: arguments key, x, y"""
633  return False
634 
635 def h_callback(k, x, y):
636  print("Enter q or <ESC> to leave interactive mode, h for this help, or a letter to fire a callback")
637  return False
638 
639 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
640 #
641 # Handle Displays, including the default one (the frame to use when a user specifies None)
642 #
643 # If the default frame is None, image display is disabled
644 #
645 def setDefaultBackend(backend):
646  Display.setDefaultBackend(backend)
647 
649  return Display.getDefaultBackend()
650 
651 def setDefaultFrame(frame=0):
652  return Display.setDefaultFrame(frame)
653 
655  """Get the default frame for display"""
656  return Display.getDefaultFrame()
657 
659  """Increment the default frame for display"""
660  return Display.incrDefaultFrame()
661 
662 def setDefaultMaskTransparency(maskPlaneTransparency={}):
663  return Display.setDefaultMaskTransparency(maskPlaneTransparency)
664 
665 def setDefaultMaskPlaneColor(name=None, color=None):
666  """!Set the default mapping from mask plane names to colours
667  \param name name of mask plane, or a dict mapping names to colours
668  \param color Desired color, or None if name is a dict
669 
670  If name is None, use the hard-coded default dictionary
671  """
672 
673  return Display.setDefaultMaskPlaneColor(name, color)
674 
675 def getDisplay(frame=None, backend=None, create=True, verbose=False, *args, **kwargs):
676  """!Return the Display indexed by frame, creating it if needs be
677 
678  See Display.getDisplay
679 
680  \param frame The desired frame (None => use defaultFrame (see setDefaultFrame))
681  \param backend create the specified frame using this backend (or the default if None) \
682  if it doesn't already exist. If backend == "", it's an error to specify a non-existent frame
683  \param create create the display if it doesn't already exist.
684  \param verbose Allow backend to be chatty
685  \param args arguments passed to Display constructor
686  \param kwargs keyword arguments passed to Display constructor
687  """
688 
689  return Display.getDisplay(frame, backend, create, verbose, *args, **kwargs)
690 
692  """!Delete and close all known display
693  """
694  return Display.delAllDisplays()
def getMaskTransparency
Return the current display&#39;s mask transparency.
Definition: interface.py:390
def getDisplay
Return the Display indexed by frame, creating it if needs be.
Definition: interface.py:291
def setMaskTransparency
Specify display&#39;s mask transparency (percent); or None to not set it when loading masks...
Definition: interface.py:371
def interact
Enter an interactive loop, listening for key presses in display and firing callbacks.
Definition: interface.py:570
def setMaskPlaneColor
Request that mask plane name be displayed as color.
Definition: interface.py:344
def zoom
Zoom frame by specified amount, optionally panning also.
Definition: interface.py:545
metadata import lsst afw display as afwDisplay except ImportError
def delAllDisplays
Delete and close all known display.
Definition: interface.py:316
def mtv
Display an Image or Mask on a DISPLAY display.
Definition: interface.py:399
def __enter__
Support for python&#39;s with statement.
Definition: interface.py:186
def pan
Pan to (rowc, colc); see also zoom.
Definition: interface.py:565
def verbose
The backend&#39;s verbosity.
Definition: interface.py:217
def __init__
Create an object able to display images and overplot glyphs.
Definition: interface.py:133
def getMaskPlaneColor
Return the colour associated with the specified mask plane name.
Definition: interface.py:366
A class to handle events such as key presses in image display windows.
Definition: interface.py:619
def dot
Draw a symbol onto the specified DISPLAY frame at (col,row) = (c,r) [0-based coordinates].
Definition: interface.py:460
def _makeDisplayImpl
Return the DisplayImpl for the named backend.
Definition: interface.py:63
boost::shared_ptr< Wcs > makeWcs(coord::Coord const &crval, geom::Point2D const &crpix, double CD11, double CD12, double CD21, double CD22)
Create a Wcs object from crval, crpix, CD, using CD elements (useful from python) ...
Definition: makeWcs.cc:138
def scale
Set the range of the scaling from DN in the image to the image display.
Definition: interface.py:526
def delAllDisplays
Delete and close all known display.
Definition: interface.py:691
def show
Uniconify and Raise display.
Definition: interface.py:395
def line
Draw a set of symbols or connect the points, a list of (col,row) If symbs is True, draw points at the specified points using the desired symbol, otherwise connect the dots.
Definition: interface.py:498
def setCallback
Set the callback for key k to be func, returning the old callback.
Definition: interface.py:590
def erase
Erase the specified DISPLAY frame.
Definition: interface.py:455
static Log getLogger(Log const &logger)
Definition: Log.h:772
def getDisplay
Return the Display indexed by frame, creating it if needs be.
Definition: interface.py:675
def flush
Flush the buffers.
Definition: interface.py:451
def __exit__
Support for python&#39;s with statement.
Definition: interface.py:190
def getActiveCallbackKeys
Return all callback keys.
Definition: interface.py:607
def noop_callback
Callback function: arguments key, x, y.
Definition: interface.py:631
def maskColorGenerator
A generator for &quot;standard&quot; colours.
Definition: interface.py:323
def setDefaultMaskPlaneColor
Set the default mapping from mask plane names to colours.
Definition: interface.py:665
def setDefaultMaskPlaneColor
Set the default mapping from mask plane names to colours.
Definition: interface.py:269