In [53]:
import lsst.afw.image as afwImage
import lsst.afw.display as afwDisplay

afwDisplay.setDefaultBackend("ds9")

afwDisplay.delDisplay('all')
In [54]:
exp = afwImage.ExposureF("data/HSC-0908120-056-small.fits")
In [55]:
display0 = afwDisplay.getDisplay(frame=0, backend="ds9", verbose=True)

The workhorse "display my image" routine

In [56]:
display0.mtv(exp, title="parent")

Configure the mask plane transparency (alpha); in percent and draw the CROSSTALK plane in orange

In [57]:
display0.setMaskTransparency(50)
display0.setMaskPlaneColor("CROSSTALK", "orange")

Now redisplay that image with some of the mask planes disabled

In [58]:
for frame in (0, 1):
    disp = afwDisplay.getDisplay(frame, verbose=True)
    
    disp.setMaskTransparency(50)

    if frame == 1:
        disp.setMaskPlaneColor("CROSSTALK", "ignore")
    disp.mtv(exp, title="parent")
    
    disp.erase()
    disp.dot('o', 205, 180, size=6, ctype=afwDisplay.RED)

Zoom and pan works too

In [59]:
display0.pan(205, 180)
display0.zoom(4)

afwDisplay.getDisplay(1).zoom(4, 205, 180)

Now overlay something, in this case symbols and lines

In [60]:
display0.show()  # Un-iconise and raise the display to the top of the stacking order if appropriate

display0.erase()

with display0.Buffering():
    display0.dot('o', 200, 220)
    vertices = [(200, 220), (210, 230), (224, 230), (214, 220), (200, 220)]
    display0.line(vertices, ctype=afwDisplay.CYAN)
    display0.line(vertices[:-1], symbs="+x+x", size=3)

Now control the stretch.

In [61]:
display0.show()

display0.scaleLimits("zscale")
display0.scaleType("linear")

Demonstrate the utility routine to generate mask plane colours (used by e.g. the ds9 implementation of _mtv)

In [62]:
colorGenerator = display0.maskColorGenerator(omitBW=True)
for i in range(10):
    print i, next(colorGenerator),
0 red 1 green 2 blue 3 cyan 4 magenta 5 yellow 6 red 7 green 8 blue 9 cyan

Now the make-an-image-mosaic code. Start by creating a set of 30x30 images with labels

In [63]:
images = []
labels = []
for i in range(1, 4):
    im = afwImage.ImageF(30, 30); im[:] = 100*i
    images.append(im)
    labels.append("Label %d" % i)
In [64]:
import lsst.afw.display.utils as dispUtils

m = dispUtils.Mosaic()

mosaic = m.makeMosaic(images)
disp = afwDisplay.getDisplay(frame=2)
disp.mtv(mosaic)
m.drawLabels(labels, display=disp)
In [65]:
m = dispUtils.Mosaic()
    
m.setGutter(5)
m.setBackground(10)
m.setMode("x")
    
for im, lab in zip(images, labels):
    m.append(im, lab)
    
mos = m.makeMosaic(frame=3)        # it's really better to pass a Display object