The sherpa.astro.xspec module

Support for XSPEC models.

Sherpa supports versions 12.13.0, 12.12.1, and 12.12.0 of XSPEC [1], and can be built against the model library or the full application. There is no guarantee of support for older or newer versions of XSPEC.

To be able to use most routines from this module, the HEADAS environment variable must be set. The get_xsversion function can be used to return the XSPEC version - including patch level - the module is using:

>>> from sherpa.astro import xspec
>>> xspec.get_xsversion()

Initializing XSPEC

The XSPEC model library is initalized so that the cosmology parameters are set to H_0=70, q_0=0.0, and lambda_0=0.73 (they can be changed with set_xscosmo).

The other settings - for example for the abundance and cross-section tables - follow the standard rules for XSPEC. This means that the values are taken from the user’s XSPEC configuration file - either ~/.xspec/Xspec.init or $HEADAS/../spectral/manager/Xspec.init - for these settings (in particular note that the default value for the photo-ionization table is ‘vern’ rather than ‘bcmc’ which used to be the case in XSPEC 12.10.0 and earlier).

The default chatter setting - used by models to inform users of issues - was set to 0 (which hid the messages) until Sherpa 4.14.0, when it was changed to 10 (to match XSPEC).

Supported models

The additive [2], multiplicative [3], and convolution [4] models from the XSPEC model library are supported, except for the smaug model [5], since it requires use of information from the XFLT keywords in the data file).

Parameter values

XSPEC parameters have soft and hard limits but they are different to the Sherpa meaning:

  • the XSPEC hard limit is more-like a Sherpa parameter with the same soft and hard limits;

  • and it is possible to change the hard limits.

To support these, XSPEC models use the XSBaseParameter and XSParameter classes, while the “norm” parameter added to additive models remains a sherpa.models.parameter.Parameter instance.


This document describes the base classes for XSPEC models, and the utility routines - such as querying and retrieving the abundance table information. The models provided by XSPEC are described in The sherpa.astro.xspec module.


XSBaseParameter(modelname, name, val[, min, ...])

An XSPEC parameter.

XSParameter(modelname, name, val[, min, ...])

An XSPEC parameter where you exceed the hard limits.

XSModel(name, pars)

The base class for XSPEC models.

XSAdditiveModel(name, pars)

The base class for XSPEC additive models.

XSMultiplicativeModel(name, pars)

The base class for XSPEC multiplicative models.

XSConvolutionKernel(name, pars)

The base class for XSPEC convolution models.

XSConvolutionModel(model, wrapper)

Evaluate a model and pass it to an XSPEC convolution model.

XSTableModel(filename[, name, parnames, ...])

Interface to XSPEC table models.



Return the X-Spec abundance setting or elemental abundance.


Return the chatter level used by X-Spec.


Return the X-Spec cosmology settings.


Return the path to the files describing the XSPEC models.


Return the path to the model data files.


Return the state of the XSPEC module.


Return the version of the X-Spec model library in use.


Return the cross sections used by X-Spec models.


Return the X-Spec model setting.

read_xstable_model(modelname, filename[, etable])

Create a XSPEC table model.


Set the elemental abundances used by X-Spec models.


Set the chatter level used by X-Spec.

set_xscosmo(h0, q0, l0)

Set the cosmological parameters used by X-Spec models.


Set the path to the files describing the XSPEC models.


Restore the state of the XSPEC module.


Set the cross sections used by X-Spec models.

set_xsxset(name, value)

Set a X-Spec model setting.

Class Inheritance Diagram

Inheritance diagram of XSBaseParameter, XSParameter, XSModel, XSAdditiveModel, XSMultiplicativeModel, XSConvolutionKernel, XSConvolutionModel, XSTableModel