Wednesday, February 13, 2013

Running IPython Notebook in CIAO/Sherpa

I wanted to work with  IPython Notebook  in CIAO to create a nice record of analysis for my collaborators. Sherpa uses IPython 0.13, but CIAO does not come with 'pyzmq' and 'tornado'  required for running the Notebook. I also needed to install zmq library.  

Here are my installation steps after my downloading and installing CIAO 4.5 binaries on my iMAC OS 10.6.8:

1/ Start with "zmq" library. 

   Download  zeromq-3.2.2.tar.gz (version from23-Nov-2012 09:01) from: http://download.zeromq.org

tar xvf zeromq-3.2.2.tar.gz       
cd zeromq-3.2.2      
 ./configure
make
sudo make install

2/  Install pyzmq into CIAO area.

    Need to "source $ASCDS_INSTALL/bin/ciao.csh" to be in CIAO environment for installation in CIAO Python site-packages area. This can be done with "ciaorun" as I did below:
download the source file pyzmq-2.2.0.tar.gz from: http://pypi.python.org/pypi/pyzmq/2.2.0

tar xvf pyzmq-2.2.0.tar.gz
cd pyzmq-2.2.0
ciaorun python setup.py install \
  --prefix=$ASCDS_INSTALL

3/ Install tornado into CIAO area.

 Download the source file tornado-2.4.1.tar.gz from: http://pypi.python.org/pypi/tornado

tar xvf tornado-2.4.1.tar.gz
cd tornado-2.4.1/
ciaorun python setup.py install \
  --prefix=$ASCDS_INSTALL

4/ Run IPython Notebook


ipython notebook will start  a notebook session in your browser. Open the New Notebook to get to the interactive session. In the first cell type:

import numpy as np
from sherpa.astro.ui import *
from pychips import *

and then shift-return to run it. In the second cell:

x = np.arange(20)
y = np.sin(x)
add_curve(x,y)

shift-return to run it. You should see the CHIPS plot appearing outside the browser.