Документ взят из кэша поисковой машины. Адрес оригинального документа : http://hea-www.harvard.edu/AstroStat/slog/groundtruth.info/AstroStat/slog/2010/sherpa-cheat-sheet/comment-page-1/index.html
Дата изменения: Unknown
Дата индексирования: Sun Mar 2 22:11:43 2014
Кодировка:

Поисковые слова: п р п п р п
The AstroStat Slog » Blog Archive » Everybody needs crampons

Everybody needs crampons

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/

On Help:

  • In general, to get help, use: ahelp "something" (note the quotes)
  • Even more useful, type: ? wildcard to get a list of all commands that include the wildcard
  • You can also do a form of autocomplete: type TAB after writing half a command to get a list of all possible completions.

Data I/O:

  • To read in your PHA file, use: load_pha()
  • Often for Chandra spectra, the background is included in that same file. In any case, to read it in separately, use: load_bkg()
    • 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_arf()
    • Q: 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_rmf()
    • Q: 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: print(get_data()) and print(get_bkg())
  • To select a subset of channels to analyze, use: notice_id()
  • To subtract background from source data, use: subtract()
  • To not subtract, to undo the subtraction, etc., use: unsubtract()
  • 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.)

Fitting:

  • To fit model to the data, command it to: fit()
  • To get error bars on the fit parameters, use: projection() (or 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., set_source(xsphabs.abs1*powlaw1d.psrc+powlaw1d.pbkg))
  • To see what the model parameter values are, type: print(get_model())
  • To change statistic, use: set_stat() (options are various chisq types, cstat, and cash)
  • To change the optimization method, use: set_method() (options are levmar, moncar, neldermead, simann, simplex)

Timestamps:
v1:2007-dec-18
v2:2008-feb-20
v3:2010-apr-30

2 Comments
  1. Doug Burke:

    Vinay,

    Have you looked at the Sherpa scripts page. For instance, some of the plot options are discussed in the plotting thread, although I couldn’t see the error bars explicitly addressed. Try


    p = get_data_plot_prefs()
    print(p)
    p["yerrorbars"] = False

    To change the units of the y error bars, use the set_analysis() routine, for instance


    set_analysis("wave", type="counts")

    Also, for error estimation, we suggest you use


    conf()

    rather than projection nowadays, and note that the error analysis will be done in parallel (so expect all your cores to get used up).

    And finally,


    ,ahelp set_analysis

    can also be used to avoid quoting the first argument by using a comma before the command. This is an ipython-ism, and can be used for other commands, e.g.


    ,load_pha foo.pha

    Doug

    06-12-2010, 6:16 pm
  2. vlk:

    Thanks for the link to the Sherpa scripts page, Doug. The best way to become familiar with a new language is to see lots of simple examples.

    Also thanks for the other comments. I will probably include those comments by moving this page off to gWave shortly — it is much easier to update and make changes there than in the blog format.

    06-12-2010, 11:11 pm
Leave a comment