Xspec Xspec Home Page

Frequently Asked Questions

Frequently Asked Questions

1. Help! Help doesn't work.

2. In v11 I used to be able to include background models using a '/b' modifier. How do I do this in v12?

3. I need the v11 extend command.

4. I'd like to use the XSPEC model library in my program. What do I do?

5. How do I calculate the flux from only one component of my model? Can I get an error on this?

6. When I do a flux error the error range given does not include the value calculated by the flux command.

7. I have an ascii optical /UV fluxed spectrum which I would like to include in a fit in XSPEC. How do I do this?

8. How can I get XSPEC to automatically perform a set of commands on start-up (including loading my local models library)?

9. What is meant by a "named" model and when are names necessary?

10. My local models library code calls functions from a third-party library. How do I get initpackage to include this library in the local models build?

11. Everytime I make a new plot, the plot window is placed in the center of the screen and takes control away from the XSPEC session window. Can I get the plot window to remain in the location I placed it, and to leave session window in control?


1. Help! Help doesn't work.

If typing "help [command]" at the XSPEC prompt doesn't bring up a document window in either pdf or html format, you may need to edit your initial settings file ~/.xspec/Xspec.init. In the section "options and commands for displaying helpfiles," the USE_ONLINE_HELP setting determines if help will open online html web pages, or the distributed help pages in pdf format.

For online viewing, the html settings should simply be set to the name of your browser (in lower-case) unless you're on a Mac or Cygwin. For Mac's it should be set to "open" and for Cygwin "cygstart." Similarly the pdf viewer is set through the PDF_COMMAND variable. Suggested settings for various platforms are listed in the file.

2. In v11 I used to be able to include background models using a '/b' modifier. How do I do this in v12?

In v12 it is possible to assign multiple detector responses to a spectrum and to define unique models for each detector number. This replaces and expands what was possible with the '/b' feature. For example, a second detector response can be added to spectrum 1:

XSPEC12>response 2:1 backgroundResponse.pha

and a corresponding model:

XSPEC12>model 2:backgroundModel

see the response and model commands for more information. An example is also available.

3. I need the v11 extend command.

The v11 extend command has been replaced by the more general energies command. With extend, the energy array was still partly constrained by the original response energies array. energies however allows you to replace the response energies with any arbitrary array, including one that can be read in from an ascii text file.

4. I'd like to use the XSPEC model library in my program. What do I do?

XSPEC models are contained in the library libXSFunctions, which can be linked into your program. The file Xspec/src/XSFunctions/xsFortran.h contains a collection of helper functions for interfacing with the XSPEC models and can be called in C, C++, and Fortran. See Appendix F for more information and a sample Makefile.

5. How do I calculate the flux from only one component of my model? Can I get an error on this?

There is a new model component cflux which can be used in front of any component (or combination of components) for which you want to calculate the flux. This component makes the flux a parameter so its confidence interval can be calculated in the usual fashion.

6. When I do a flux error the error range given does not include the value calculated by the flux command.

This is possible and does not necessarily indicate that something has gone wrong. The flux error is calculated by generating parameter sets and for each parameter set calculating a flux. The fluxes are ordered and the eg 90% range derived by excluding the bottom and top 5%. The parameter sets are drawn from an estimate of the posterior distribution which assumes a multi-dimensional Gaussian with correlation matrix given by the matrix of second derivatives at the best fit. This may not be a good estimate if parameter space is complicated. We intend to replace this by a better method involving Markov Chain Monte Carlo.

7. I have an ascii optical /UV fluxed spectrum which I would like to include in a fit in XSPEC. How do I do this?

You can convert ascii files of fluxed spectra into XSPEC spectra and unit diagonal response matrices using the ftool flx2xsp. Type fhelp flx2xsp to read how.

8. How can I get XSPEC to automatically perform a set of commands on start-up (including loading my local models library)?

You can create a file xspec.rc in your ~/.xspec directory and place in it valid commands which will be executed upon start-up. If you've already built your local models library with the initpackage command, you can add "lmod mylibrary" (without the quotes) to xspec.rc and it will load everytime you start XSPEC (except on Cygwin).

For those maintaining XSPEC for a group of users, you can also add commands to be executed for every user on start-up. These should be placed in the file headas/spectral/scripts/global_customize.tcl and will be executed before the users' xspec.rc commands. See the subsection "Customizing XSPEC" in the manual's Xspec Overview for more information.

9. What is meant by a "named" model and when are names necessary?

One of the key enhancements of XSPEC12 is the ability to analyze with multiple models. Whenever you want to define more than one model, XSPEC requires names to distinguish among them. For example:

Define an unnamed model for detector source 1. This is also the way models are defined in XSPEC11.
XSPEC12>model wa(po)

Now define a second model with the name "anotherModel," to be applied to source detector 2.
XSPEC12>model 2:anotherModel wa(ga)

Define a third model, this time for source 1 which will render the first model inactive:
XSPEC12>model 1:stillAnotherModel bbody

See the model command help and its use of the active/inactive options for more information.

10. My local models library code calls functions from a third-party library. How do I get initpackage to include this library in the local models build?

The Makefile that initpackage creates for building your local models library is based on the template file heasoft-[ver]/Xspec/src/tools/initpackage/xspackage.tmpl. If you need to add a path to the third-party library's header files, add:   -I/path/to/your/3rdParty/library/include   to the HD_CXXFLAGS setting. Then:

For Mac with all versions of HEASOFT, or Linux with HEASOFT-6.26 or later:
To make sure the linker pulls in the library, further edit the xspackage.tmpl file by adding a "-l" flag for the library (e.g. -lgsl) in the HD_SHLIB_LIBS settings.

After completing your changes to xspackage.tmpl, reinstall it by typing "hmake" and "hmake install" from the heasoft-[ver]/Xspec/src/tools/initpackage directory.

For Linux/Unix with HEASOFT versions prior to 6.26:
The XSPEC executable itself should be relinked with the new library included. So, edit the file heasoft-[ver]/Xspec/src/main/Makefile by adding a "-l" flag for the library to the HD_CXXLIBS setting. Then from the same directory do:
    rm xspec
    hmake local
    hmake publish
    hmake install


After these modifications, you should be able to use initpackage and lmod in the normal way to build and load your local models library.

11. Everytime I make a new plot, the plot window is placed in the center of the screen and takes control away from the XSPEC session window. Can I get the plot window to remain in the location I placed it, and to leave the session window in control?

When you select the plot device (with the cpd command), choose "/xs" rather than "/xw". "/xs" will set up an xwindow for persistent use.


Xspec Xspec Home Page



HEASARC Home | Observatories | Archive | Calibration | Software | Tools | Students/Teachers/Public

Last modified: Tuesday, 04-Jun-2019 16:59:56 EDT

HEASARC support for unencrypted FTP access ended on September 20, 2019. Please see this notice for details.