lsst.afw  16.0-43-gaa65a4573
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  try:
464  wcs = afwGeom.makeSkyWcs(data.getMetadata())
465  except TypeError:
466  wcs = None
467  data = data.image
468 
469  self._xy0 = data.getXY0() # DecoratedImage doesn't have getXY0()
470 
471  if isinstance(data, afwImage.Image): # it's an Image; display it
472  self._impl._mtv(data, None, wcs, title)
473  # it's a Mask; display it, bitplane by bitplane
474  elif isinstance(data, afwImage.Mask):
475  #
476  # Some displays can't display a Mask without an image; so display an Image too,
477  # with pixel values set to the mask
478  #
479  self._impl._mtv(afwImage.ImageI(data.getArray()), data, wcs, title)
480  # it's a MaskedImage; display Image and overlay Mask
481  elif isinstance(data, afwImage.MaskedImage):
482  self._impl._mtv(data.getImage(), data.getMask(), wcs, title)
483  else:
484  raise RuntimeError("Unsupported type %s" % repr(data))
485  #
486  # Graphics commands
487  #
488 
489  class _Buffering:
490  """A class intended to be used with python's with statement"""
491 
492  def __init__(self, _impl):
493  self._impl = _impl
494 
495  def __enter__(self):
496  self._impl._buffer(True)
497 
498  def __exit__(self, *args):
499  self._impl._buffer(False)
500  self._impl._flush()
501 
502  def Buffering(self):
503  """Return a class intended to be used with python's with statement
504  E.g.
505  with display.Buffering():
506  display.dot("+", xc, yc)
507  """
508  return self._Buffering(self._impl)
509 
510  def flush(self):
511  """!Flush the buffers"""
512  self._impl._flush()
513 
514  def erase(self):
515  """!Erase the specified DISPLAY frame
516  """
517  self._impl._erase()
518 
519  def dot(self, symb, c, r, size=2, ctype=None, origin=afwImage.PARENT, *args, **kwargs):
520  """!Draw a symbol onto the specified DISPLAY frame at (col,row) = (c,r)
521  [0-based coordinates]
522 
523  Possible values are:
524  + Draw a +
525  x Draw an x
526  * Draw a *
527  o Draw a circle
528  @:Mxx,Mxy,Myy Draw an ellipse with moments (Mxx, Mxy, Myy) (argument size is ignored)
529  An object derived from afwGeom.ellipses.BaseCore Draw the ellipse (argument size is ignored)
530  Any other value is interpreted as a string to be drawn. Strings obey the fontFamily (which may be
531  extended with other characteristics, e.g. "times bold italic". Text will be drawn rotated by
532  textAngle (textAngle is ignored otherwise).
533 
534  N.b. objects derived from BaseCore include Axes and Quadrupole.
535  """
536  if isinstance(symb, int):
537  symb = "%d" % (symb)
538 
539  if origin == afwImage.PARENT and self._xy0 is not None:
540  x0, y0 = self._xy0
541  r -= y0
542  c -= x0
543 
544  if isinstance(symb, afwGeom.ellipses.BaseCore) or re.search(r"^@:", symb):
545  try:
546  mat = re.search(r"^@:([^,]+),([^,]+),([^,]+)", symb)
547  except TypeError:
548  pass
549  else:
550  if mat:
551  mxx, mxy, myy = [float(_) for _ in mat.groups()]
552  symb = afwGeom.Quadrupole(mxx, myy, mxy)
553 
554  symb = afwGeom.ellipses.Axes(symb)
555 
556  self._impl._dot(symb, c, r, size, ctype, **kwargs)
557 
558  def line(self, points, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5):
559  """!Draw a set of symbols or connect the points, a list of (col,row)
560  If symbs is True, draw points at the specified points using the desired symbol,
561  otherwise connect the dots. Ctype is the name of a colour (e.g. 'red')
562 
563  If symbs supports indexing (which includes a string -- caveat emptor) the
564  elements are used to label the points
565  """
566  if symbs:
567  try:
568  symbs[1]
569  except TypeError:
570  symbs = len(points)*list(symbs)
571 
572  for i, xy in enumerate(points):
573  self.dot(symbs[i], *xy, size=size, ctype=ctype)
574  else:
575  if len(points) > 0:
576  if origin == afwImage.PARENT and self._xy0 is not None:
577  x0, y0 = self._xy0
578  _points = list(points) # make a mutable copy
579  for i, p in enumerate(points):
580  _points[i] = (p[0] - x0, p[1] - y0)
581  points = _points
582 
583  self._impl._drawLines(points, ctype)
584  #
585  # Set gray scale
586  #
587 
588  def scale(self, algorithm, min, max=None, unit=None, *args, **kwargs):
589  """!Set the range of the scaling from DN in the image to the image display
590  @param algorithm Desired scaling (e.g. "linear" or "asinh")
591  @param min Minimum value, or "minmax" or "zscale"
592  @param max Maximum value (must be None for minmax|zscale)
593  @param unit Units for min and max (e.g. Percent, Absolute, Sigma; None if min==minmax|zscale)
594  @param *args Optional arguments
595  @param **kwargs Optional keyword arguments
596  """
597  if min in ("minmax", "zscale"):
598  assert max is None, "You may not specify \"%s\" and max" % min
599  assert unit is None, "You may not specify \"%s\" and unit" % min
600  elif max is None:
601  raise RuntimeError("Please specify max")
602 
603  self._impl._scale(algorithm, min, max, unit, *args, **kwargs)
604  #
605  # Zoom and Pan
606  #
607 
608  def zoom(self, zoomfac=None, colc=None, rowc=None, origin=afwImage.PARENT):
609  """!Zoom frame by specified amount, optionally panning also"""
610 
611  if (rowc and colc is None) or (colc and rowc is None):
612  raise RuntimeError(
613  "Please specify row and column center to pan about")
614 
615  if rowc is not None:
616  if origin == afwImage.PARENT and self._xy0 is not None:
617  x0, y0 = self._xy0
618  colc -= x0
619  rowc -= y0
620 
621  self._impl._pan(colc, rowc)
622 
623  if zoomfac is None and rowc is None:
624  zoomfac = 2
625 
626  if zoomfac is not None:
627  self._impl._zoom(zoomfac)
628 
629  def pan(self, colc=None, rowc=None, origin=afwImage.PARENT):
630  """!Pan to (rowc, colc); see also zoom"""
631 
632  self.zoom(None, colc, rowc, origin)
633 
634  def interact(self):
635  """!Enter an interactive loop, listening for key presses in display and firing callbacks.
636  Exit with q, @c CR, @c ESC, or any other callback function that returns a ``True`` value.
637  """
638  interactFinished = False
639 
640  while not interactFinished:
641  ev = self._impl._getEvent()
642  if not ev:
643  continue
644  k, x, y = ev.k, ev.x, ev.y # for now
645 
646  if k not in self._callbacks:
647  logger.warn("No callback registered for {0}".format(k))
648  else:
649  try:
650  interactFinished = self._callbacks[k](k, x, y)
651  except Exception as e:
652  logger.error(
653  "Display._callbacks['{0}']({0},{1},{2}) failed: {3}".format(k, x, y, e))
654 
655  def setCallback(self, k, func=None, noRaise=False):
656  """!Set the callback for key k to be func, returning the old callback
657  """
658 
659  if k in "f":
660  if noRaise:
661  return
662  raise RuntimeError(
663  "Key '%s' is already in use by display, so I can't add a callback for it" % k)
664 
665  ofunc = self._callbacks.get(k)
666  self._callbacks[k] = func if func else noop_callback
667 
668  self._impl._setCallback(k, self._callbacks[k])
669 
670  return ofunc
671 
672  def getActiveCallbackKeys(self, onlyActive=True):
673  """!Return all callback keys
674  @param onlyActive If true only return keys that do something
675  """
676 
677  return sorted([k for k, func in self._callbacks.items() if
678  not (onlyActive and func == noop_callback)])
679 
680 #
681 # Callbacks for display events
682 #
683 
684 
685 class Event:
686  """!A class to handle events such as key presses in image display windows"""
687 
688  def __init__(self, k, x=float('nan'), y=float('nan')):
689  self.k = k
690  self.x = x
691  self.y = y
692 
693  def __str__(self):
694  return "%s (%.2f, %.2f)" % (self.k, self.x, self.y)
695 #
696 # Default fallback function
697 #
698 
699 
700 def noop_callback(k, x, y):
701  """!Callback function: arguments key, x, y"""
702  return False
703 
704 
705 def h_callback(k, x, y):
706  print("Enter q or <ESC> to leave interactive mode, h for this help, or a letter to fire a callback")
707  return False
708 
709 #
710 # Handle Displays, including the default one (the frame to use when a user specifies None)
711 #
712 # If the default frame is None, image display is disabled
713 #
714 
715 
716 def setDefaultBackend(backend):
717  Display.setDefaultBackend(backend)
718 
719 
721  return Display.getDefaultBackend()
722 
723 
724 def setDefaultFrame(frame=0):
725  return Display.setDefaultFrame(frame)
726 
727 
729  """Get the default frame for display"""
730  return Display.getDefaultFrame()
731 
732 
734  """Increment the default frame for display"""
735  return Display.incrDefaultFrame()
736 
737 
738 def setDefaultMaskTransparency(maskPlaneTransparency={}):
739  return Display.setDefaultMaskTransparency(maskPlaneTransparency)
740 
741 
742 def setDefaultMaskPlaneColor(name=None, color=None):
743  """!Set the default mapping from mask plane names to colours
744  @param name name of mask plane, or a dict mapping names to colours
745  @param color Desired color, or None if name is a dict
746 
747  If name is None, use the hard-coded default dictionary
748  """
749 
750  return Display.setDefaultMaskPlaneColor(name, color)
751 
752 
753 def getDisplay(frame=None, backend=None, create=True, verbose=False, *args, **kwargs):
754  """!Return the Display indexed by frame, creating it if needs be
755 
756  See Display.getDisplay
757 
758  @param frame The desired frame (None => use defaultFrame (see setDefaultFrame))
759  @param backend create the specified frame using this backend (or the default if None) \
760  if it doesn't already exist. If backend == "", it's an error to specify a non-existent frame
761  @param create create the display if it doesn't already exist.
762  @param verbose Allow backend to be chatty
763  @param args arguments passed to Display constructor
764  @param kwargs keyword arguments passed to Display constructor
765  """
766 
767  return Display.getDisplay(frame, backend, create, verbose, *args, **kwargs)
768 
769 
771  """!Delete and close all known display
772  """
773  return Display.delAllDisplays()
def pan(self, colc=None, rowc=None, origin=afwImage.PARENT)
Pan to (rowc, colc); see also zoom.
Definition: interface.py:629
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:519
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:753
def noop_callback(k, x, y)
Callback function: arguments key, x, y.
Definition: interface.py:700
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:72
def setDefaultMaskPlaneColor(name=None, color=None)
Set the default mapping from mask plane names to colours.
Definition: interface.py:742
def setDefaultMaskTransparency(maskPlaneTransparency={})
Definition: interface.py:738
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:655
def __init__(self, k, x=float('nan'), y=float('nan'))
Definition: interface.py:688
def setDefaultImageColormap(cmap)
Set the default colourmap for images.
Definition: interface.py:305
def erase(self)
Erase the specified DISPLAY frame.
Definition: interface.py:514
def flush(self)
Flush the buffers.
Definition: interface.py:510
def delAllDisplays()
Delete and close all known display.
Definition: interface.py:352
def getActiveCallbackKeys(self, onlyActive=True)
Return all callback keys.
Definition: interface.py:672
A class to handle events such as key presses in image display windows.
Definition: interface.py:685
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:78
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:716
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:588
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:74
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:558
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:770
def interact(self)
Enter an interactive loop, listening for key presses in display and firing callbacks.
Definition: interface.py:634
daf::base::PropertyList * list
Definition: fits.cc:819
def setDefaultFrame(frame=0)
Definition: interface.py:724
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:608
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:59
def setDefaultMaskTransparency(maskPlaneTransparency={})
Definition: interface.py:276
A container for an Image and its associated metadata.
Definition: Image.h:398
def show(self)
Uniconify and Raise display.
Definition: interface.py:441