LSST Applications g070148d5b3+33e5256705,g0d53e28543+25c8b88941,g0da5cf3356+2dd1178308,g1081da9e2a+62d12e78cb,g17e5ecfddb+7e422d6136,g1c76d35bf8+ede3a706f7,g295839609d+225697d880,g2e2c1a68ba+cc1f6f037e,g2ffcdf413f+853cd4dcde,g38293774b4+62d12e78cb,g3b44f30a73+d953f1ac34,g48ccf36440+885b902d19,g4b2f1765b6+7dedbde6d2,g5320a0a9f6+0c5d6105b6,g56b687f8c9+ede3a706f7,g5c4744a4d9+ef6ac23297,g5ffd174ac0+0c5d6105b6,g6075d09f38+66af417445,g667d525e37+2ced63db88,g670421136f+2ced63db88,g71f27ac40c+2ced63db88,g774830318a+463cbe8d1f,g7876bc68e5+1d137996f1,g7985c39107+62d12e78cb,g7fdac2220c+0fd8241c05,g96f01af41f+368e6903a7,g9ca82378b8+2ced63db88,g9d27549199+ef6ac23297,gabe93b2c52+e3573e3735,gb065e2a02a+3dfbe639da,gbc3249ced9+0c5d6105b6,gbec6a3398f+0c5d6105b6,gc9534b9d65+35b9f25267,gd01420fc67+0c5d6105b6,geee7ff78d7+a14128c129,gf63283c776+ede3a706f7,gfed783d017+0c5d6105b6,w.2022.47
LSST Data Management Base Package
|
In April 2015 we restructured the image display code to be backend agnostic, while still only supporting a virtualDevice (which does nothing), and ds9 (http://hea-www.harvard.edu/RD/ds9) for the present. At the same time we made the interface object oriented — opening a display returns an object (the old functional interface with a frame argument is supported for backward compatibility).
Although ds9 has a number of drawbacks (slow; slightly unstable API; awkward to use with firewalls) it also as a number of advantages: Supported by the CfA; ubiquitous in astronomy; support for WCS; support for multiple frames.
The basic functionality is in lsst.afw.display
, and the workhorse routine is mtv
. The simplest use is simply to setup afw and display_ds9, start ds9 (you may have to install it yourself) and python, and type:
Rather than saving disp
in a variable, you can say
and if the display doesn't exist it'll be created for you. You can say e.g.
to create a rather useless display named "2" using the do-nothing virtualDisplay
device; you're more likely to specify "ds9"
or (soon) "firefly"
.
You can display images in multiple frames, either by explicitly specifying the frame, or by setting the default with afwDisplay.setDefaultFrame()
. If you are using the ds9 backend and there's a strong desire for multiple instances of ds9 this could be supported (by choosing different tcp ports); file a ticket if this is really important for you. ds9 uses integers as its ‘frame’ identifiers, but other display devices may use other types (e.g. strings).
See the manual at lsst.afw.display.interface.Display for all the supported commands, and the iPython notebook at examples/imageDisplay.ipynb for examples (we'll provide an nbviewer link once this is pushed to github).
Whenever you're writing more than a few glyphs we strongly recommend that you turn on buffering (it's certainly necessary when you're using the ds9 backend). The simplest way to do this is by using python's with
statement:
You can explicitly flush the buffer at anytime with disp.flush()
The mtv
command handles all of the LSST image types:
The pixels are displayed on your image display. Images don't have a Wcs, so no astronomical WCS information is available, but we do support WCSA
and WCSB
; the former is 0-indexed pixel coordinates allowing for the Image's XY0
; the latter is 0-indexed pixel coordinates relative to the bottom left pixel being (0,
0
).
mtv
accepts an optional wcs
argument, which allows you to provide an astronomical Wcs (but if you have an DecoratedImage or Exposure this is done for you)
Displayed like Image, but with the default WCS set from the DecoratedImage's Wcs
Overlay the current display with the Mask.
If you're using the ds9 backend there's a bug that prevents you from displaying a pure Mask, but you can use the isMask
argument to force the Mask to be treated as a 16-bit image. Also, the Mask display isn't as fast as you might like, as ds9's current API requires us to send each mask plane as a separate 16-bit image (I have asked Bill Joy at CfA to change this). Each bitplane may be given a separate colour; you can inspect the current mapping with getMaskPlaneColor
or set it with setMaskPlaneColor
. If a mask plane has no defined colour, one will be chosen for you.
You may vary the mask's transparency, either via the GUI or with e.g. setMaskTransparency(50)
.
The image-plane pixels are displayed, overlaid with the mask. If you want to look at the variance too, you'll need to say something like:
Wcs
You won't need to configure the display code at all if you're happy with ds9, as it is the default-default backend when available (i.e. if you have display_ds9 setup).
At some point we may add a configuration mechanism using environment variables and/or dot files, but for the present the recommended way to set your preferred display environment is by using python's startup file. E.g. if you have the environment variable $PYTHONSTARTUP set to ~/
.pythonrc, you'd edit ~
.pythonrc to say something like:
There are facilities to build mosaics of images in lsst.afw.display.utils
(n.b. these are mosaics in the sense of a tiled floor; we're not building astrophysical mosaics projected on the sky.)
The basic class is Mosaic:
You can return the (ix, iy)th (or nth) bounding box with getBBox()
See lsst.afw.display.utils.Mosaic for more details; there are examples near the end of the iPython notebook at examples/imageDisplay.ipynb (we'll provide an nbviewer link once this is pushed to github).
If you're using ds9 you may want to use it through a firewall; here's how.
On your home machine, type
(setenv XPA_PORT "DS9:ds9 22345 22346"
for csh users, of course)
On lsstXXX.ncsa.uiuc.edu
, set XPA_PORT
to the same value, setup display_ds9
and afw
, start python
, import lsst.afw.display as afwDisplay
and proceed:
xpa afficianados will note that I'm bypassing the xpa name server; it needs another set of 2 or 3 ports tunnelled, and setting up ACLs.
Here's a script (in afw/examples
) to run on your home machine that should simplify setting up/tearing down the ssh tunnels. It's not great, so improvements would/will be welcomed.