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