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, and Integral/SPI.
This manual describes the new version, XSPEC12, 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) and which has been re-engineered to allow future growth (see next section for details). 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 walk-throughs 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.
Since its inception in 1983 XSPEC has continued to be a mission independent general purpose analysis environment for X-Ray spectra. The decision was made in 1998 to re-engineer it using methods of modern computer science in order for it to be able to continue fulfilling that role.
The program’s internal design, layout, and data structures have largely been rewritten in ANSI C++ using object oriented design techniques, generic programming techniques, and design patterns.The thoroughgoing reanalysis has also allowed a number of improvements in overall design and, at robustness, as well as maintainability, without changing the familiar syntax.With a few exceptions here and there, the new program syntax is fully backward-compatible with that of XSPEC11: most of the exceptions support new features that are enhancements (and can be ignored if not relevant to the user’s problems). Some features of XSPEC11 previously declared to be deprecated have been removed.
At the same time, the core of XSPEC’s calculation scheme has been retained, in particular the models library, written almost exclusively in fortran77.
The implementation of user models has been rewritten to allow users to write models not only calculated in single precision fortran, but double precision fortran, C, and C++. Further, XSPEC can now be used as a development environment for user models by allowing recompilation and plotting from the XSPEC command prompt.
In XSPEC12, spectra can be fit with more than one distinct model simultaneously, provided separate model components can be assigned distinct response functions, such as with coded aperture masks.
A new internal dynamic expression implementation allows more complex (multiply-nested) models, and also allows parameter links to be polynomial functions of one or more parameters.
Great care has been taken to ensure that the program is efficient in memory usage and execution speed. A revision of the numerical derivative algorithm has allowed the reduction in the number of convolution operations required during fitting. On the other hand, XSPEC12 performs its calculations in double precision (apart from the models library), and the more complex model expression evaluations both reduce execution speed. Taken together, XSPEC12 should outperform XSPEC11 where the number of channels is large and the model to be fitted is relatively simple and should be comparable in other circumstances.
The default fitting algorithm (the Levenberg-Marquadt algorithm for non-linear fitting of analytic models) has been retained intact. New fitting algorithms and objective functions (statistics) may be added to the program at runtime. The CERN Minuit/migrad algorithm has been better integrated into the code and its documentation is now directly accessible to the user during XSPEC sessions.
Type II (multi-spectrum) OGIP files are now fully supported. Multiple ranges can be selected in the data command, and support is present for Type II background and arf files. Observation simulations (the fakeit command) now operate on Type II inputs.
The online documentation scheme is now implemented using pdf files, replacing the older VMS-style help system. The help scheme can be configured to use external applications such as Adobe Acrobat or the xpdf readers. Users can document their own local models and tcl-scripted procedures in pdf files and add them to the help system.
Plotting within XSPEC is backward compatible with a few small extensions. Although it is currently implemented as before using PLT, XSPEC’s code is now separated from explicit dependence on the plot library, which will allow the use of alternative plotting libraries in the future. The PLT plotting package is described briefly in Appendix D and in more detail in the “QDP/PLT User's Guide” (Tennant, 1989).
XSPEC12 communicates with the user through the familiar command line interface. The input/output streams, however, can be easily redirected to communicate with the user through a graphical user interface (GUI). Development of a GUI is currently in its early stages.
Finally, the design implements a new error handling system which has the capability of returning the program safely to the user prompt when an error occurs and leaving the program in a state from which the user can continue working. Also, for the first time there is now an undo command.
The INTEGRAL Spectrometer (SPI) is a coded-mask telescope, with a 19-element Germanium detector array. There are several complications regarding the spectral de-convolution of coded-aperture data. For XSPEC the most obvious problem is the source confusion issue; as there may be multiple sources in the FoV leading to different degrees of shadowing on different detectors. Thus, a separate instrumental response must be applied to a spectral model for each possible source, for each detector. If there are multiple sources in the FoV, then additional spectral models can be applied to an additional set of response matrices, enumerated as before over detector and dither pointing. This capability —to model more than one source at a time in a given minimization procedure—did not exist in previous versions of XSPEC. The other unique aspect of the INTEGRAL analysis is that the background is modeled along with the source(s) in a single de-convolution.
XSPEC analysis of INTEGRAL/SPI data is very different from other instruments is the manner in which the response matrices are handled. Since there are a large number of responses involved in the de-convolution problem, memory use becomes a concern. To load the required response matrices (as XSPEC normally does), would require ~(Nch)2´Np´Nd floating-point memory locations per source. This could become quite large for high-spectral resolution and/or long observation scenarios. To address this problem, a methodology has been developed to reconstruct the required 2-D response matrices from a basis set, consisting of a small number (3) of 2-D objects (template RMFs), and a larger number of 1-D objects (component ARFs). The full matrices can then be reconstructed "on the fly" at the minimization step of the calculation, and discarded after each use. This, in principle, occurs all very transparently to the user.
A fuller description of Integral data analysis appears in section 2 of this manual and a walkthrough example is given in 4.6.
The commands and features not provided in XSPEC12.2 are:
Feature |
Rationale for exclusion |
recornorm command |
recornorm modifies the internal computation of the statistic and its derivatives. It is intended to generalize this feature to allow fitting to the background and also for more complex gain variations. |
mdefine command |
mdefine will be reimplemented using XSPEC12’s expression parser once the parse has been extended for transcendental mathematical expressions. |
thleqw |
rarely used command not yet implemented. |
extend |
Beginning with version 12.3.0, this has been replaced by the more flexible energies command. |
background models |
This has been replaced by XSPEC12’s multiple source modeling techniques |
improve |
Minuit specific algorithm not yet implemented |
Additionally, we have withdrawn seldom-used fitting methods anneal and genetic. Future development will add new techniques.
XSPEC is distributed and maintained under the aegis of the GSFC High Energy Astrophysics Science Archival Research Center (HEASARC). If you have any problems with XSPEC please e-mail us at
If you want to be added to our electronic mailing list for announcements of new releases then send mail to
with the main body of the message comprising the line
subscribe XANADU Your Name
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
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 the Chandra and XMM-Newton missions. The HEASARC, which has supported the development of XSPEC since 1990, intends to use XSPEC for future missions as well as for those whose data are being resurrected. The effort to re-engineer XSPEC was begun in the fall of 1998 partly because of the realization that the internal code did not easily generalize to support analysis of coded-mask instruments. The need was also seen to reengineer the program to allow significant new features to be added (support for new data formats, fitting methods; interfaces and plotting libraries) well into the future, while retaining a high degree of backward compatibility.
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 now by the NASA/GSFC HEASARC.
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