lsst.afw  13.0-100-ge0459d59f+2
interface.py
Go to the documentation of this file.
1 from __future__ import absolute_import, division, 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 
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 def _makeDisplayImpl(display, backend, *args, **kwargs):
63  """!Return the DisplayImpl for the named backend
64 
65  \param display Name of device. Should be importable, either absolutely or relative to lsst.display
66  \param backend The desired backend
67  \param args Arguments passed to DisplayImpl.__init__
68  \param kwargs Keywords arguments passed to DisplayImpl.__init__
69 
70  E.g.
71  import lsst.afw.display as afwDisplay
72  display = afwDisplay.Display(display=1, backend="ds9")
73  would call
74  _makeDisplayImpl(..., "ds9", 1)
75  and import the ds9 implementation of DisplayImpl from lsst.display.ds9
76  """
77  _disp = None
78  exc = None
79  for dt in ("lsst.display.%s" % backend, backend, ".%s" % backend, "lsst.afw.display.%s" % backend):
80  exc = None
81  # only specify the root package if we are not doing an absolute import
82  impargs = {}
83  if dt.startswith("."):
84  impargs["package"] = "lsst.display"
85  try:
86  _disp = importlib.import_module(dt, **impargs)
87  break
88  except (ImportError, SystemError) as e:
89  # SystemError can be raised in Python 3.5 if a relative import
90  # is attempted when the root package, lsst.display, does not exist.
91  # Copy the exception into outer scope
92  exc = e
93 
94  if not _disp or not hasattr(_disp.DisplayImpl, "_show"):
95  if exc is not None:
96  # re-raise the final exception
97  raise exc
98  else:
99  raise ImportError(
100  "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 class Display(object):
113  _displays = {}
114  _defaultBackend = None
115  _defaultFrame = 0
116  _defaultMaskPlaneColor = dict(
117  BAD=RED,
118  CR=MAGENTA,
119  EDGE=YELLOW,
120  INTERPOLATED=GREEN,
121  SATURATED=GREEN,
122  DETECTED=BLUE,
123  DETECTED_NEGATIVE=CYAN,
124  SUSPECT=YELLOW,
125  NO_DATA=ORANGE,
126  # deprecated names
127  INTRP=GREEN,
128  SAT=GREEN,
129  )
130  _defaultMaskTransparency = {}
131 
132  def __init__(self, frame=None, backend=None, *args, **kwargs):
133  """!Create an object able to display images and overplot glyphs
134 
135  \param frame An identifier for the display
136  \param backend The backend to use (defaults to value set by setDefaultBackend())
137  \param args Arguments to pass to the backend
138  \param kwargs Arguments to pass to the backend
139  """
140  if frame is None:
141  frame = getDefaultFrame()
142 
143  if backend is None:
144  if Display._defaultBackend is None:
145  try:
146  setDefaultBackend("ds9")
147  except RuntimeError:
148  setDefaultBackend("virtualDevice")
149 
150  backend = Display._defaultBackend
151 
152  self.frame = frame
153  self._impl = _makeDisplayImpl(self, backend, *args, **kwargs)
154  self.name = backend
155 
156  self._xy0 = None # the data displayed on the frame's XY0
157  self.setMaskTransparency(Display._defaultMaskTransparency)
158  self._maskPlaneColors = {}
159  self.setMaskPlaneColor(Display._defaultMaskPlaneColor)
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 hasattr(self, "_impl") and self._impl:
222  del self._impl
223  self._impl = None
224 
225  if self.frame in Display._displays:
226  del Display._displays[self.frame]
227 
228  @property
229  def verbose(self):
230  """!The backend's verbosity"""
231  return self._impl.verbose
232 
233  @verbose.setter
234  def verbose(self, value):
235  if self._impl:
236  self._impl.verbose = value
237 
238  def __str__(self):
239  return "Display[%s]" % (self.frame)
240 
241  #
242  # Handle Displays, including the default one (the frame to use when a user specifies None)
243  #
244  @staticmethod
245  def setDefaultBackend(backend):
246  try:
247  _makeDisplayImpl(None, backend)
248  except Exception as e:
249  raise RuntimeError(
250  "Unable to set backend to %s: \"%s\"" % (backend, e))
251 
252  Display._defaultBackend = backend
253 
254  @staticmethod
256  return Display._defaultBackend
257 
258  @staticmethod
259  def setDefaultFrame(frame=0):
260  """Set the default frame for display"""
261  Display._defaultFrame = frame
262 
263  @staticmethod
265  """Get the default frame for display"""
266  return Display._defaultFrame
267 
268  @staticmethod
270  """Increment the default frame for display"""
271  Display._defaultFrame += 1
272  return Display._defaultFrame
273 
274  @staticmethod
275  def setDefaultMaskTransparency(maskPlaneTransparency={}):
276  if hasattr(maskPlaneTransparency, "copy"):
277  maskPlaneTransparency = maskPlaneTransparency.copy()
278 
279  Display._defaultMaskTransparency = maskPlaneTransparency
280 
281  @staticmethod
282  def setDefaultMaskPlaneColor(name=None, color=None):
283  """!Set the default mapping from mask plane names to colours
284  \param name name of mask plane, or a dict mapping names to colours
285  \param color Desired color, or None if name is a dict
286 
287  If name is None, use the hard-coded default dictionary
288  """
289 
290  if name is None:
291  name = Display._defaultMaskPlaneColor
292 
293  if isinstance(name, dict):
294  assert color is None
295  for k, v in name.items():
297  return
298  #
299  # Set the individual colour values
300  #
301  Display._defaultMaskPlaneColor[name] = color
302 
303  @staticmethod
304  def getDisplay(frame=None, backend=None, create=True, verbose=False, *args, **kwargs):
305  """!Return the Display indexed by frame, creating it if needs be
306 
307  \param frame The desired frame (None => use defaultFrame (see setDefaultFrame))
308  \param backend create the specified frame using this backend (or the default if None) \
309  if it doesn't already exist. If backend == "", it's an error to specify a non-existent frame
310  \param create create the display if it doesn't already exist.
311  \param verbose Allow backend to be chatty
312  \param args arguments passed to Display constructor
313  \param kwargs keyword arguments passed to Display constructor
314  """
315 
316  if frame is None:
317  frame = Display._defaultFrame
318 
319  if frame not in Display._displays:
320  if backend == "":
321  raise RuntimeError("Frame %s does not exist" % frame)
322 
323  Display._displays[frame] = Display(
324  frame, backend, verbose=verbose, *args, **kwargs)
325 
326  Display._displays[frame].verbose = verbose
327  return Display._displays[frame]
328 
329  @staticmethod
331  """!Delete and close all known display
332  """
333  for disp in list(Display._displays.values()):
334  disp.close()
335  Display._displays = {}
336 
337  def maskColorGenerator(self, omitBW=True):
338  """!A generator for "standard" colours
339 
340  \param omitBW Don't include Black and White
341 
342  e.g.
343  colorGenerator = interface.maskColorGenerator(omitBW=True)
344  for p in planeList:
345  print p, next(colorGenerator)
346  """
347  _maskColors = [WHITE, BLACK, RED, GREEN,
348  BLUE, CYAN, MAGENTA, YELLOW, ORANGE]
349 
350  i = -1
351  while True:
352  i += 1
353  color = _maskColors[i%len(_maskColors)]
354  if omitBW and color in (BLACK, WHITE):
355  continue
356 
357  yield color
358 
359  def setMaskPlaneColor(self, name, color=None):
360  """!Request that mask plane name be displayed as color
361 
362  \param name Name of mask plane or a dictionary of name -> colourName
363  \param color The name of the colour to use (must be None if name is a dict)
364 
365  Colours may be specified as any X11-compliant string (e.g. <tt>"orchid"</tt>), or by one
366  of the following constants defined in \c afwDisplay: \c BLACK, \c WHITE, \c RED, \c BLUE,
367  \c GREEN, \c CYAN, \c MAGENTA, \c YELLOW.
368 
369  The advantage of using the symbolic names is that the python interpreter can detect typos.
370 
371  """
372 
373  if isinstance(name, dict):
374  assert color is None
375  for k, v in name.items():
376  self.setMaskPlaneColor(k, v)
377  return
378 
379  self._maskPlaneColors[name] = color
380 
381  def getMaskPlaneColor(self, name):
382  """!Return the colour associated with the specified mask plane name"""
383 
384  return self._maskPlaneColors.get(name)
385 
386  def setMaskTransparency(self, transparency=None, name=None):
387  """!Specify display's mask transparency (percent); or None to not set it when loading masks"""
388 
389  if isinstance(transparency, dict):
390  assert name is None
391  for k, v in transparency.items():
392  self.setMaskTransparency(k, v)
393  return
394 
395  if transparency is not None and (transparency < 0 or transparency > 100):
396  print(
397  "Mask transparency should be in the range [0, 100]; clipping", file=sys.stderr)
398  if transparency < 0:
399  transparency = 0
400  else:
401  transparency = 100
402 
403  if transparency is not None:
404  self._impl._setMaskTransparency(transparency, name)
405 
406  def getMaskTransparency(self, name=None):
407  """!Return the current display's mask transparency"""
408 
409  return self._impl._getMaskTransparency(name)
410 
411  def show(self):
412  """!Uniconify and Raise display. N.b. throws an exception if frame doesn't exit"""
413  return self._impl._show()
414 
415  def mtv(self, data, title="", wcs=None):
416  """!Display an Image or Mask on a DISPLAY display
417 
418  Historical note: the name "mtv" comes from Jim Gunn's forth imageprocessing
419  system, Mirella (named after Mirella Freni); The "m" stands for Mirella.
420  """
421  if hasattr(data, "getXY0"):
422  self._xy0 = data.getXY0()
423  else:
424  self._xy0 = None
425 
426  # it's an Exposure; display the MaskedImage with the WCS
427  if isinstance(data, afwImage.Exposure):
428  if wcs:
429  raise RuntimeError(
430  "You may not specify a wcs with an Exposure")
431  data, wcs = data.getMaskedImage(), data.getWcs()
432  elif isinstance(data, afwImage.DecoratedImage): # it's a DecoratedImage; display it
433  data, wcs = data.getImage(), afwImage.makeWcs(data.getMetadata())
434  self._xy0 = data.getXY0() # DecoratedImage doesn't have getXY0()
435 
436  if isinstance(data, afwImage.Image): # it's an Image; display it
437  self._impl._mtv(data, None, wcs, title)
438  # it's a Mask; display it, bitplane by bitplane
439  elif isinstance(data, afwImage.Mask):
440  #
441  # Some displays can't display a Mask without an image; so display an Image too,
442  # with pixel values set to the mask
443  #
444  self._impl._mtv(afwImage.ImageI(data.getArray()), data, wcs, title)
445  # it's a MaskedImage; display Image and overlay Mask
446  elif isinstance(data, afwImage.MaskedImage):
447  self._impl._mtv(data.getImage(), data.getMask(), wcs, title)
448  else:
449  raise RuntimeError("Unsupported type %s" % repr(data))
450  #
451  # Graphics commands
452  #
453 
454  class _Buffering(object):
455  """A class intended to be used with python's with statement"""
456 
457  def __init__(self, _impl):
458  self._impl = _impl
459 
460  def __enter__(self):
461  self._impl._buffer(True)
462 
463  def __exit__(self, *args):
464  self._impl._buffer(False)
465  self._impl._flush()
466 
467  def Buffering(self):
468  """Return a class intended to be used with python's with statement
469  E.g.
470  with display.Buffering():
471  display.dot("+", xc, yc)
472  """
473  return self._Buffering(self._impl)
474 
475  def flush(self):
476  """!Flush the buffers"""
477  self._impl._flush()
478 
479  def erase(self):
480  """!Erase the specified DISPLAY frame
481  """
482  self._impl._erase()
483 
484  def dot(self, symb, c, r, size=2, ctype=None, origin=afwImage.PARENT, *args, **kwargs):
485  """!Draw a symbol onto the specified DISPLAY frame at (col,row) = (c,r)
486  [0-based coordinates]
487 
488  Possible values are:
489  + Draw a +
490  x Draw an x
491  * Draw a *
492  o Draw a circle
493  @:Mxx,Mxy,Myy Draw an ellipse with moments (Mxx, Mxy, Myy) (argument size is ignored)
494  An object derived from afwGeom.ellipses.BaseCore Draw the ellipse (argument size is ignored)
495  Any other value is interpreted as a string to be drawn. Strings obey the fontFamily (which may be
496  extended with other characteristics, e.g. "times bold italic". Text will be drawn rotated by
497  textAngle (textAngle is ignored otherwise).
498 
499  N.b. objects derived from BaseCore include Axes and Quadrupole.
500  """
501  if isinstance(symb, int):
502  symb = "%d" % (symb)
503 
504  if origin == afwImage.PARENT and self._xy0 is not None:
505  x0, y0 = self._xy0
506  r -= y0
507  c -= x0
508 
509  if isinstance(symb, afwGeom.ellipses.BaseCore) or re.search(r"^@:", symb):
510  try:
511  mat = re.search(r"^@:([^,]+),([^,]+),([^,]+)", symb)
512  except TypeError:
513  pass
514  else:
515  if mat:
516  mxx, mxy, myy = [float(_) for _ in mat.groups()]
517  symb = afwGeom.ellipses.Quadrupole(mxx, myy, mxy)
518 
519  symb = afwGeom.ellipses.Axes(symb)
520 
521  self._impl._dot(symb, c, r, size, ctype, **kwargs)
522 
523  def line(self, points, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5):
524  """!Draw a set of symbols or connect the points, a list of (col,row)
525  If symbs is True, draw points at the specified points using the desired symbol,
526  otherwise connect the dots. Ctype is the name of a colour (e.g. 'red')
527 
528  If symbs supports indexing (which includes a string -- caveat emptor) the
529  elements are used to label the points
530  """
531  if symbs:
532  try:
533  symbs[1]
534  except:
535  symbs = len(points)*list(symbs)
536 
537  for i, xy in enumerate(points):
538  self.dot(symbs[i], *xy, size=size, ctype=ctype)
539  else:
540  if len(points) > 0:
541  if origin == afwImage.PARENT and self._xy0 is not None:
542  x0, y0 = self._xy0
543  _points = list(points) # make a mutable copy
544  for i, p in enumerate(points):
545  _points[i] = (p[0] - x0, p[1] - y0)
546  points = _points
547 
548  self._impl._drawLines(points, ctype)
549  #
550  # Set gray scale
551  #
552 
553  def scale(self, algorithm, min, max=None, unit=None, *args, **kwargs):
554  """!Set the range of the scaling from DN in the image to the image display
555  \param algorithm Desired scaling (e.g. "linear" or "asinh")
556  \param min Minimum value, or "minmax" or "zscale"
557  \param max Maximum value (must be None for minmax|zscale)
558  \param unit Units for min and max (e.g. Percent, Absolute, Sigma; None if min==minmax|zscale)
559  \param *args Optional arguments
560  \param **kwargs Optional keyword arguments
561  """
562  if min in ("minmax", "zscale"):
563  assert max is None, "You may not specify \"%s\" and max" % min
564  assert unit is None, "You may not specify \"%s\" and unit" % min
565  elif max is None:
566  raise RuntimeError("Please specify max")
567 
568  self._impl._scale(algorithm, min, max, unit, *args, **kwargs)
569  #
570  # Zoom and Pan
571  #
572 
573  def zoom(self, zoomfac=None, colc=None, rowc=None, origin=afwImage.PARENT):
574  """!Zoom frame by specified amount, optionally panning also"""
575 
576  if (rowc and colc is None) or (colc and rowc is None):
577  raise RuntimeError(
578  "Please specify row and column center to pan about")
579 
580  if rowc is not None:
581  if origin == afwImage.PARENT and self._xy0 is not None:
582  x0, y0 = self._xy0
583  rowc -= x0
584  colc -= y0
585 
586  self._impl._pan(colc, rowc)
587 
588  if zoomfac is None and rowc is None:
589  zoomfac = 2
590 
591  if zoomfac is not None:
592  self._impl._zoom(zoomfac)
593 
594  def pan(self, colc=None, rowc=None, origin=afwImage.PARENT):
595  """!Pan to (rowc, colc); see also zoom"""
596 
597  self.zoom(None, colc, rowc, origin)
598 
599  def interact(self):
600  """!Enter an interactive loop, listening for key presses in display and firing callbacks.
601  Exit with q, \c CR, \c ESC, or any other callback function that returns a ``True`` value.
602  """
603  interactFinished = False
604 
605  while not interactFinished:
606  ev = self._impl._getEvent()
607  if not ev:
608  continue
609  k, x, y = ev.k, ev.x, ev.y # for now
610 
611  if k not in self._callbacks:
612  logger.warn("No callback registered for {0}".format(k))
613  else:
614  try:
615  interactFinished = self._callbacks[k](k, x, y)
616  except Exception as e:
617  logger.error(
618  "Display._callbacks['{0}']({0},{1},{2}) failed: {3}".format(k, x, y, e))
619 
620  def setCallback(self, k, func=None, noRaise=False):
621  """!Set the callback for key k to be func, returning the old callback
622  """
623 
624  if k in "f":
625  if noRaise:
626  return
627  raise RuntimeError(
628  "Key '%s' is already in use by display, so I can't add a callback for it" % k)
629 
630  ofunc = self._callbacks.get(k)
631  self._callbacks[k] = func if func else noop_callback
632 
633  self._impl._setCallback(k, self._callbacks[k])
634 
635  return ofunc
636 
637  def getActiveCallbackKeys(self, onlyActive=True):
638  """!Return all callback keys
639  \param onlyActive If true only return keys that do something
640  """
641 
642  return sorted([k for k, func in self._callbacks.items() if
643  not (onlyActive and func == noop_callback)])
644 
645 #
646 # Callbacks for display events
647 #
648 
649 
650 class Event(object):
651  """!A class to handle events such as key presses in image display windows"""
652 
653  def __init__(self, k, x=float('nan'), y=float('nan')):
654  self.k = k
655  self.x = x
656  self.y = y
657 
658  def __str__(self):
659  return "%s (%.2f, %.2f)" % (self.k, self.x, self.y)
660 #
661 # Default fallback function
662 #
663 
664 
665 def noop_callback(k, x, y):
666  """!Callback function: arguments key, x, y"""
667  return False
668 
669 
670 def h_callback(k, x, y):
671  print("Enter q or <ESC> to leave interactive mode, h for this help, or a letter to fire a callback")
672  return False
673 
674 #
675 # Handle Displays, including the default one (the frame to use when a user specifies None)
676 #
677 # If the default frame is None, image display is disabled
678 #
679 
680 
681 def setDefaultBackend(backend):
682  Display.setDefaultBackend(backend)
683 
684 
686  return Display.getDefaultBackend()
687 
688 
689 def setDefaultFrame(frame=0):
690  return Display.setDefaultFrame(frame)
691 
692 
694  """Get the default frame for display"""
695  return Display.getDefaultFrame()
696 
697 
699  """Increment the default frame for display"""
700  return Display.incrDefaultFrame()
701 
702 
703 def setDefaultMaskTransparency(maskPlaneTransparency={}):
704  return Display.setDefaultMaskTransparency(maskPlaneTransparency)
705 
706 
707 def setDefaultMaskPlaneColor(name=None, color=None):
708  """!Set the default mapping from mask plane names to colours
709  \param name name of mask plane, or a dict mapping names to colours
710  \param color Desired color, or None if name is a dict
711 
712  If name is None, use the hard-coded default dictionary
713  """
714 
715  return Display.setDefaultMaskPlaneColor(name, color)
716 
717 
718 def getDisplay(frame=None, backend=None, create=True, verbose=False, *args, **kwargs):
719  """!Return the Display indexed by frame, creating it if needs be
720 
721  See Display.getDisplay
722 
723  \param frame The desired frame (None => use defaultFrame (see setDefaultFrame))
724  \param backend create the specified frame using this backend (or the default if None) \
725  if it doesn't already exist. If backend == "", it's an error to specify a non-existent frame
726  \param create create the display if it doesn't already exist.
727  \param verbose Allow backend to be chatty
728  \param args arguments passed to Display constructor
729  \param kwargs keyword arguments passed to Display constructor
730  """
731 
732  return Display.getDisplay(frame, backend, create, verbose, *args, **kwargs)
733 
734 
736  """!Delete and close all known display
737  """
738  return Display.delAllDisplays()
def pan(self, colc=None, rowc=None, origin=afwImage.PARENT)
Pan to (rowc, colc); see also zoom.
Definition: interface.py:594
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:484
def maskColorGenerator(self, omitBW=True)
A generator for "standard" colours.
Definition: interface.py:337
def verbose(self)
The backend&#39;s verbosity.
Definition: interface.py:229
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:718
def noop_callback(k, x, y)
Callback function: arguments key, x, y.
Definition: interface.py:665
A class to contain the data, WCS, and other information needed to describe an image of the sky...
Definition: Exposure.h:76
def setDefaultMaskPlaneColor(name=None, color=None)
Set the default mapping from mask plane names to colours.
Definition: interface.py:707
def setDefaultMaskTransparency(maskPlaneTransparency={})
Definition: interface.py:703
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:304
def setCallback(self, k, func=None, noRaise=False)
Set the callback for key k to be func, returning the old callback.
Definition: interface.py:620
def __init__(self, k, x=float('nan'), y=float('nan'))
Definition: interface.py:653
def erase(self)
Erase the specified DISPLAY frame.
Definition: interface.py:479
def getMaskPlaneColor(self, name)
Return the colour associated with the specified mask plane name.
Definition: interface.py:381
def flush(self)
Flush the buffers.
Definition: interface.py:475
def delAllDisplays()
Delete and close all known display.
Definition: interface.py:330
def getActiveCallbackKeys(self, onlyActive=True)
Return all callback keys.
Definition: interface.py:637
A class to handle events such as key presses in image display windows.
Definition: interface.py:650
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:83
def setDefaultBackend(backend)
Definition: interface.py:681
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:553
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:132
def mtv(self, data, title="", wcs=None)
Display an Image or Mask on a DISPLAY display.
Definition: interface.py:415
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:282
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:523
def setMaskPlaneColor(self, name, color=None)
Request that mask plane name be displayed as color.
Definition: interface.py:359
def getMaskTransparency(self, name=None)
Return the current display&#39;s mask transparency.
Definition: interface.py:406
def delAllDisplays()
Delete and close all known display.
Definition: interface.py:735
def interact(self)
Enter an interactive loop, listening for key presses in display and firing callbacks.
Definition: interface.py:599
def setDefaultFrame(frame=0)
Definition: interface.py:689
std::shared_ptr< Wcs > makeWcs(std::shared_ptr< daf::base::PropertySet > const &_metadata, bool stripMetadata)
Definition: makeWcs.cc:37
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:386
def zoom(self, zoomfac=None, colc=None, rowc=None, origin=afwImage.PARENT)
Zoom frame by specified amount, optionally panning also.
Definition: interface.py:573
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:68
def setDefaultMaskTransparency(maskPlaneTransparency={})
Definition: interface.py:275
A container for an Image and its associated metadata.
Definition: Image.h:391
def show(self)
Uniconify and Raise display.
Definition: interface.py:411