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