Advanced Python Scripting using Sherpa

Refsdal, Brian

Sherpa is a general purpose modeling and fitting application written in Python. The dynamism of Python allows Sherpa to be a powerful and extensible software package ready for the modern challenges of data analysis. Primarily developed for the Chandra Interactive Analysis of Observations (CIAO) package, it provides a flexible environment for resolving spectral and image properties, analyzing time series, and modeling generic types of data. Complex model expressions are supported using Sherpa's general purpose definition syntax.

Sherpa's parametrized data modeling is achieved using robust optimization methods implementing the forward fitting technique. Sherpa includes functions to calculate goodness-of-fit and parameter confidence limits. CPU intensive routines are written in C++/FORTRAN. But since all other data structures are contained in Python modules, users can easily add their own data structures, models, statistics or optimization methods to Sherpa.

We will introduce a scripted example that highlights Sherpa's ability to estimate energy and photon flux errors using simulations. The draws from these simulations, accessible as NumPy ndarrays, can be sampled from uni-variate and multi-variate normal distributions and can be binned and visualized with simple high level functions. We will demonstrate how Sherpa can be extended with user-defined model and statistic classes written in Python. Sherpa's open design allows users to incorporate prior statistics derived from the source model. Loops in the user-defined model are implemented in C and wrapped for use in Python. We will also show an example of a Sherpa work-flow that produces fitted data products for input spectra using SAMP to communicate with other SAMP-enabled applications like CSCview.

Support of the development of Sherpa is provided by National Aeronautics and Space Administration through the Chandra X-ray Center, which is operated by the Smithsonian Astrophysical Observatory for and on behalf of the National Aeronautics and Space Administration contract NAS8-03060.

Return to poster list