Skip to content
Omar Laurino edited this page Dec 19, 2015 · 1 revision

A collection of Sherpa jupyter (ipython) notebooks.

These notebooks are not an official product of the Chandra X-ray Center. Credit goes to the original authors.

Sherpa Quick Start Notebook

Notebooks taken from @dougburke's GitHub repository:

  • A simple fit which is based on the NumPy/SciPy fitting example from the Practical Python for Astronomers course.

  • Writing your own user model, which fits the cumulative distribution function of a data set with the Gamma CDF. The same code can be run from the CIAO version of Sherpa (I added this as we are currently lacking in documentation for how to use the add_user_model routine).

    May 26 2015.

  • An integrated user model, which fits the Gamma probability distribution function to the data set used in the 'Writing your own user model' example. This is an example of handling "integrated" data sets, and also shows off how to write a guess routine for your model, and some plot manipulations (in particular, re-creating a region-projection plot and adding extra annotations to it).

    June 4 2015.

  • How can I plot data and models when using the lower-level routines, which came up (in my mind) in the "Writing your own user model" example, where I started off using the lower-level API, but quickly switched to the higher-level (data management) API in part because I did not know how to create the plots. Well, I do know, and so can you.

    June 5 2015.

  • Extending existing models (and an example of using XSPEC models), which shows how to write a user model that extends the behavior of an existing model (in this case, subtracting a model from itself with different parameter values). It also shows how to build the XSPEC module, and so use the XSPEC models from standalone Sherpa.

    June 16 2015.

  • Simulating 2D data with a dash of error analysis, which uses the object API to simulate a 2D model (i.e. an image), fit it, and calculate errors on the parameters. This can be thought of as an extension of the previous notebooks that show how to replicate the functionality of the high-level UI layer using the object API (it also marks the start of me using the term "object API" for what I previously referred to as the "low-level API").

    June 19 2015

  • Simulating and fitting a 2D image (this time with a Bayesian approach), which is based on the previous notebook, this time showing how you can use the Monte Carlo Markov Chain (MCMC) analysis module in Sherpa (that is, the Bayesian Low-Count X-ray Spectral (pyBLoCXS) module). This notebook is mainly intended to show how to do this, rather than explain why (or the differences between the various frequentist and Bayesian methods for coming up with an error estimate).

    June 22 2015

Notebooks taken from @anetasie's GitHub repository

  • Templates: Sherpa can use the template models and combined them with the other models. Here we show a simple template fitting to the SED of a quasar. A set of accretion disk spectral models with the standard parameters (mass, accretion rate, inclination anlge) has been stored in the subdirectory Templates.

  • Image fitting: Images can be easily fit in Sherpa. In the following example we show how to include the PSF in the modeling of the central source. The X-ray Chandra image data are modeled with the gaussian shape that accounts for the point source emission (quasar in this case) and a constant for the background. We ignore the region of the image with the additional structure in the vicinity of a point source.

  • Bayes Example: A Simple Bayesian analysis of X-ray spectrum in Sherpa (requires Xspec models).