Many people’s workflows these days involve running IPython notebooks, and often ds9 as well as their image browser of choice. However, these don’t play all that nicely with running the stack on lsst-dev, as IPython notebook are controlled through web-browsers, and using ds9 with X-forwarding largely negates the advantages offered by ds9 (fast, interactive re-scaling & panning etc.)
This is a tutorial designed to help people setup and run the stack on lsst-dev, with the IPython kernels running there, but controlling these in a local web-browser, and with a local copy of ds9, as opposed running ds9 on lsst-dev and X-forwarding the images (and all the lag that brings).
On your local machine, create/edit the file: ~/.ssh/config and add the entry:
Host lsst-dev Hostname lsst-dev.ncsa.illinois.edu User <your username> RemoteForward XXXX localhost:XXXX RemoteForward <XXXX+1> localhost:<XXXX+1> LocalForward YYYY localhost:ZZZZ ForwardAgent yes ForwardX11 yes ForwardX11Trusted yes
where XXXX and XXXX+1 are random consecutive numbers greater than 4096, and YYYY and ZZZZ are any other random numbers greater than 4096. I have not included values here, because otherwise once multiple people have followed these instructions we will end up with a bunch of collisions and a tangled, buggy mess!
On your local machine configure the XPA ports for ds9 by typing:
export XPA_PORT="DS9:ds9 XXXXX XXXXX+1"
and open an ssh tunnel with port forwarding:
ssh -N -f -L localhost:ZZZZ:localhost:YYYY firstname.lastname@example.org
using the values from above. Now, launch ds9. If you have a from-source version then just launch by typing ‘ds9 &’ from the same terminal. If you have an OS-X “app style” distribution you can try launching it from the OS-X GUI as you usually would, but you will need check whether it has picked up the XPA port config from the environment by clicking File—>XPA—>Information in ds9 and confirming that the number after the colon under XPA_METHOD is equal to XXXXX from before (sometimes it is, sometimes it isn’t, I haven’t figured out why ). If it is then you’re fine. If it’s not then close ds9 and relaunch the ‘app’ from the terminal by typing:
open /Applications/SAOImage\ DS9.app/ &
Now, login to lsst-dev by typing just:
so that it picks up the config from the ssh config file. You should not be prompted for a password (unless it is for your ssh key via an OS-X dialog) as you should have set up your keys. I believe that if this is not the case then you are going to have problems.
On lsst-dev setup the stack: (or use one of these methods)
source /lsst/stack/loadLSST.sh (or appropriate for your shell)
and specify the XPA ports on this machine too, using the same values as before:
export XPA_PORT="DS9:ds9 XXXXX XXXXX+1”
Now, cd to wherever your IPython notebook directory is, eg:
and launch the IPython notebook with no browser, specifying the port from before:
ipython notebook --no-browser --port=YYYY
or, for a continuous session something along the lines of:
nohup ipython notebook --no-browser --port=YYYY >> ~/ipython_notebooks/stdout.txt
Now, on your local machine, launch firefox (or your browser of choice), and go to:
This should connect you to the remote kernel. To test that you have a remote kernel with the stack loaded correctly and the instance of ds9 on your local machine correctly connected, open a new notebook and do the following:
import lsst.afw.image as afwImage import lsst.afw.display as afwDisplay import numpy as np data = np.zeros((10,10), dtype=np.float32) img = afwImage.ImageF(data) afwDisplay.mtv(img,frame=0)
a small, 10x10 black box should appear inside ds9 on your local machine.
If it does, you have succeeded!
If it does not, I have failed
PS: If you just want to try a local stack with a local ds9:
Open ds9 (either cmdline version or the “App”), mainly just to check if you have it installed. The stack should try to launch it for you, but I think this only works for the cmdline version and not the App.
import lsst.afw.display.ds9 as ds9 import lsst.afw.image as afwImage import numpy as np data = np.zeros((100,100), dtype = np.float32) img = afwImage.ImageF(data) ds9.mtv(img,frame=1)