LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
lsst.afw.display.interface.Display Class Reference

Classes

class  _Buffering
 

Public Member Functions

def __init__ (self, frame=None, backend=None, *args, **kwargs)
 
def __enter__ (self)
 
def __exit__ (self, *args)
 
def __del__ (self)
 
def __getattr__ (self, name)
 
def close (self)
 
def verbose (self)
 
def verbose (self, value)
 
def __str__ (self)
 
def setImageColormap (self, cmap)
 
def maskColorGenerator (self, omitBW=True)
 
def setMaskPlaneColor (self, name, color=None)
 
def getMaskPlaneColor (self, name=None)
 
def setMaskTransparency (self, transparency=None, name=None)
 
def getMaskTransparency (self, name=None)
 
def show (self)
 
def mtv (self, data, title="", wcs=None)
 
def Buffering (self)
 
def flush (self)
 
def erase (self)
 
def dot (self, symb, c, r, size=2, ctype=None, origin=afwImage.PARENT, *args, **kwargs)
 
def line (self, points, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5)
 
def scale (self, algorithm, min, max=None, unit=None, *args, **kwargs)
 
def zoom (self, zoomfac=None, colc=None, rowc=None, origin=afwImage.PARENT)
 
def pan (self, colc=None, rowc=None, origin=afwImage.PARENT)
 
def interact (self)
 
def setCallback (self, k, func=None, noRaise=False)
 
def getActiveCallbackKeys (self, onlyActive=True)
 

Static Public Member Functions

def setDefaultBackend (backend)
 
def getDefaultBackend ()
 
def setDefaultFrame (frame=0)
 
def getDefaultFrame ()
 
def incrDefaultFrame ()
 
def setDefaultMaskTransparency (maskPlaneTransparency={})
 
def setDefaultMaskPlaneColor (name=None, color=None)
 
def setDefaultImageColormap (cmap)
 
def getDisplay (frame=None, backend=None, create=True, verbose=False, *args, **kwargs)
 
def delAllDisplays ()
 

Public Attributes

 frame
 
 name
 

Detailed Description

Create an object able to display images and overplot glyphs

Parameters
----------
frame
    An identifier for the display
backend : `str`
    The backend to use (defaults to value set by setDefaultBackend())
*args
    Arguments to pass to the backend
**kwargs
    Arguments to pass to the backend

Definition at line 118 of file interface.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.afw.display.interface.Display.__init__ (   self,
  frame = None,
  backend = None,
args,
**  kwargs 
)

Definition at line 152 of file interface.py.

152  def __init__(self, frame=None, backend=None, *args, **kwargs):
153  if frame is None:
154  frame = getDefaultFrame()
155 
156  if backend is None:
157  if Display._defaultBackend is None:
158  try:
159  setDefaultBackend("ds9")
160  except RuntimeError:
161  setDefaultBackend("virtualDevice")
162 
163  backend = Display._defaultBackend
164 
165  self.frame = frame
166  self._impl = _makeDisplayImpl(self, backend, *args, **kwargs)
167  self.name = backend
168 
169  self._xy0 = None # displayed data's XY0
170  self.setMaskTransparency(Display._defaultMaskTransparency)
171  self._maskPlaneColors = {}
172  self.setMaskPlaneColor(Display._defaultMaskPlaneColor)
173  self.setImageColormap(Display._defaultImageColormap)
174 
175  self._callbacks = {}
176 
177  for ik in range(ord('a'), ord('z') + 1):
178  k = f"{ik:c}"
179  self.setCallback(k, noRaise=True)
180  self.setCallback(k.upper(), noRaise=True)
181 
182  for k in ('Return', 'Shift_L', 'Shift_R'):
183  self.setCallback(k)
184 
185  for k in ('q', 'Escape'):
186  self.setCallback(k, lambda k, x, y: True)
187 
188  def _h_callback(k, x, y):
189  h_callback(k, x, y)
190 
191  for k in sorted(self._callbacks.keys()):
192  doc = self._callbacks[k].__doc__
193  print(" %-6s %s" % (k, doc.split("\n")[0] if doc else "???"))
194 
195  self.setCallback('h', _h_callback)
196 
197  Display._displays[frame] = self
198 
def setDefaultBackend(backend)
Definition: interface.py:870

◆ __del__()

def lsst.afw.display.interface.Display.__del__ (   self)

Definition at line 209 of file interface.py.

209  def __del__(self):
210  self.close()
211 

Member Function Documentation

◆ __enter__()

def lsst.afw.display.interface.Display.__enter__ (   self)
Support for python's with statement

Definition at line 199 of file interface.py.

199  def __enter__(self):
200  """Support for python's with statement
201  """
202  return self
203 

◆ __exit__()

def lsst.afw.display.interface.Display.__exit__ (   self,
args 
)
Support for python's with statement

Definition at line 204 of file interface.py.

204  def __exit__(self, *args):
205  """Support for python's with statement
206  """
207  self.close()
208 

◆ __getattr__()

def lsst.afw.display.interface.Display.__getattr__ (   self,
  name 
)
Return the attribute of ``self._impl``, or ``._impl`` if it is requested

Parameters:
-----------
name : `str`
    name of the attribute requested

Returns:
--------
attribute : `object`
    the attribute of self._impl for the requested name

Definition at line 212 of file interface.py.

212  def __getattr__(self, name):
213  """Return the attribute of ``self._impl``, or ``._impl`` if it is requested
214 
215  Parameters:
216  -----------
217  name : `str`
218  name of the attribute requested
219 
220  Returns:
221  --------
222  attribute : `object`
223  the attribute of self._impl for the requested name
224  """
225 
226  if name == '_impl':
227  return object.__getattr__(self, name)
228 
229  if not (hasattr(self, "_impl") and self._impl):
230  raise AttributeError("Device has no _impl attached")
231 
232  try:
233  return getattr(self._impl, name)
234  except AttributeError:
235  raise AttributeError(
236  f"Device {self.name} has no attribute \"{name}\"")
237 

◆ __str__()

def lsst.afw.display.interface.Display.__str__ (   self)

Definition at line 258 of file interface.py.

258  def __str__(self):
259  return f"Display[{self.frame}]"
260 

◆ Buffering()

def lsst.afw.display.interface.Display.Buffering (   self)
Return a class intended to be used with python's with statement

Examples
--------
.. code-block:: py

   with display.Buffering():
       display.dot("+", xc, yc)

Definition at line 572 of file interface.py.

572  def Buffering(self):
573  """Return a class intended to be used with python's with statement
574 
575  Examples
576  --------
577  .. code-block:: py
578 
579  with display.Buffering():
580  display.dot("+", xc, yc)
581  """
582  return self._Buffering(self._impl)
583 
def Buffering()
Definition: ds9.py:63

◆ close()

def lsst.afw.display.interface.Display.close (   self)

Definition at line 238 of file interface.py.

238  def close(self):
239  if getattr(self, "_impl", None) is not None:
240  self._impl._close()
241  del self._impl
242  self._impl = None
243 
244  if self.frame in Display._displays:
245  del Display._displays[self.frame]
246 

◆ delAllDisplays()

def lsst.afw.display.interface.Display.delAllDisplays ( )
static
Delete and close all known displays

Definition at line 399 of file interface.py.

399  def delAllDisplays():
400  """Delete and close all known displays
401  """
402  for disp in list(Display._displays.values()):
403  disp.close()
404  Display._displays = {}
405 
daf::base::PropertyList * list
Definition: fits.cc:913

◆ dot()

def lsst.afw.display.interface.Display.dot (   self,
  symb,
  c,
  r,
  size = 2,
  ctype = None,
  origin = afwImage.PARENT,
args,
**  kwargs 
)
Draw a symbol onto the specified display frame

Parameters
----------
symb
    Possible values are:

        ``"+"``
            Draw a +
        ``"x"``
            Draw an x
        ``"*"``
            Draw a *
        ``"o"``
            Draw a circle
        ``"@:Mxx,Mxy,Myy"``
            Draw an ellipse with moments (Mxx, Mxy, Myy) (argument size is ignored)
        `lsst.afw.geom.ellipses.BaseCore`
            Draw the ellipse (argument size is ignored). N.b. objects
            derived from `~lsst.afw.geom.ellipses.BaseCore` include
            `~lsst.afw.geom.ellipses.Axes` and `~lsst.afw.geom.ellipses.Quadrupole`.
        Any other value
            Interpreted as a string to be drawn.
c, r
    The column and row where the symbol is drawn [0-based coordinates]
size : `int`
    Size of symbol, in pixels
ctype : `str`
    The desired color, either e.g. `lsst.afw.display.RED` or a color name known to X11
origin : `lsst.afw.image.ImageOrigin`
    Coordinate system for the given positions.
*args
    Extra arguments to backend
**kwargs
    Extra keyword arguments to backend

Definition at line 594 of file interface.py.

594  def dot(self, symb, c, r, size=2, ctype=None, origin=afwImage.PARENT, *args, **kwargs):
595  """Draw a symbol onto the specified display frame
596 
597  Parameters
598  ----------
599  symb
600  Possible values are:
601 
602  ``"+"``
603  Draw a +
604  ``"x"``
605  Draw an x
606  ``"*"``
607  Draw a *
608  ``"o"``
609  Draw a circle
610  ``"@:Mxx,Mxy,Myy"``
611  Draw an ellipse with moments (Mxx, Mxy, Myy) (argument size is ignored)
612  `lsst.afw.geom.ellipses.BaseCore`
613  Draw the ellipse (argument size is ignored). N.b. objects
614  derived from `~lsst.afw.geom.ellipses.BaseCore` include
615  `~lsst.afw.geom.ellipses.Axes` and `~lsst.afw.geom.ellipses.Quadrupole`.
616  Any other value
617  Interpreted as a string to be drawn.
618  c, r
619  The column and row where the symbol is drawn [0-based coordinates]
620  size : `int`
621  Size of symbol, in pixels
622  ctype : `str`
623  The desired color, either e.g. `lsst.afw.display.RED` or a color name known to X11
624  origin : `lsst.afw.image.ImageOrigin`
625  Coordinate system for the given positions.
626  *args
627  Extra arguments to backend
628  **kwargs
629  Extra keyword arguments to backend
630  """
631  if isinstance(symb, int):
632  symb = f"{symb:d}"
633 
634  if origin == afwImage.PARENT and self._xy0 is not None:
635  x0, y0 = self._xy0
636  r -= y0
637  c -= x0
638 
639  if isinstance(symb, afwGeom.ellipses.BaseCore) or re.search(r"^@:", symb):
640  try:
641  mat = re.search(r"^@:([^,]+),([^,]+),([^,]+)", symb)
642  except TypeError:
643  pass
644  else:
645  if mat:
646  mxx, mxy, myy = [float(_) for _ in mat.groups()]
647  symb = afwGeom.Quadrupole(mxx, myy, mxy)
648 
649  symb = afwGeom.ellipses.Axes(symb)
650 
651  self._impl._dot(symb, c, r, size, ctype, **kwargs)
652 
An ellipse core with quadrupole moments as parameters.
Definition: Quadrupole.h:47
def dot(symb, c, r, frame=None, size=2, ctype=None, origin=afwImage.PARENT, *args, **kwargs)
Definition: ds9.py:100

◆ erase()

def lsst.afw.display.interface.Display.erase (   self)
Erase the specified display frame

Definition at line 589 of file interface.py.

589  def erase(self):
590  """Erase the specified display frame
591  """
592  self._impl._erase()
593 
def erase(frame=None)
Definition: ds9.py:96

◆ flush()

def lsst.afw.display.interface.Display.flush (   self)
Flush the buffers

Definition at line 584 of file interface.py.

584  def flush(self):
585  """Flush the buffers
586  """
587  self._impl._flush()
588 

◆ getActiveCallbackKeys()

def lsst.afw.display.interface.Display.getActiveCallbackKeys (   self,
  onlyActive = True 
)
Return all callback keys

Parameters
----------
onlyActive : `bool`
    If `True` only return keys that do something

Definition at line 814 of file interface.py.

814  def getActiveCallbackKeys(self, onlyActive=True):
815  """Return all callback keys
816 
817  Parameters
818  ----------
819  onlyActive : `bool`
820  If `True` only return keys that do something
821  """
822 
823  return sorted([k for k, func in self._callbacks.items() if
824  not (onlyActive and func == noop_callback)])
825 
826 #
827 # Callbacks for display events
828 #
829 
830 
std::vector< SchemaItem< Flag > > * items
def getActiveCallbackKeys(onlyActive=True, frame=None)
Definition: ds9.py:133

◆ getDefaultBackend()

def lsst.afw.display.interface.Display.getDefaultBackend ( )
static

Definition at line 275 of file interface.py.

275  def getDefaultBackend():
276  return Display._defaultBackend
277 

◆ getDefaultFrame()

def lsst.afw.display.interface.Display.getDefaultFrame ( )
static
Get the default frame for display

Definition at line 285 of file interface.py.

285  def getDefaultFrame():
286  """Get the default frame for display
287  """
288  return Display._defaultFrame
289 

◆ getDisplay()

def lsst.afw.display.interface.Display.getDisplay (   frame = None,
  backend = None,
  create = True,
  verbose = False,
args,
**  kwargs 
)
static
Return a specific `Display`, creating it if need be

Parameters
----------
frame
    The desired frame (`None` => use defaultFrame (see `~Display.setDefaultFrame`))
backend : `str`
    create the specified frame using this backend (or the default if
    `None`) if it doesn't already exist. If ``backend == ""``, it's an
    error to specify a non-existent ``frame``.
create : `bool`
    create the display if it doesn't already exist.
verbose : `bool`
    Allow backend to be chatty
*args
    arguments passed to `Display` constructor
**kwargs
    keyword arguments passed to `Display` constructor

Definition at line 364 of file interface.py.

364  def getDisplay(frame=None, backend=None, create=True, verbose=False, *args, **kwargs):
365  """Return a specific `Display`, creating it if need be
366 
367  Parameters
368  ----------
369  frame
370  The desired frame (`None` => use defaultFrame (see `~Display.setDefaultFrame`))
371  backend : `str`
372  create the specified frame using this backend (or the default if
373  `None`) if it doesn't already exist. If ``backend == ""``, it's an
374  error to specify a non-existent ``frame``.
375  create : `bool`
376  create the display if it doesn't already exist.
377  verbose : `bool`
378  Allow backend to be chatty
379  *args
380  arguments passed to `Display` constructor
381  **kwargs
382  keyword arguments passed to `Display` constructor
383  """
384 
385  if frame is None:
386  frame = Display._defaultFrame
387 
388  if frame not in Display._displays:
389  if backend == "":
390  raise RuntimeError(f"Frame {frame} does not exist")
391 
392  Display._displays[frame] = Display(
393  frame, backend, verbose=verbose, *args, **kwargs)
394 
395  Display._displays[frame].verbose = verbose
396  return Display._displays[frame]
397 
def getDisplay(frame=None, backend=None, create=True, verbose=False, *args, **kwargs)
Definition: interface.py:913

◆ getMaskPlaneColor()

def lsst.afw.display.interface.Display.getMaskPlaneColor (   self,
  name = None 
)
Return the color associated with the specified mask plane name

Parameters
----------
name : `str`
    Desired mask plane; if `None`, return entire dict

Definition at line 462 of file interface.py.

462  def getMaskPlaneColor(self, name=None):
463  """Return the color associated with the specified mask plane name
464 
465  Parameters
466  ----------
467  name : `str`
468  Desired mask plane; if `None`, return entire dict
469  """
470 
471  if name is None:
472  return self._maskPlaneColors
473  else:
474  return self._maskPlaneColors.get(name)
475 
def getMaskPlaneColor(name, frame=None)
Definition: ds9.py:76

◆ getMaskTransparency()

def lsst.afw.display.interface.Display.getMaskTransparency (   self,
  name = None 
)
Return the current display's mask transparency

Definition at line 497 of file interface.py.

497  def getMaskTransparency(self, name=None):
498  """Return the current display's mask transparency
499  """
500 
501  return self._impl._getMaskTransparency(name)
502 
def getMaskTransparency(name, frame=None)
Definition: ds9.py:84

◆ incrDefaultFrame()

def lsst.afw.display.interface.Display.incrDefaultFrame ( )
static
Increment the default frame for display

Definition at line 291 of file interface.py.

291  def incrDefaultFrame():
292  """Increment the default frame for display
293  """
294  Display._defaultFrame += 1
295  return Display._defaultFrame
296 

◆ interact()

def lsst.afw.display.interface.Display.interact (   self)
Enter an interactive loop, listening for key presses in display and firing callbacks.

Exit with ``q``, ``CR``, ``ESC``, or any other callback function that returns a `True` value.

Definition at line 762 of file interface.py.

762  def interact(self):
763  """Enter an interactive loop, listening for key presses in display and firing callbacks.
764 
765  Exit with ``q``, ``CR``, ``ESC``, or any other callback function that returns a `True` value.
766  """
767  interactFinished = False
768 
769  while not interactFinished:
770  ev = self._impl._getEvent()
771  if not ev:
772  continue
773  k, x, y = ev.k, ev.x, ev.y # for now
774 
775  if k not in self._callbacks:
776  logger.warn("No callback registered for {0}".format(k))
777  else:
778  try:
779  interactFinished = self._callbacks[k](k, x, y)
780  except Exception as e:
781  logger.error(
782  "Display._callbacks['{0}']({0},{1},{2}) failed: {3}".format(k, x, y, e))
783 
def interact(frame=None)
Definition: ds9.py:125
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

◆ line()

def lsst.afw.display.interface.Display.line (   self,
  points,
  origin = afwImage.PARENT,
  symbs = False,
  ctype = None,
  size = 0.5 
)
Draw a set of symbols or connect points

Parameters
----------
points : `list`
    a list of (col, row)
origin : `lsst.afw.image.ImageOrigin`
    Coordinate system for the given positions.
symbs : `bool` or sequence
    If ``symbs`` is `True`, draw points at the specified points using the desired symbol,
    otherwise connect the dots.

    If ``symbs`` supports indexing (which includes a string -- caveat emptor) the
    elements are used to label the points
ctype : `str`
    ``ctype`` is the name of a color (e.g. 'red')
size : `float`

Definition at line 653 of file interface.py.

653  def line(self, points, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5):
654  """Draw a set of symbols or connect points
655 
656  Parameters
657  ----------
658  points : `list`
659  a list of (col, row)
660  origin : `lsst.afw.image.ImageOrigin`
661  Coordinate system for the given positions.
662  symbs : `bool` or sequence
663  If ``symbs`` is `True`, draw points at the specified points using the desired symbol,
664  otherwise connect the dots.
665 
666  If ``symbs`` supports indexing (which includes a string -- caveat emptor) the
667  elements are used to label the points
668  ctype : `str`
669  ``ctype`` is the name of a color (e.g. 'red')
670  size : `float`
671  """
672  if symbs:
673  try:
674  symbs[1]
675  except TypeError:
676  symbs = len(points)*list(symbs)
677 
678  for i, xy in enumerate(points):
679  self.dot(symbs[i], *xy, size=size, ctype=ctype)
680  else:
681  if len(points) > 0:
682  if origin == afwImage.PARENT and self._xy0 is not None:
683  x0, y0 = self._xy0
684  _points = list(points) # make a mutable copy
685  for i, p in enumerate(points):
686  _points[i] = (p[0] - x0, p[1] - y0)
687  points = _points
688 
689  self._impl._drawLines(points, ctype)
def line(points, frame=None, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5)
Definition: ds9.py:104

◆ maskColorGenerator()

def lsst.afw.display.interface.Display.maskColorGenerator (   self,
  omitBW = True 
)
A generator for "standard" colors

Parameters
----------
omitBW : `bool`
    Don't include `BLACK` and `WHITE`

Examples
--------

.. code-block:: py

   colorGenerator = interface.maskColorGenerator(omitBW=True)
   for p in planeList:
       print p, next(colorGenerator)

Definition at line 406 of file interface.py.

406  def maskColorGenerator(self, omitBW=True):
407  """A generator for "standard" colors
408 
409  Parameters
410  ----------
411  omitBW : `bool`
412  Don't include `BLACK` and `WHITE`
413 
414  Examples
415  --------
416 
417  .. code-block:: py
418 
419  colorGenerator = interface.maskColorGenerator(omitBW=True)
420  for p in planeList:
421  print p, next(colorGenerator)
422  """
423  _maskColors = [WHITE, BLACK, RED, GREEN,
424  BLUE, CYAN, MAGENTA, YELLOW, ORANGE]
425 
426  i = -1
427  while True:
428  i += 1
429  color = _maskColors[i%len(_maskColors)]
430  if omitBW and color in (BLACK, WHITE):
431  continue
432 
433  yield color
434 

◆ mtv()

def lsst.afw.display.interface.Display.mtv (   self,
  data,
  title = "",
  wcs = None 
)
Display an `~lsst.afw.image.Image` or `~lsst.afw.image.Mask` on a display

Notes
-----
Historical note: the name "mtv" comes from Jim Gunn's forth imageprocessing
system, Mirella (named after Mirella Freni); The "m" stands for Mirella.

Definition at line 512 of file interface.py.

512  def mtv(self, data, title="", wcs=None):
513  """Display an `~lsst.afw.image.Image` or `~lsst.afw.image.Mask` on a display
514 
515  Notes
516  -----
517  Historical note: the name "mtv" comes from Jim Gunn's forth imageprocessing
518  system, Mirella (named after Mirella Freni); The "m" stands for Mirella.
519  """
520  if hasattr(data, "getXY0"):
521  self._xy0 = data.getXY0()
522  else:
523  self._xy0 = None
524 
525  # it's an Exposure; display the MaskedImage with the WCS
526  if isinstance(data, afwImage.Exposure):
527  if wcs:
528  raise RuntimeError(
529  "You may not specify a wcs with an Exposure")
530  data, wcs = data.getMaskedImage(), data.getWcs()
531  elif isinstance(data, afwImage.DecoratedImage): # it's a DecoratedImage; display it
532  try:
533  wcs = afwGeom.makeSkyWcs(data.getMetadata())
534  except TypeError:
535  wcs = None
536  data = data.image
537 
538  self._xy0 = data.getXY0() # DecoratedImage doesn't have getXY0()
539 
540  if isinstance(data, afwImage.Image): # it's an Image; display it
541  self._impl._mtv(data, None, wcs, title)
542  # it's a Mask; display it, bitplane by bitplane
543  elif isinstance(data, afwImage.Mask):
544  #
545  # Some displays can't display a Mask without an image; so display an Image too,
546  # with pixel values set to the mask
547  #
548  self._impl._mtv(afwImage.ImageI(data.getArray()), data, wcs, title)
549  # it's a MaskedImage; display Image and overlay Mask
550  elif isinstance(data, afwImage.MaskedImage):
551  self._impl._mtv(data.getImage(), data.getMask(), wcs, title)
552  else:
553  raise RuntimeError(f"Unsupported type {data!r}")
A container for an Image and its associated metadata.
Definition: Image.h:397
A class to contain the data, WCS, and other information needed to describe an image of the sky.
Definition: Exposure.h:72
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:51
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:77
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:73
def mtv(data, frame=None, title="", wcs=None, *args, **kwargs)
Definition: ds9.py:92
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
Definition: SkyWcs.cc:521

◆ pan()

def lsst.afw.display.interface.Display.pan (   self,
  colc = None,
  rowc = None,
  origin = afwImage.PARENT 
)
Pan to a location

Parameters
----------
colc, rowc
    the coordinates to pan to
origin : `lsst.afw.image.ImageOrigin`
    Coordinate system for the given positions.

See also
--------
Display.zoom

Definition at line 745 of file interface.py.

745  def pan(self, colc=None, rowc=None, origin=afwImage.PARENT):
746  """Pan to a location
747 
748  Parameters
749  ----------
750  colc, rowc
751  the coordinates to pan to
752  origin : `lsst.afw.image.ImageOrigin`
753  Coordinate system for the given positions.
754 
755  See also
756  --------
757  Display.zoom
758  """
759 
760  self.zoom(None, colc, rowc, origin)
761 
def pan(colc=None, rowc=None, frame=None, origin=afwImage.PARENT)
Definition: ds9.py:112

◆ scale()

def lsst.afw.display.interface.Display.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

Parameters
----------
algorithm : `str`
    Desired scaling (e.g. "linear" or "asinh")
min
    Minimum value, or "minmax" or "zscale"
max
    Maximum value (must be `None` for minmax|zscale)
unit
    Units for min and max (e.g. Percent, Absolute, Sigma; `None` if min==minmax|zscale)
*args
    Optional arguments to the backend
**kwargs
    Optional keyword arguments to the backend

Definition at line 694 of file interface.py.

694  def scale(self, algorithm, min, max=None, unit=None, *args, **kwargs):
695  """Set the range of the scaling from DN in the image to the image display
696 
697  Parameters
698  ----------
699  algorithm : `str`
700  Desired scaling (e.g. "linear" or "asinh")
701  min
702  Minimum value, or "minmax" or "zscale"
703  max
704  Maximum value (must be `None` for minmax|zscale)
705  unit
706  Units for min and max (e.g. Percent, Absolute, Sigma; `None` if min==minmax|zscale)
707  *args
708  Optional arguments to the backend
709  **kwargs
710  Optional keyword arguments to the backend
711  """
712  if min in ("minmax", "zscale"):
713  assert max is None, f"You may not specify \"{min}\" and max"
714  assert unit is None, f"You may not specify \"{min}\" and unit"
715  elif max is None:
716  raise RuntimeError("Please specify max")
717 
718  self._impl._scale(algorithm, min, max, unit, *args, **kwargs)
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:108

◆ setCallback()

def lsst.afw.display.interface.Display.setCallback (   self,
  k,
  func = None,
  noRaise = False 
)
Set the callback for a key

Parameters
----------
k
    The key to assign the callback to
func : callable
    The callback assigned to ``k``
noRaise : `bool`

Returns
-------
oldFunc : callable
    The callback previously assigned to ``k``.

Definition at line 784 of file interface.py.

784  def setCallback(self, k, func=None, noRaise=False):
785  """Set the callback for a key
786 
787  Parameters
788  ----------
789  k
790  The key to assign the callback to
791  func : callable
792  The callback assigned to ``k``
793  noRaise : `bool`
794 
795  Returns
796  -------
797  oldFunc : callable
798  The callback previously assigned to ``k``.
799  """
800 
801  if k in "f":
802  if noRaise:
803  return
804  raise RuntimeError(
805  f"Key '{k}' is already in use by display, so I can't add a callback for it")
806 
807  ofunc = self._callbacks.get(k)
808  self._callbacks[k] = func if func else noop_callback
809 
810  self._impl._setCallback(k, self._callbacks[k])
811 
812  return ofunc
813 
def setCallback(k, func=lsst.afw.display.noop_callback, noRaise=False, frame=None)
Definition: ds9.py:129

◆ setDefaultBackend()

def lsst.afw.display.interface.Display.setDefaultBackend (   backend)
static

Definition at line 265 of file interface.py.

265  def setDefaultBackend(backend):
266  try:
267  _makeDisplayImpl(None, backend)
268  except Exception as e:
269  raise RuntimeError(
270  f"Unable to set backend to {backend}: \"{e}\"")
271 
272  Display._defaultBackend = backend
273 

◆ setDefaultFrame()

def lsst.afw.display.interface.Display.setDefaultFrame (   frame = 0)
static
Set the default frame for display

Definition at line 279 of file interface.py.

279  def setDefaultFrame(frame=0):
280  """Set the default frame for display
281  """
282  Display._defaultFrame = frame
283 
def setDefaultFrame(frame=0)
Definition: interface.py:878

◆ setDefaultImageColormap()

def lsst.afw.display.interface.Display.setDefaultImageColormap (   cmap)
static
Set the default colormap for images

Parameters
----------
cmap : `str`
    Name of colormap, as interpreted by the backend

Notes
-----
The only colormaps that all backends are required to honor
(if they pay any attention to setImageColormap) are "gray" and "grey"

Definition at line 331 of file interface.py.

331  def setDefaultImageColormap(cmap):
332  """Set the default colormap for images
333 
334  Parameters
335  ----------
336  cmap : `str`
337  Name of colormap, as interpreted by the backend
338 
339  Notes
340  -----
341  The only colormaps that all backends are required to honor
342  (if they pay any attention to setImageColormap) are "gray" and "grey"
343  """
344 
345  Display._defaultImageColormap = cmap
346 

◆ setDefaultMaskPlaneColor()

def lsst.afw.display.interface.Display.setDefaultMaskPlaneColor (   name = None,
  color = None 
)
static
Set the default mapping from mask plane names to colors

Parameters
----------
name : `str` or `dict`
    name of mask plane, or a dict mapping names to colors
    If name is `None`, use the hard-coded default dictionary
color
    Desired color, or `None` if name is a dict

Definition at line 305 of file interface.py.

305  def setDefaultMaskPlaneColor(name=None, color=None):
306  """Set the default mapping from mask plane names to colors
307 
308  Parameters
309  ----------
310  name : `str` or `dict`
311  name of mask plane, or a dict mapping names to colors
312  If name is `None`, use the hard-coded default dictionary
313  color
314  Desired color, or `None` if name is a dict
315  """
316 
317  if name is None:
318  name = Display._defaultMaskPlaneColor
319 
320  if isinstance(name, dict):
321  assert color is None
322  for k, v in name.items():
324  return
325  #
326  # Set the individual color values
327  #
328  Display._defaultMaskPlaneColor[name] = color
329 
def setDefaultMaskPlaneColor(name=None, color=None)
Definition: interface.py:898

◆ setDefaultMaskTransparency()

def lsst.afw.display.interface.Display.setDefaultMaskTransparency (   maskPlaneTransparency = {})
static

Definition at line 298 of file interface.py.

298  def setDefaultMaskTransparency(maskPlaneTransparency={}):
299  if hasattr(maskPlaneTransparency, "copy"):
300  maskPlaneTransparency = maskPlaneTransparency.copy()
301 
302  Display._defaultMaskTransparency = maskPlaneTransparency
303 
def setDefaultMaskTransparency(maskPlaneTransparency={})
Definition: interface.py:894

◆ setImageColormap()

def lsst.afw.display.interface.Display.setImageColormap (   self,
  cmap 
)
Set the colormap to use for images

 Parameters
----------
cmap : `str`
    Name of colormap, as interpreted by the backend

Notes
-----
The only colormaps that all backends are required to honor
(if they pay any attention to setImageColormap) are "gray" and "grey"

Definition at line 347 of file interface.py.

347  def setImageColormap(self, cmap):
348  """Set the colormap to use for images
349 
350  Parameters
351  ----------
352  cmap : `str`
353  Name of colormap, as interpreted by the backend
354 
355  Notes
356  -----
357  The only colormaps that all backends are required to honor
358  (if they pay any attention to setImageColormap) are "gray" and "grey"
359  """
360 
361  self._impl._setImageColormap(cmap)
362 

◆ setMaskPlaneColor()

def lsst.afw.display.interface.Display.setMaskPlaneColor (   self,
  name,
  color = None 
)
Request that mask plane name be displayed as color

Parameters
----------
name : `str` or `dict`
    Name of mask plane or a dictionary of name -> colorName
color : `str`
    The name of the color to use (must be `None` if ``name`` is a `dict`)

    Colors may be specified as any X11-compliant string (e.g. `"orchid"`), or by one
    of the following constants in `lsst.afw.display` : `BLACK`, `WHITE`, `RED`, `BLUE`,
    `GREEN`, `CYAN`, `MAGENTA`, `YELLOW`.

    If the color is "ignore" (or `IGNORE`) then that mask plane is not displayed

    The advantage of using the symbolic names is that the python interpreter can detect typos.

Definition at line 435 of file interface.py.

435  def setMaskPlaneColor(self, name, color=None):
436  """Request that mask plane name be displayed as color
437 
438  Parameters
439  ----------
440  name : `str` or `dict`
441  Name of mask plane or a dictionary of name -> colorName
442  color : `str`
443  The name of the color to use (must be `None` if ``name`` is a `dict`)
444 
445  Colors may be specified as any X11-compliant string (e.g. `"orchid"`), or by one
446  of the following constants in `lsst.afw.display` : `BLACK`, `WHITE`, `RED`, `BLUE`,
447  `GREEN`, `CYAN`, `MAGENTA`, `YELLOW`.
448 
449  If the color is "ignore" (or `IGNORE`) then that mask plane is not displayed
450 
451  The advantage of using the symbolic names is that the python interpreter can detect typos.
452  """
453 
454  if isinstance(name, dict):
455  assert color is None
456  for k, v in name.items():
457  self.setMaskPlaneColor(k, v)
458  return
459 
460  self._maskPlaneColors[name] = color
461 
def setMaskPlaneColor(name, color=None, frame=None)
Definition: ds9.py:72

◆ setMaskTransparency()

def lsst.afw.display.interface.Display.setMaskTransparency (   self,
  transparency = None,
  name = None 
)
Specify display's mask transparency (percent); or `None` to not set it when loading masks

Definition at line 476 of file interface.py.

476  def setMaskTransparency(self, transparency=None, name=None):
477  """Specify display's mask transparency (percent); or `None` to not set it when loading masks
478  """
479 
480  if isinstance(transparency, dict):
481  assert name is None
482  for k, v in transparency.items():
483  self.setMaskTransparency(v, k)
484  return
485 
486  if transparency is not None and (transparency < 0 or transparency > 100):
487  print(
488  "Mask transparency should be in the range [0, 100]; clipping", file=sys.stderr)
489  if transparency < 0:
490  transparency = 0
491  else:
492  transparency = 100
493 
494  if transparency is not None:
495  self._impl._setMaskTransparency(transparency, name)
496 
def setMaskTransparency(name, frame=None)
Definition: ds9.py:80

◆ show()

def lsst.afw.display.interface.Display.show (   self)
Uniconify and Raise display.

Notes
-----
Throws an exception if frame doesn't exit

Definition at line 503 of file interface.py.

503  def show(self):
504  """Uniconify and Raise display.
505 
506  Notes
507  -----
508  Throws an exception if frame doesn't exit
509  """
510  return self._impl._show()
511 
def show(frame=None)
Definition: ds9.py:88

◆ verbose() [1/2]

def lsst.afw.display.interface.Display.verbose (   self)
The backend's verbosity

Definition at line 248 of file interface.py.

248  def verbose(self):
249  """The backend's verbosity
250  """
251  return self._impl.verbose
252 

◆ verbose() [2/2]

def lsst.afw.display.interface.Display.verbose (   self,
  value 
)

Definition at line 254 of file interface.py.

254  def verbose(self, value):
255  if self._impl:
256  self._impl.verbose = value
257 

◆ zoom()

def lsst.afw.display.interface.Display.zoom (   self,
  zoomfac = None,
  colc = None,
  rowc = None,
  origin = afwImage.PARENT 
)
Zoom frame by specified amount, optionally panning also

Definition at line 723 of file interface.py.

723  def zoom(self, zoomfac=None, colc=None, rowc=None, origin=afwImage.PARENT):
724  """Zoom frame by specified amount, optionally panning also
725  """
726 
727  if (rowc and colc is None) or (colc and rowc is None):
728  raise RuntimeError(
729  "Please specify row and column center to pan about")
730 
731  if rowc is not None:
732  if origin == afwImage.PARENT and self._xy0 is not None:
733  x0, y0 = self._xy0
734  colc -= x0
735  rowc -= y0
736 
737  self._impl._pan(colc, rowc)
738 
739  if zoomfac is None and rowc is None:
740  zoomfac = 2
741 
742  if zoomfac is not None:
743  self._impl._zoom(zoomfac)
744 
def zoom(zoomfac=None, colc=None, rowc=None, frame=None, origin=afwImage.PARENT)
Definition: ds9.py:118

Member Data Documentation

◆ frame

lsst.afw.display.interface.Display.frame

Definition at line 165 of file interface.py.

◆ name

lsst.afw.display.interface.Display.name

Definition at line 167 of file interface.py.


The documentation for this class was generated from the following file: