Sherpa is a fitting environment in which Chandra data (and really, X-ray data from any observatory) can be analyzed. It has just undergone a major update and now runs on python. Or allows python to run. Something like that. It is a very powerful tool, but I can never remember how to use it, and I have an amazing knack for not finding what I need in the documentation. So here is a little cheat sheet (which I will keep updating
as and when if I learn more):
2010-apr-30: Aneta has setup a blogspot site to deal with simple Sherpa techniques and tactics: http://pysherpa.blogspot.com/
- In general, to get help, use:
ahelp "something"(note the quotes)
- Even more useful, type:
? wildcardto get a list of all commands that include the
- You can also do a form of autocomplete: type TAB after writing half a command to get a list of all possible completions.
- To read in your PHA file, use:
- Often for Chandra spectra, the background is included in that same file. In any case, to read it in separately, use:
- Q: should it be loaded in to the same dataID as the source?
- A: Yes.
- A: When the background counts are present in the same file, they can be read in separately and assigned to the background via
set_bkg('src',get_data('bkg')), so counts from a different file can be assigned as background to the current spectrum.
- To read in the corresponding ARF, use:
load_bkg_arf()for the background — should it be done before or after
load_bkg(), or does it matter?
- A: does not matter
- To read in the corresponding RMF, use:
load_bkg_rmf()for the background, and same question as above
- A: same answer as above; does not matter.
- To see the structure of the data, type:
- To select a subset of channels to analyze, use:
- To subtract background from source data, use:
- To not subtract, to undo the subtraction, etc., use:
- To plot useful stuff, use:
plot_data(), plot_bkg(), plot_arf(), plot_model(), plot_fit(),etc.
- (Q: how in god’s name does one avoid plotting those damned error bars? I know error bars are necessary, but when I have a spectrum with 8192 bins, I don’t want it washed out with silly 1-sigma Poisson bars. And while we are asking questions, how do I change the units on the y-axis to counts/bin? A: rumors say that
plot_data(1,yerr=0)should do the trick, but it appears to be still in the development version.)
- To fit model to the data, command it to:
- To get error bars on the fit parameters, use:
covar(), but why deliberately use a function that is guaranteed to underestimate your error bars?)
- Defining models appears to be much easier now. You can use syntax like:
set_source(ModelName.ModelID+AnotherModel.ModelID2)(where you can distinguish between different instances of the same type of model using the ModelID — e.g.,
- To see what the model parameter values are, type:
- To change statistic, use: set_stat() (options are various
- To change the optimization method, use:
levmar, moncar, neldermead, simann, simplex)