Loading [MathJax]/extensions/tex2jax.js
LSST Applications g0fba68d861+5b9ba6aee1,g1ec0fe41b4+e220e2fb2f,g1fd858c14a+120b017347,g35bb328faa+fcb1d3bbc8,g4d2262a081+57a06a8609,g53246c7159+fcb1d3bbc8,g56a49b3a55+8d793c2a3d,g60b5630c4e+4e8d433789,g60dcce3b99+6eff471efc,g67b6fd64d1+fad15079a7,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g8180f54f50+65cb53bb37,g8352419a5c+fcb1d3bbc8,g8852436030+ae791ba189,g89139ef638+fad15079a7,g9125e01d80+fcb1d3bbc8,g94187f82dc+4e8d433789,g989de1cb63+fad15079a7,g9ccd5d7f00+cce09d2c12,g9d31334357+4e8d433789,g9f33ca652e+323fd354f8,gabe3b4be73+1e0a283bba,gabf8522325+94c30d56e9,gb1101e3267+5e0f808207,gb58c049af0+f03b321e39,gb89ab40317+fad15079a7,gc0af124501+a88dc73679,gcf25f946ba+ae791ba189,gd6cbbdb0b4+8d7f1baacb,gdb1c4ca869+16879ca1a6,gde0f65d7ad+11b49afd66,ge1ad929117+4e8d433789,ge278dab8ac+4d6e48c014,ge410e46f29+fad15079a7,gf5e32f922b+fcb1d3bbc8,gf618743f1b+8ff1364817,gf67bdafdda+fad15079a7,w.2025.17
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
lsst.afw.display.interface.Display Class Reference

Classes

class  _Buffering
 

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

 frame = frame
 
 name = backend
 

Protected Attributes

 _impl = _makeDisplayImpl(self, backend, **kwargs)
 
 _xy0 = None
 
dict _maskPlaneColors = {}
 
dict _callbacks = {}
 

Static Protected Attributes

dict _displays = {}
 
 _defaultBackend = None
 
int _defaultFrame = 0
 
 _defaultMaskPlaneColor
 
dict _defaultMaskTransparency = {}
 
str _defaultImageColormap = "gray"
 

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()).
**kwargs
    Arguments to pass to the backend.

Definition at line 126 of file interface.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 158 of file interface.py.

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

◆ __del__()

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

Definition at line 215 of file interface.py.

215 def __del__(self):
216 self.close()
217

Member Function Documentation

◆ __enter__()

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

Definition at line 205 of file interface.py.

205 def __enter__(self):
206 """Support for python's with statement.
207 """
208 return self
209

◆ __exit__()

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

Definition at line 210 of file interface.py.

210 def __exit__(self, *args):
211 """Support for python's with statement.
212 """
213 self.close()
214

◆ __getattr__()

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 218 of file interface.py.

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

◆ __str__()

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

Definition at line 265 of file interface.py.

265 def __str__(self):
266 return f"Display[{self.frame}]"
267

◆ Buffering()

lsst.afw.display.interface.Display.Buffering ( self)
Return a context manager that will buffer repeated display
commands, to e.g. speed up displaying points.

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

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

Definition at line 623 of file interface.py.

623 def Buffering(self):
624 """Return a context manager that will buffer repeated display
625 commands, to e.g. speed up displaying points.
626
627 Examples
628 --------
629 .. code-block:: py
630
631 with display.Buffering():
632 display.dot("+", xc, yc)
633 """
634 return self._Buffering(self._impl)
635

◆ centroids()

lsst.afw.display.interface.Display.centroids ( self,
catalog,
* ,
symbol = "o",
** kwargs )
Draw the sources from a catalog at their pixel centroid positions
as given by `~lsst.afw.table.Catalog.getX()` and
`~lsst.afw.table.Catalog.getY()`.

See `dot` for an explanation of ``symbol`` and available args/kwargs,
which are passed to `dot`.

Parameters
----------
catalog : `lsst.afw.table.Catalog`
    Catalog to display centroids for. Must have valid `slot_Centroid`.

Definition at line 646 of file interface.py.

646 def centroids(self, catalog, *, symbol="o", **kwargs):
647 """Draw the sources from a catalog at their pixel centroid positions
648 as given by `~lsst.afw.table.Catalog.getX()` and
649 `~lsst.afw.table.Catalog.getY()`.
650
651 See `dot` for an explanation of ``symbol`` and available args/kwargs,
652 which are passed to `dot`.
653
654 Parameters
655 ----------
656 catalog : `lsst.afw.table.Catalog`
657 Catalog to display centroids for. Must have valid `slot_Centroid`.
658 """
659 if not catalog.getCentroidSlot().isValid():
660 raise RuntimeError("Catalog must have a valid `slot_Centroid` defined to get X/Y positions.")
661
662 with self.Buffering():
663 for pt in catalog:
664 self.dot(symbol, pt.getX(), pt.getY(), **kwargs)
665

◆ close()

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

Definition at line 245 of file interface.py.

245 def close(self):
246 if getattr(self, "_impl", None) is not None:
247 self._impl._close()
248 del self._impl
249 self._impl = None
250
251 if self.frame in Display._displays:
252 del Display._displays[self.frame]
253

◆ delAllDisplays()

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

Definition at line 402 of file interface.py.

402 def delAllDisplays():
403 """Delete and close all known displays.
404 """
405 for disp in list(Display._displays.values()):
406 disp.close()
407 Display._displays = {}
408

◆ dot()

lsst.afw.display.interface.Display.dot ( self,
symb,
c,
r,
size = 2,
ctype = None,
origin = afwImage.PARENT,
** 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 : `float`
    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.
**kwargs
    Extra keyword arguments to backend.

Definition at line 666 of file interface.py.

666 def dot(self, symb, c, r, size=2, ctype=None, origin=afwImage.PARENT, **kwargs):
667 """Draw a symbol onto the specified display frame.
668
669 Parameters
670 ----------
671 symb
672 Possible values are:
673
674 ``"+"``
675 Draw a +
676 ``"x"``
677 Draw an x
678 ``"*"``
679 Draw a *
680 ``"o"``
681 Draw a circle
682 ``"@:Mxx,Mxy,Myy"``
683 Draw an ellipse with moments (Mxx, Mxy, Myy) (argument size is ignored)
684 `lsst.afw.geom.ellipses.BaseCore`
685 Draw the ellipse (argument size is ignored). N.b. objects
686 derived from `~lsst.afw.geom.ellipses.BaseCore` include
687 `~lsst.afw.geom.ellipses.Axes` and `~lsst.afw.geom.ellipses.Quadrupole`.
688 Any other value
689 Interpreted as a string to be drawn.
690 c, r : `float`
691 The column and row where the symbol is drawn [0-based coordinates].
692 size : `int`
693 Size of symbol, in pixels.
694 ctype : `str`
695 The desired color, either e.g. `lsst.afw.display.RED` or a color name known to X11
696 origin : `lsst.afw.image.ImageOrigin`
697 Coordinate system for the given positions.
698 **kwargs
699 Extra keyword arguments to backend.
700 """
701 if isinstance(symb, int):
702 symb = f"{symb:d}"
703
704 if origin == afwImage.PARENT and self._xy0 is not None:
705 x0, y0 = self._xy0
706 r -= y0
707 c -= x0
708
709 if isinstance(symb, afwGeom.ellipses.BaseCore) or re.search(r"^@:", symb):
710 try:
711 mat = re.search(r"^@:([^,]+),([^,]+),([^,]+)", symb)
712 except TypeError:
713 pass
714 else:
715 if mat:
716 mxx, mxy, myy = [float(_) for _ in mat.groups()]
717 symb = afwGeom.Quadrupole(mxx, myy, mxy)
718
719 symb = afwGeom.ellipses.Axes(symb)
720
721 self._impl._dot(symb, c, r, size, ctype, **kwargs)
722
An ellipse core for the semimajor/semiminor axis and position angle parametrization (a,...
Definition Axes.h:47
A base class for parametrizations of the "core" of an ellipse - the ellipticity and size.
Definition BaseCore.h:55
An ellipse core with quadrupole moments as parameters.
Definition Quadrupole.h:47

◆ erase()

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

Definition at line 641 of file interface.py.

641 def erase(self):
642 """Erase the specified display frame.
643 """
644 self._impl._erase()
645

◆ flush()

lsst.afw.display.interface.Display.flush ( self)
Flush any buffering that may be provided by the backend.

Definition at line 636 of file interface.py.

636 def flush(self):
637 """Flush any buffering that may be provided by the backend.
638 """
639 self._impl._flush()
640

◆ getActiveCallbackKeys()

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 884 of file interface.py.

884 def getActiveCallbackKeys(self, onlyActive=True):
885 """Return all callback keys
886
887 Parameters
888 ----------
889 onlyActive : `bool`
890 If `True` only return keys that do something
891 """
892 return sorted([k for k, func in self._callbacks.items() if
893 not (onlyActive and func == noop_callback)])
894
895
896# Callbacks for display events
897
898

◆ getDefaultBackend()

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

Definition at line 281 of file interface.py.

281 def getDefaultBackend():
282 return Display._defaultBackend
283

◆ getDefaultFrame()

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

Definition at line 291 of file interface.py.

291 def getDefaultFrame():
292 """Get the default frame for display.
293 """
294 return Display._defaultFrame
295

◆ getDisplay()

lsst.afw.display.interface.Display.getDisplay ( frame = None,
backend = None,
create = True,
verbose = False,
** 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.
**kwargs
    keyword arguments passed to `Display` constructor.

Definition at line 368 of file interface.py.

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

◆ getMaskPlaneColor()

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 468 of file interface.py.

468 def getMaskPlaneColor(self, name=None):
469 """Return the color associated with the specified mask plane name.
470
471 Parameters
472 ----------
473 name : `str`
474 Desired mask plane; if `None`, return entire dict.
475 """
476 if name is None:
477 return self._maskPlaneColors
478 else:
479 color = self._maskPlaneColors.get(name)
480
481 if color is None:
482 color = self._defaultMaskPlaneColor.get(name)
483
484 return color
485

◆ getMaskTransparency()

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

Definition at line 507 of file interface.py.

507 def getMaskTransparency(self, name=None):
508 """Return the current display's mask transparency.
509 """
510 return self._impl._getMaskTransparency(name)
511

◆ image()

lsst.afw.display.interface.Display.image ( self,
data,
title = "",
wcs = None,
metadata = None )
Display an image on a display, with semi-transparent masks
overlaid, if available.

Parameters
----------
data : `lsst.afw.image.Exposure` or `lsst.afw.image.MaskedImage` or `lsst.afw.image.Image`
    Image to display; Exposure and MaskedImage will show transparent
    mask planes.
title : `str`, optional
    Title for the display window.
wcs : `lsst.afw.geom.SkyWcs`, optional
    World Coordinate System to align an `~lsst.afw.image.MaskedImage`
    or `~lsst.afw.image.Image` to; raise an exception if ``data``
    is an `~lsst.afw.image.Exposure`.
metadata : `lsst.daf.base.PropertySet`, optional
    Additional FITS metadata to be sent to display.

Raises
------
RuntimeError
    Raised if an Exposure is passed with a non-None wcs when the
    ``wcs`` kwarg is also non-None.
TypeError
    Raised if data is an incompatible type.

Definition at line 538 of file interface.py.

538 def image(self, data, title="", wcs=None, metadata=None):
539 """Display an image on a display, with semi-transparent masks
540 overlaid, if available.
541
542 Parameters
543 ----------
544 data : `lsst.afw.image.Exposure` or `lsst.afw.image.MaskedImage` or `lsst.afw.image.Image`
545 Image to display; Exposure and MaskedImage will show transparent
546 mask planes.
547 title : `str`, optional
548 Title for the display window.
549 wcs : `lsst.afw.geom.SkyWcs`, optional
550 World Coordinate System to align an `~lsst.afw.image.MaskedImage`
551 or `~lsst.afw.image.Image` to; raise an exception if ``data``
552 is an `~lsst.afw.image.Exposure`.
553 metadata : `lsst.daf.base.PropertySet`, optional
554 Additional FITS metadata to be sent to display.
555
556 Raises
557 ------
558 RuntimeError
559 Raised if an Exposure is passed with a non-None wcs when the
560 ``wcs`` kwarg is also non-None.
561 TypeError
562 Raised if data is an incompatible type.
563 """
564 if hasattr(data, "getXY0"):
565 self._xy0 = data.getXY0()
566 else:
567 self._xy0 = None
568
569 # It's an Exposure; display the MaskedImage with the WCS
570 if isinstance(data, afwImage.Exposure):
571 if wcs:
572 raise RuntimeError("You may not specify a wcs with an Exposure")
573 data, wcs, metadata = data.getMaskedImage(), data.wcs, data.metadata
574 # it's a DecoratedImage; display it
575 elif isinstance(data, afwImage.DecoratedImage):
576 try:
577 wcs = afwGeom.makeSkyWcs(data.getMetadata())
578 except TypeError:
579 wcs = None
580 data = data.image
581
582 self._xy0 = data.getXY0() # DecoratedImage doesn't have getXY0()
583
584 if isinstance(data, afwImage.Image): # it's an Image; display it
585 self._impl._mtv(data, None, wcs, title, metadata)
586 # It's a Mask; display it, bitplane by bitplane.
587 elif isinstance(data, afwImage.Mask):
588 self.__addMissingMaskPlanes(data)
589 # Some displays can't display a Mask without an image; so display
590 # an Image too, with pixel values set to the mask.
591 self._impl._mtv(afwImage.ImageI(data.array), data, wcs, title, metadata)
592 # It's a MaskedImage; display Image and overlay Mask.
593 elif isinstance(data, afwImage.MaskedImage):
594 self.__addMissingMaskPlanes(data.mask)
595 self._impl._mtv(data.image, data.mask, wcs, title, metadata)
596 else:
597 raise TypeError(f"Unsupported type {data!r}")
598
A container for an Image and its associated metadata.
Definition Image.h:406
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:82
A class to manipulate images, masks, and variance as a single object.
Definition MaskedImage.h:74
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
Definition SkyWcs.cc:521

◆ incrDefaultFrame()

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

Definition at line 297 of file interface.py.

297 def incrDefaultFrame():
298 """Increment the default frame for display.
299 """
300 Display._defaultFrame += 1
301 return Display._defaultFrame
302

◆ interact()

lsst.afw.display.interface.Display.interact ( self)
Enter an interactive loop, listening for key presses or equivalent
UI actions in the display and firing callbacks.

Exit with ``q``, ``CR``, ``ESC``, or any equivalent UI action provided
in the display. The loop may also be exited by returning `True` from a
user-provided callback function.

Definition at line 825 of file interface.py.

825 def interact(self):
826 """Enter an interactive loop, listening for key presses or equivalent
827 UI actions in the display and firing callbacks.
828
829 Exit with ``q``, ``CR``, ``ESC``, or any equivalent UI action provided
830 in the display. The loop may also be exited by returning `True` from a
831 user-provided callback function.
832 """
833 interactFinished = False
834
835 while not interactFinished:
836 ev = self._impl._getEvent()
837 if not ev:
838 continue
839 k, x, y = ev.k, ev.x, ev.y # for now
840
841 if k not in self._callbacks:
842 logger.warning("No callback registered for %s", k)
843 else:
844 try:
845 interactFinished = self._callbacks[k](k, x, y)
846 except Exception:
847 logger.exception(
848 "Display._callbacks['%s'](%s,%s,%s) failed.", k, x, y)
849

◆ line()

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`
    Size of points to create if `symbs` is passed.

Definition at line 723 of file interface.py.

723 def line(self, points, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5):
724 """Draw a set of symbols or connect points
725
726 Parameters
727 ----------
728 points : `list`
729 A list of (col, row)
730 origin : `lsst.afw.image.ImageOrigin`
731 Coordinate system for the given positions.
732 symbs : `bool` or sequence
733 If ``symbs`` is `True`, draw points at the specified points using
734 the desired symbol, otherwise connect the dots.
735
736 If ``symbs`` supports indexing (which includes a string -- caveat
737 emptor) the elements are used to label the points.
738 ctype : `str`
739 ``ctype`` is the name of a color (e.g. 'red').
740 size : `float`
741 Size of points to create if `symbs` is passed.
742 """
743 if symbs:
744 try:
745 symbs[1]
746 except TypeError:
747 symbs = len(points)*list(symbs)
748
749 for i, xy in enumerate(points):
750 self.dot(symbs[i], *xy, size=size, ctype=ctype)
751 else:
752 if len(points) > 0:
753 if origin == afwImage.PARENT and self._xy0 is not None:
754 x0, y0 = self._xy0
755 _points = list(points) # make a mutable copy
756 for i, p in enumerate(points):
757 _points[i] = (p[0] - x0, p[1] - y0)
758 points = _points
759
760 self._impl._drawLines(points, ctype)
761

◆ maskColorGenerator()

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 409 of file interface.py.

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

◆ mtv()

lsst.afw.display.interface.Display.mtv ( self,
data,
title = "",
wcs = None,
metadata = None )
Display an image on a display, with semi-transparent masks
overlaid, if available.

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 599 of file interface.py.

599 def mtv(self, data, title="", wcs=None, metadata=None):
600 """Display an image on a display, with semi-transparent masks
601 overlaid, if available.
602
603 Notes
604 -----
605 Historical note: the name "mtv" comes from Jim Gunn's forth imageprocessing
606 system, Mirella (named after Mirella Freni); The "m" stands for Mirella.
607 """
608 self.image(data, title, wcs, metadata)
609

◆ pan()

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

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

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

Definition at line 809 of file interface.py.

809 def pan(self, colc=None, rowc=None, origin=afwImage.PARENT):
810 """Pan to a location.
811
812 Parameters
813 ----------
814 colc, rowc
815 Coordinates to pan to.
816 origin : `lsst.afw.image.ImageOrigin`
817 Coordinate system for the given positions.
818
819 See also
820 --------
821 Display.zoom
822 """
823 self.zoom(None, colc, rowc, origin)
824

◆ scale()

lsst.afw.display.interface.Display.scale ( self,
algorithm,
min,
max = None,
unit = None,
** 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).
**kwargs
    Optional keyword arguments to the backend.

Definition at line 762 of file interface.py.

762 def scale(self, algorithm, min, max=None, unit=None, **kwargs):
763 """Set the range of the scaling from DN in the image to the image
764 display.
765
766 Parameters
767 ----------
768 algorithm : `str`
769 Desired scaling (e.g. "linear" or "asinh").
770 min
771 Minimum value, or "minmax" or "zscale".
772 max
773 Maximum value (must be `None` for minmax|zscale).
774 unit
775 Units for min and max (e.g. Percent, Absolute, Sigma; `None` if
776 min==minmax|zscale).
777 **kwargs
778 Optional keyword arguments to the backend.
779 """
780 if min in ("minmax", "zscale"):
781 assert max is None, f"You may not specify \"{min}\" and max"
782 assert unit is None, f"You may not specify \"{min}\" and unit"
783 elif max is None:
784 raise RuntimeError("Please specify max")
785
786 self._impl._scale(algorithm, min, max, unit, **kwargs)
787

◆ setCallback()

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

Backend displays may provide an equivalent graphical UI action, but
must make the associated key letter visible in the UI in some way.

Parameters
----------
k : `str`
    The key to assign the callback to.
func : callable
    The callback assigned to ``k``.
noRaise : `bool`
    Do not raise if ``k`` is already in use.

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

Definition at line 850 of file interface.py.

850 def setCallback(self, k, func=None, noRaise=False):
851 """Set the callback for a key.
852
853 Backend displays may provide an equivalent graphical UI action, but
854 must make the associated key letter visible in the UI in some way.
855
856 Parameters
857 ----------
858 k : `str`
859 The key to assign the callback to.
860 func : callable
861 The callback assigned to ``k``.
862 noRaise : `bool`
863 Do not raise if ``k`` is already in use.
864
865 Returns
866 -------
867 oldFunc : callable
868 The callback previously assigned to ``k``.
869 """
870
871 if k in "f":
872 if noRaise:
873 return
874 raise RuntimeError(
875 f"Key '{k}' is already in use by display, so I can't add a callback for it")
876
877 ofunc = self._callbacks.get(k)
878 self._callbacks[k] = func if func else noop_callback
879
880 self._impl._setCallback(k, self._callbacks[k])
881
882 return ofunc
883

◆ setDefaultBackend()

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

Definition at line 271 of file interface.py.

271 def setDefaultBackend(backend):
272 try:
273 _makeDisplayImpl(None, backend)
274 except Exception as e:
275 raise RuntimeError(
276 f"Unable to set backend to {backend}: \"{e}\"")
277
278 Display._defaultBackend = backend
279

◆ setDefaultFrame()

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

Definition at line 285 of file interface.py.

285 def setDefaultFrame(frame=0):
286 """Set the default frame for display.
287 """
288 Display._defaultFrame = frame
289

◆ setDefaultImageColormap()

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 335 of file interface.py.

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

◆ setDefaultMaskPlaneColor()

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 311 of file interface.py.

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

◆ setDefaultMaskTransparency()

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

Definition at line 304 of file interface.py.

304 def setDefaultMaskTransparency(maskPlaneTransparency={}):
305 if hasattr(maskPlaneTransparency, "copy"):
306 maskPlaneTransparency = maskPlaneTransparency.copy()
307
308 Display._defaultMaskTransparency = maskPlaneTransparency
309

◆ setImageColormap()

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 351 of file interface.py.

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

◆ setMaskPlaneColor()

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 438 of file interface.py.

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

◆ setMaskTransparency()

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 486 of file interface.py.

486 def setMaskTransparency(self, transparency=None, name=None):
487 """Specify display's mask transparency (percent); or `None` to not set
488 it when loading masks.
489 """
490 if isinstance(transparency, dict):
491 assert name is None
492 for k, v in transparency.items():
493 self.setMaskTransparency(v, k)
494 return
495
496 if transparency is not None and (transparency < 0 or transparency > 100):
497 print(
498 "Mask transparency should be in the range [0, 100]; clipping", file=sys.stderr)
499 if transparency < 0:
500 transparency = 0
501 else:
502 transparency = 100
503
504 if transparency is not None:
505 self._impl._setMaskTransparency(transparency, name)
506

◆ show()

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

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

Definition at line 512 of file interface.py.

512 def show(self):
513 """Uniconify and Raise display.
514
515 Notes
516 -----
517 Throws an exception if frame doesn't exit.
518 """
519 return self._impl._show()
520

◆ verbose() [1/2]

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

Definition at line 255 of file interface.py.

255 def verbose(self):
256 """The backend's verbosity.
257 """
258 return self._impl.verbose
259

◆ verbose() [2/2]

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

Definition at line 261 of file interface.py.

261 def verbose(self, value):
262 if self._impl:
263 self._impl.verbose = value
264

◆ zoom()

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 788 of file interface.py.

788 def zoom(self, zoomfac=None, colc=None, rowc=None, origin=afwImage.PARENT):
789 """Zoom frame by specified amount, optionally panning also
790 """
791 if (rowc and colc is None) or (colc and rowc is None):
792 raise RuntimeError(
793 "Please specify row and column center to pan about")
794
795 if rowc is not None:
796 if origin == afwImage.PARENT and self._xy0 is not None:
797 x0, y0 = self._xy0
798 colc -= x0
799 rowc -= y0
800
801 self._impl._pan(colc, rowc)
802
803 if zoomfac is None and rowc is None:
804 zoomfac = 2
805
806 if zoomfac is not None:
807 self._impl._zoom(zoomfac)
808

Member Data Documentation

◆ _callbacks

dict lsst.afw.display.interface.Display._callbacks = {}
protected

Definition at line 181 of file interface.py.

◆ _defaultBackend

lsst.afw.display.interface.Display._defaultBackend = None
staticprotected

Definition at line 139 of file interface.py.

◆ _defaultFrame

int lsst.afw.display.interface.Display._defaultFrame = 0
staticprotected

Definition at line 140 of file interface.py.

◆ _defaultImageColormap

str lsst.afw.display.interface.Display._defaultImageColormap = "gray"
staticprotected

Definition at line 156 of file interface.py.

◆ _defaultMaskPlaneColor

lsst.afw.display.interface.Display._defaultMaskPlaneColor
staticprotected
Initial value:
= dict(
BAD=RED,
CR=MAGENTA,
EDGE=YELLOW,
INTERPOLATED=GREEN,
SATURATED=GREEN,
DETECTED=BLUE,
DETECTED_NEGATIVE=CYAN,
SUSPECT=YELLOW,
NO_DATA=ORANGE,
# deprecated names
INTRP=GREEN,
SAT=GREEN,
)

Definition at line 141 of file interface.py.

◆ _defaultMaskTransparency

dict lsst.afw.display.interface.Display._defaultMaskTransparency = {}
staticprotected

Definition at line 155 of file interface.py.

◆ _displays

dict lsst.afw.display.interface.Display._displays = {}
staticprotected

Definition at line 138 of file interface.py.

◆ _impl

lsst.afw.display.interface.Display._impl = _makeDisplayImpl(self, backend, **kwargs)
protected

Definition at line 172 of file interface.py.

◆ _maskPlaneColors

dict lsst.afw.display.interface.Display._maskPlaneColors = {}
protected

Definition at line 177 of file interface.py.

◆ _xy0

lsst.afw.display.interface.Display._xy0 = None
protected

Definition at line 175 of file interface.py.

◆ frame

lsst.afw.display.interface.Display.frame = frame

Definition at line 171 of file interface.py.

◆ name

lsst.afw.display.interface.Display.name = backend

Definition at line 173 of file interface.py.


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