make_xstable_model

sherpa.astro.io.xstable.make_xstable_model(name: str, egrid_lo: Any, egrid_hi: Any, params: list[Param], spectra: list[Any], addparams: list[BaseParam] | None = None, addspectra: list[list[Any]] | None = None, addmodel: bool = True, redshift: bool = False, escale: bool = False, lolim: float = 0, hilim: float = 0, units: str | None = None, xfxp: list[str] | None = None) list[TableHDU][source] [edit on github]

Create the blocks for a XSPEC table model.

An XSPEC table model can be either additive or multiplicative, contain 1 or more interpolated parameters, 0 or more additional parameters, and support additional parameters (redshift and escale), as well as setting the value to use outside the tabulated energy range. The table defines the energy grid the models are defined on, and the models used (one per set of parameters unless the xfxp argument is set).

Parameters:
  • name (str) – The model name (stored in the table). Any spaces are removed.

  • egrid_lo (sequence of float) – The energy grid (in keV) used to define the spectra. It is required that len(egrid_lo) == len(egrid_hi), the arrays are in increasing order, that they are consecutive so that egrid_hi[i] == egrid_lo[i + 1], and that egrid_lo[0] > 0.

  • egrid_hi (sequence of float) – The energy grid (in keV) used to define the spectra. It is required that len(egrid_lo) == len(egrid_hi), the arrays are in increasing order, that they are consecutive so that egrid_hi[i] == egrid_lo[i + 1], and that egrid_lo[0] > 0.

  • params (sequence of Param) – The definitions of the parameters used to interpolate the models. It must have at least one element.

  • spectra (sequence of sequence of float) – The spectra for each set of parameters in paramvals. It is a 2D array of shape(nrows, len(egrid_lo)), and each row matches the corresponding parameter grouping: paramvals[0].values[i], paramvals[1].values[j], .. where the first parameter loops the slowest. The number of rows is the multiplication of the number of parameter values.

  • addparams (sequence of BaseParam or None, optional) – The definitions of the additional parameters; that is those that are not interpolated over.

  • addspectra (sequence of sequence of sequence of float or None, optional) – The spectra for the additional parameters. It must is a 3D array of shape (nrows, len(addparams), len(egrid_lo)).

  • addmodel (bool, optional) – Is this an additive model (True) or a multiplicative one (False). The default is True (additive).

  • redshift (bool, optional) – Should the redshift parameter be added? The default is False.

  • escale (bool, optional) – Should the escale parameter be added? The default is False.

  • lolim (bool, optional) – The value to be used when energies are below or above the values in egrid_lo or egrid_hi respectively.

  • hilim (bool, optional) – The value to be used when energies are below or above the values in egrid_lo or egrid_hi respectively.

  • units (str or None, optional) – The model units. For additive models the default is “photons/cm^2/s” and for multiplicative models it is “”.

  • xfxp (sequence of str or None) – If there are multiple spectra per parameter grid point, these values give the expression to use (the number of elements is the number of spectra per grid point). It is expected this is None or has a length more than 1.

Returns:

hdus – The header and column data needed to create a FITS file.

Return type:

list of TableHDU

Notes

This supports version 1.2.0 of the XSPEC table model specification, although this code should be considered experimental.

It is not designed to be memory efficient, so for models that use a large number of spectra, other tools may make more sense.