make_xstable_model

sherpa.astro.io.xstable.make_xstable_model(name: str, egrid_lo: ndarray, egrid_hi: ndarray, params: list[Param], spectra: list[ndarray], addparams: list[BaseParam] | None = None, addspectra: list[list[ndarray]] | None = None, addmodel: bool = True, redshift: bool = False, escale: bool = False, lolim: float = 0, hilim: float = 0, units: str | None = None, xfxp: Sequence[str] | None = None) BlockList[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:
namestr

The model name (stored in the table). Any spaces are removed.

egrid_lo, egrid_hisequence 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.

paramssequence of Param

The definitions of the parameters used to interpolate the models. It must have at least one element.

spectrasequence 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.

addparamssequence of BaseParam or None, optional

The definitions of the additional parameters; that is those that are not interpolated over.

addspectrasequence 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)).

addmodelbool, optional

Is this an additive model (True) or a multiplicative one (False). The default is True (additive).

redshiftbool, optional

Should the redshift parameter be added? The default is False.

escalebool, optional

Should the escale parameter be added? The default is False.

lolim, hilimbool, optional

The value to be used when energies are below or above the values in egrid_lo or egrid_hi respectively.

unitsstr or None, optional

The model units. For additive models the default is “photons/cm^2/s” and for multiplicative models it is “”.

xfxpsequence 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:
hdusBlockList

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

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.