lsst.display.matplotlib gb32d437585+cb1993dea9
Loading...
Searching...
No Matches
lsst.display.matplotlib.matplotlib.DisplayImpl Class Reference
Inheritance diagram for lsst.display.matplotlib.matplotlib.DisplayImpl:

Public Member Functions

 __init__ (self, display, verbose=False, interpretMaskBits=True, mtvOrigin=afwImage.PARENT, fastMaskDisplay=False, reopenPlot=False, useSexagesimal=False, dpi=None, useWcsAxes=True, wcsGrid=False, astPlotOptions="", *args, **kwargs)
 savefig (self, *args, **kwargs)
 show_colorbar (self, show=True, where="right", axSize="5%", axPad=None, **kwargs)
 useSexagesimal (self, useSexagesimal)
 wait (self, prompt="[c(ontinue) p(db)] :", allowPdb=True)

Protected Member Functions

 _close (self)
 Close the display, cleaning up any allocated resources.
 _show (self)
 _setMaskTransparency (self, transparency, maskplane)
 _getMaskTransparency (self, maskplane=None)
 _mtv (self, image, mask=None, wcs=None, title="", metadata=None)
 _i_mtv (self, data, wcs, title, isMask)
 _drawWcsAxes (self, ax, wcs)
 _i_setImage (self, image, mask=None, wcs=None)
 _setImageColormap (self, cmap)
 _buffer (self, enable=True)
 _flush (self)
 _erase (self)
 _dot (self, symb, c, r, size, ctype, fontFamily="helvetica", textAngle=None)
 _drawLines (self, points, ctype)
 _scale (self, algorithm, minval, maxval, unit, *args, **kwargs)
 _i_scale (self, algorithm, minval, maxval, unit, *args, **kwargs)
 _zoom (self, zoomfac)
 _pan (self, colc, rowc)
 _getEvent (self, timeout=-1)

Protected Attributes

 _figure = figure
 _display = display
dict _maskTransparency = {None: 0.7}
 _interpretMaskBits = interpretMaskBits
# we draw each bitplane separately _fastMaskDisplay = fastMaskDisplay
list _useSexagesimal = [useSexagesimal]
 _mtvOrigin = mtvOrigin
 _useWcsAxes = useWcsAxes
 _wcsGrid = wcsGrid
 _astPlotOptions = astPlotOptions
dict _wcsAxesManagers = {}
tuple _mappable_ax = None
 _colorbar_ax = None
 _image_colormap = matplotlib.cm.gray
 _scaleArgs = dict()
 _normalize = None
 _image = None
 _mask = None
 _wcs = None
 _title = title
 _xy0 = self._image.getXY0() if self._image else (0, 0)
# avoid min _zoomfac = None
 _width
int _height = 0, 0
float _xcen = 0.5*self._width
float _ycen = 0.5*self._height

Detailed Description

Provide a matplotlib backend for afwDisplay

Recommended backends in notebooks are:
  %matplotlib notebook
or
  %matplotlib ipympl
or
  %matplotlib qt
  %gui qt
or
  %matplotlib inline
or
  %matplotlib osx

Apparently only qt supports Display.interact(); the list of interactive
backends is given by lsst.display.matplotlib.interactiveBackends

Constructor & Destructor Documentation

◆ __init__()

lsst.display.matplotlib.matplotlib.DisplayImpl.__init__ ( self,
display,
verbose = False,
interpretMaskBits = True,
mtvOrigin = afwImage.PARENT,
fastMaskDisplay = False,
reopenPlot = False,
useSexagesimal = False,
dpi = None,
useWcsAxes = True,
wcsGrid = False,
astPlotOptions = "",
* args,
** kwargs )
Initialise a matplotlib display

@param fastMaskDisplay      If True only show the first bitplane that's
                            set in each pixel
                            (e.g. if (SATURATED & DETECTED)
                            ignore DETECTED)
                            Not really what we want, but a bit faster
@param interpretMaskBits    Interpret the mask value under the cursor
@param mtvOrigin            Display pixel coordinates with LOCAL origin
                            (bottom left == 0,0 not XY0)
@param reopenPlot           If true, close the plot before opening it.
                            (useful with e.g. %ipympl)
@param useSexagesimal       If True, display coordinates in sexagesimal
                            E.g. hh:mm:ss.ss (default:False)
                            May be changed by calling
                                  display.useSexagesimal()
@param dpi                  Number of dpi (passed to pyplot.figure)
@param useWcsAxes           If True (the default) and the data
                            have a WCS, draw sky coordinate axes
                            using AST instead of pixel axes
@param wcsGrid              If True draw the full curvilinear
                            coordinate grid across the image
                            (only used with useWcsAxes)
@param astPlotOptions       Extra AST Plot attribute settings,
                            e.g. "Colour(grid)=2" for a red
                            grid; these override the defaults.
                            N.b. AST colours are 1-based grf
                            colour table indices, not names
                            (see lsst.display.matplotlib
                            .wcsAxes.WcsAxesManager)

The `frame` argument to `Display` may be a matplotlib figure; this
permits code such as
   fig, axes = plt.subplots(1, 2)

   disp = afwDisplay.Display(fig)
   disp.scale('asinh', 'zscale', Q=0.5)

   for axis, exp in zip(axes, exps):
      fig.sca(axis)    # make axis active
      disp.mtv(exp)

Member Function Documentation

◆ _dot()

lsst.display.matplotlib.matplotlib.DisplayImpl._dot ( self,
symb,
c,
r,
size,
ctype,
fontFamily = "helvetica",
textAngle = None )
protected
Draw a symbol at (col,row) = (c,r) [0-based coordinates]
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)
    An afwGeom.ellipses.Axes Draw the ellipse (argument size is
                             ignored)

Any other value is interpreted as a string to be drawn. Strings obey the
fontFamily (which may be extended with other characteristics, e.g.
"times bold italic".  Text will be drawn rotated by textAngle
(textAngle is ignored otherwise).

◆ _drawLines()

lsst.display.matplotlib.matplotlib.DisplayImpl._drawLines ( self,
points,
ctype )
protected
Connect the points, a list of (col,row)
Ctype is the name of a colour (e.g. 'red')

◆ _drawWcsAxes()

lsst.display.matplotlib.matplotlib.DisplayImpl._drawWcsAxes ( self,
ax,
wcs )
protected
Draw sky coordinate axes with AST, hiding the pixel axes.

Falls back to ordinary pixel axes with a warning if AST cannot
draw the given WCS.

◆ _erase()

lsst.display.matplotlib.matplotlib.DisplayImpl._erase ( self)
protected
Erase the display, keeping any WCS axes

◆ _getEvent()

lsst.display.matplotlib.matplotlib.DisplayImpl._getEvent ( self,
timeout = -1 )
protected
Listen for a key press, returning (key, x, y)

◆ _getMaskTransparency()

lsst.display.matplotlib.matplotlib.DisplayImpl._getMaskTransparency ( self,
maskplane = None )
protected
Return the current mask transparency

◆ _i_mtv()

lsst.display.matplotlib.matplotlib.DisplayImpl._i_mtv ( self,
data,
wcs,
title,
isMask )
protected
Internal routine to display an Image or Mask on a DS9 display

◆ _i_setImage()

lsst.display.matplotlib.matplotlib.DisplayImpl._i_setImage ( self,
image,
mask = None,
wcs = None )
protected
Save the current image, mask, wcs, and XY0

◆ _mtv()

lsst.display.matplotlib.matplotlib.DisplayImpl._mtv ( self,
image,
mask = None,
wcs = None,
title = "",
metadata = None )
protected
Display an Image and/or Mask on a matplotlib display

◆ _pan()

lsst.display.matplotlib.matplotlib.DisplayImpl._pan ( self,
colc,
rowc )
protected
Pan to (colc, rowc)

◆ _scale()

lsst.display.matplotlib.matplotlib.DisplayImpl._scale ( self,
algorithm,
minval,
maxval,
unit,
* args,
** kwargs )
protected
Set gray scale

N.b.  Supports extra arguments:
@param maskedPixels  List of names of mask bits to ignore
                     E.g. ["BAD", "INTERP"].
                     A single name is also supported

◆ _setImageColormap()

lsst.display.matplotlib.matplotlib.DisplayImpl._setImageColormap ( self,
cmap )
protected
Set the colormap used for the image

cmap should be either the name of an attribute of matplotlib.cm or an
mpColors.Colormap (e.g. "gray" or matplotlib.cm.gray)

◆ _setMaskTransparency()

lsst.display.matplotlib.matplotlib.DisplayImpl._setMaskTransparency ( self,
transparency,
maskplane )
protected
Specify mask transparency (percent)

◆ _show()

lsst.display.matplotlib.matplotlib.DisplayImpl._show ( self)
protected
Put the plot at the top of the window stacking order

◆ _zoom()

lsst.display.matplotlib.matplotlib.DisplayImpl._zoom ( self,
zoomfac )
protected
Zoom by specified amount

◆ savefig()

lsst.display.matplotlib.matplotlib.DisplayImpl.savefig ( self,
* args,
** kwargs )
Defer to figure.savefig()

Parameters
----------
args : `list`
  Passed through to figure.savefig()
kwargs : `dict`
  Passed through to figure.savefig()

◆ show_colorbar()

lsst.display.matplotlib.matplotlib.DisplayImpl.show_colorbar ( self,
show = True,
where = "right",
axSize = "5%",
axPad = None,
** kwargs )
Show (or hide) the colour bar

Parameters
----------
show : `bool`
  Should I show the colour bar?
where : `str`
  Location of colour bar: "right" or "bottom"
axSize : `float` or `str`
  Size of axes to hold the colour bar; fraction of current x-size
axPad : `float` or `str`
  Padding between axes and colour bar; fraction of current x-size
args : `list`
  Passed through to colorbar()
kwargs : `dict`
  Passed through to colorbar()

We set the default padding to put the colourbar in a reasonable
place for roughly square plots, but you may need to fiddle for
plots with extreme axis ratios.

You can only configure the colorbar when it isn't yet visible, but
as you can easily remove it this is not in practice a difficulty.

◆ useSexagesimal()

lsst.display.matplotlib.matplotlib.DisplayImpl.useSexagesimal ( self,
useSexagesimal )
Control the formatting coordinates as HH:MM:SS.ss

Parameters
----------
useSexagesimal : `bool`
   Print coordinates as e.g. HH:MM:SS.ss iff True

N.b. can also be set in Display's ctor
Are we formatting coordinates as HH:MM:SS.ss?

◆ wait()

lsst.display.matplotlib.matplotlib.DisplayImpl.wait ( self,
prompt = "[c(ontinue) p(db)] :",
allowPdb = True )
Wait for keyboard input

Parameters
----------
prompt : `str`
   The prompt string.
allowPdb : `bool`
   If true, entering a 'p' or 'pdb' puts you into pdb

Returns the string you entered

Useful when plotting from a programme that exits such as a processCcd
Any key except 'p' continues; 'p' puts you into pdb (unless
allowPdb is False)

The documentation for this class was generated from the following file:
  • python/lsst/display/matplotlib/matplotlib.py