next up previous contents
Next: Spectral Fitting and XSPEC Up: Manual Home Page Previous: Updates to the Manual


            XSPEC is a command-driven, interactive, X-ray spectral-fitting program, designed to be completely detector-independent so that it can be used for any spectrometer. XSPEC has been used to analyze data from HEAO-1 A2, Einstein Observatory, EXOSAT, Ginga, ROSAT, BBXRT, ASCA, CGRO, IUE, RXTE, Chandra, XMM-Newton,  Integral/SPI, Swift and Suzaku. There now over 1000 papers listed on ADS which cite the Arnaud 1996 XSPEC reference.

            This manual describes XSPEC v12, which is available on Linux (gcc 3.2.2 and later), MacOSX/Darwin (gcc 3.3 and later) , Solaris (2.6-9; WS6.0 and later). New users are advised to read Chapter 2, which introduces spectral fitting and the XSPEC approach, Chapter 3, which gives an overview of the program commands, and Chapter 4, which contains walkthroughs of XSPEC sessions. They should then experiment with XSPEC and, if necessary, look up individual commands in Chapter 5, or descriptions of the spectral models in use, in Chapter 6.

            The User Interface for XSPEC, which employs a tcl scripting shell and the XSPEC parser are described in Appendix A. Users possessing X-ray spectra with small numbers of counts per bin are referred to Appendix B, which describes the C-statistic option. Users interested in adding their own models can read how to do so in Appendix C. Appendix D describes the PLT plotting package which XSPEC currently uses for graphical output. Some of the tools (FTOOLS, fortran programs, scripts) that can operate on XSPEC files are listed in Appendix E. The XSPEC model library can be linked into other programs following the instructions in Appendix F. Appendix G describes how to use your own proposal distribution for Markov Chain Monte Carlo. Finally, Appendix H includes some notes on the changes between XSPEC v11 and v12.

New in v12.9.0

New features:

·         Mix model components are no longer heavily restricted in their usage. Previously mix components could only be placed at the start of a model expression, to operate on the results of the rest of the expression. Now they can be inserted throughout the expression in the same manner as convolution components.

·         Models with mix components can also be assigned to source numbers other than 1.  A corollary of this is that a mix model is no longer required to operate on all currently loaded spectra.

·         To allow more than one mix model at a time the syntax for XFLT#### keywords has been generalized. These keywords are now strings of form "key: value" with xspec maintaining an internal database of key, value pairs which mixing model code can access. Backward compatibility with the old version of XFLT#### containing only a value is maintained.

·         Expanded the types of expressions allowed in parameter linking.  It can now handle the same mathematical functionality supported in mdefine equations.  Related to this, parameters can also be specified as 'p#' and 'modelName:p#' in link expressions, as well as the old '#' and 'modelName:#'.  The link expressions are now displayed using the 'p#' format.

·         The output of the 'plot margin' command is now independent of the grid size. There is a new 'plot integprob' command which also must be run after the 'margin' command and which plots the integrated probability within the contours shown. The data and back commands now handle files with multiple SPECTRUM extensions. There are a number of ways of specifying a particular extension: filename{N} will use the Nth SPECTRUM extension; filename{SPECTRUM2} will look for an extension called SPECTRUM2; filename{back} will use the first SPECTRUM extension with the HDUCLAS2 keyword set to 'BKG'; filename{name=value} will look for a SPECTRUM extension with keyword name set to value (in this case there must be no spaces within the {}). If the BACKFILE keyword in a source filename is set to the filename itself then XSPEC will get the background from the extension with HDUCLAS2 set to 'BKG' (this, finally, makes Chandra level 3 files work seemlessly in XSPEC).

·         The 'error' command now has a 'nonew' option.  This determines whether to repeat the calculation when a new minimum is found.  Previously it was relying on the 'query' setting to make this decision.

·         Added grey-scale image as background to to contour plots. 'dem' plots now display a histogram. The new 'eqw' plot option shows the distribution of equivalent width values after running the eqwidth command with the err option.

·          New model 'nlapec'. There is also an APECNOLINES xset option which will turn off lines for all apec models.

·         The models using AtomDB files now require the line files to be sorted in increasing order of energy within each element and ion. This allows a speed-up in the model calculation.

·         Replaced the rescalecov script with the 'chain rescale' command.

·         The 'plot delc' command now works for cstat, plotting (obs-mod)/error, however it is important to remember that this is not plotting contributions to the statistic.


Enhancements previously released as patches to 12.8.2:

·         A new -udmget64 option has been added to initpackage.  This is intended for Mac platform users with local Fortran models which still make use of the udmget memory allocation function.

·         'tclout steppar' can now retrieve values of the variable parameters as well has the fixed parameters which are being stepped through.


All bug fixes to v12.8.2 released as patches are included in v12.9.0. In addition the following problems have been corrected:

·      For the case where counting statistics are not applied, 'fakeit' now outputs the spectrum in a RATE column rather than COUNTS. This is to remove bias caused by truncation errors.  It also now outputs a STAT_ERR column and sets the POISSERR flag to false.

·      Special characters have been removed from all model parameter names and (generally) replaced with underscores.  This is to make their name strings more easilty accessible in PyXspec.

·      When calculating 'tclout peakrsid' with Cstat, it should not make use of correction files.

·      Redundant model fold calculations have been removed during certain update contexts.

·      Fix to vequil model array assignment error.

·      The default filenames for fakeit output should always be in the current run directory, even when the response file is in a different directory.

·      A file-write race condition has been eliminated for the case of running 'lmod' in parallel XSPEC sessions.

·      The vvnei model had the tau and meankT parameters flipped.

·      The AtomDB input files were being reopened unnecessarily often.


How to find out more information

XSPEC is distributed and maintained under the aegis of the GSFC High Energy Astrophysics Science Archival Research Center (HEASARC). It can be downloaded as part of HEAsoft


XSPEC is available either as binaries or source. We recommend downloading the source and compiling locally to avoid potential system library conflicts and allow installation of any patches we release. If you have any problems compiling or running XSPEC please e-mail us at

The XSPEC Web page comprises links to the anonymous ftp site, a Web version of the manual, and several useful documents, including a list of known bugs. The Web address is

with the list of issues and available patches at


and additional models which can be added at


Further useful information can be found on the XSPEC Wiki at


and the xspector blog at



The first version of XSPEC was written in 1983 at the Institute of Astronomy, Cambridge, under VAX/VMS by Rick Shafer. It was written to perform spectral analysis of data from the ESA EXOSAT X-ray observatory, which was launched that year. XSPEC is a descendant of a series of spectral-fitting programs written at NASA/Goddard Space Flight Center for the OSO-8, HEAO-1 and EO missions. The initial design was the fruit of many discussions between Rick Shafer and Andy Szymkowiak.  Rick Shafer subsequently joined the EXOSAT group, where he enhanced the VAX/VMS version in collaboration with Frank Haberl. Meanwhile, Keith Arnaud ported XSPEC to a Sun/UNIX operating system. The two implementations of XSPEC diverged for several years until a determined and coordinated effort was made to recover a single version. The results of that effort was XSPECv6, described in the first edition of this manual. Subsequent editions have covered later versions of the program.  In recent years XSPEC has become the de facto standard for X-ray spectroscopic analysis for the ROSAT mission and the de jure standard for the BBXRT, ASCA, and RXTE missions. It is now in extensive use for all current X-ray and gamma-ray missions. An extensive re-engineering effort was started in the fall of 1998 to improve long-term maintainability, allow significant new features to be added, and support the analysis of spectra from coded-mask instruments.


This project would not have been possible without ignoring the advice of far more people than can be mentioned here. We would like to thank all our colleagues for their suggestions, bug reports, and (especially) source code. The GSFC X-ray astronomy group are particularly thanked for their patience exhibited while functioning as the beta test site for new releases. The initial development of XSPEC was funded by a Royal Society grant to Prof. Andy Fabian and subsequent development was partially funded by the European Space Agency's EXOSAT project and is now funded by the HEASARC at NASA/GSFC.


Arnaud, K.A., 1996, Astronomical Data Analysis Software and Systems V, eds.  G. Jacoby and J. Barnes,p17, ASP Conf. Series volume 101.

Dorman, B., and Arnaud, K. A. 2001, Astronomical Data Analysis Software and Systems X eds.  F.R. Harnden, Jr., F.A. Primini, and H. E. Payne, vol. 238, p. 415

Dorman, B., Arnaud, K. A., and Gordon, C. A. XSPEC12: Object-Oriented X-Ray Data Analysis, AAS HEAD meeting No. 35, #22.10


next up previous contents
Next: Spectral Fitting and XSPEC Up: Manual Home Page Previous: Updates to the Manual