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.

Monday, January 21, 2013

Standalone Sherpa Installation for X-ray Analysis

Tom just updated the instructions for building Standalone 4.5 Sherpa for X-ray Analysis. This build is good for all types of data modeling not only X-rays.  Check out the AstroPython web page: http://www.astropython.org/

Tuesday, January 15, 2013

Standalone Sherpa 4.5.0 Released as Source Code

I have released the standalone version of Sherpa 4.5.0 at the Sherpa website:

http://cxc.cfa.harvard.edu/contrib/sherpa/

As in past releases, the purpose is to allow Python users to install Sherpa as a Python module, without reference to any other CIAO package or program.

I release the source code tarball, sherpa-4.5.0.tar.gz, that contains all the Sherpa source code we released with CIAO 4.5.  Release notes can be found at NOTES-4.5.0.txt.  The new version is also available at the cxcdev github repository for Sherpa.

This is a major release, to sync the standalone version with the recent CIAO 4.5 release.

Wednesday, January 9, 2013

Sherpa at the AAS 221st Meeting

Chandra booth at the AAS meeting shows demos of Sherpa in CIAO. You can stop by, meet people and ask questions.

VO booth, around the corner from Chandra one, shows IRIS package which uses Sherpa in SED fitting of the data.

Thursday, December 20, 2012

New version of Sherpa in CIAO 4.5 Release

New Sherpa version was included in CIAO 4.5 software release on Dec.13, 2012. Here is the CIAO download page: http://cxc.harvard.edu/ciao/download/
The standalone Sherpa will be coming in early January 2013.

New Sherpa is build with Python 2.7.2 and IPython 0.13.


Friday, August 3, 2012

Standalone Sherpa 4.4.1 Released

I have released the standalone version of Sherpa 4.4.1 at the Sherpa website:

http://cxc.cfa.harvard.edu/contrib/sherpa/

As in past releases, the purpose is to allow Python users to install Sherpa as a Python module, without reference to any other CIAO package or program.

I release the source code tarball, sherpa-4.4.1.tar.gz, that contains all the Sherpa source code we released with CIAO 4.4.1.  Release notes can be found at NOTES-4.4.1.txt.  The new version is also available at the cxcdev github repository for Sherpa.

This is a minor patch update.  I have added support for the XSPEC 12.7.1 libraries, and interfaces to seven new additive models.  The Sherpa 4.4.0 tarball is still available in the download directory.

I am also working on Mac disk images.  I am nearly done with them, thanks to input from Brian a little while back.

Wednesday, June 6, 2012

Goodness of Fit with CSTAT/CASH

Sherpa has two statistics derived from the Poisson likelihood called Cash and CSTAT.  In this case the measure of goodness of fit requires simulations. Sherpa sampling functions make these simulations really easy.  After fitting the data using these statistics one can simply use a sampler and plot the resulting distributions. The sampler will generate a number of parameter sets using the sampling distribution  (normal, t, uniform) centered on the best fit parameter values. One can then check whether
the CSTAT or Cash values given for these parameters are largely different than the ones obtained by fitting the data.

fit()
sim = normal_sample( num=1000 )
plot_cdf( sim[ :, 0] )

plotting the cummulative distribution of the statistic values provides immediate visualization of
the best fit statistics in comparison to the simulations. The best fit statistic values should be close to the 0.5 in the cdf, so about 50% of the values. If the best fit statistics value is not close to 50% in the cdf plot then the fit is not good.

Using numpy we can also check the minimum and median of the simulated distribution in comparison to the best fit values.

# first check the current statistics, then check the simulations:

calc_stat_info()
numpy.min( sim[ :, 0 ])
numpy.median( sim[ :, 0 ])