Module-Level Functions
- xspec.callModelFunction(modelName, energies, params, flux, fluxError=None, spectrumNum=None, initString=None)
Directly call an XSPEC model function.
This provides an interface for directly accessing the functions in the XSPEC models library. Note that this utility does NOT create PyXspec Model objects for fitting to spectra. Nor does it interact with any other PyXspec objects and settings. (For that you would use the Model class and/or the AllModels container.) This merely takes input arrays of energy and parameter values and calls on the requested model function to calculate a flux array.
- Args:
modelName: Name of model component to perform the calculation. [string]
The full name must be given here (as it appears in Model.showList()). Abbreviations are not handled.
energies: Input array of energy bin values. [list or tuple]
params: Input array of parameter values. [list or tuple]
The size of this array must match the number of parameters required by the model function, otherwise an error is thrown.
flux: Input/output array of calculated flux. [list]
This list should normally be size 0 upon input. It will be resized to nEnergies-1 and filled with the calculated flux values upon output.
However if calling a model function that requires a pre-filled flux array (such as a convolution component), it should be filled to size nEngeries-1 upon input.
- fluxError: Optional input/output array for model functions which
also calculate errors. [list]
This should normally be set to the default = None. But if used, it follows the same size requirements as the flux array.
spectrumNum: Optional spectrum number value. [int]
This is generally not required in this context and should be left to the default = None. It exists as part of the model function interface for internal XSPEC usage (particularly mix model components).
- initString: Optional input string for model functions which may
take additional initialization information. [string]
Generally not required in this context. Defaults to None.
Examples:
# Create an energy array of 5 bins, each bin centered on 1-5 keV, # and pass to XSPEC's powerlaw model function to calculate the flux. # The powerlaw model requires 1 parameter, the photon index. engs = (.5, 1.5, 2.5, 3.5, 4.5, 5.5) # can be a tuple or list pars = [2.0] # tuple or list flux = [] # must be a list callModelFunction('powerlaw', engs, pars, flux) # flux array will now be size 5 with the calculated values
- xspec.callTableModel(tableType, tableFile, energies, params, flux, fluxError=None, spectrumNum=None, initString=None)
Directly call an XSPEC table model.
This provides an interface for directly accessing XSPEC table models. Note that this utility does NOT create PyXspec Model objects for fitting to spectra. Nor does it interact with any other PyXspec objects and settings. (For that you would use the Model class with an expression containing table model syntax, ie. atable{<filename>}) This merely takes input arrays of energy and parameter values and interpolates a flux array from the requested table model file.
- Args:
- tableType: Allowed table types are 'a', 'm', or 'e' for
additive, multiplicative, and exponential table models respectively.
tableFile: Name of the table model file. [string]
energies: Input array of energy bin values. [list or tuple]
params: Input array of table parameter values. [list or tuple]
flux: Input/output array of calculated flux. [list]
This list should normally be size 0 upon input. It will be resized to nEnergies-1 and filled with the calculated flux values upon output.
- fluxError: Optional input/output array for model functions which
also calculate errors. [list]
This should normally be set to the default = None. But if used, it follows the same size requirements as the flux array.
spectrumNum: Optional spectrum number value. [int]
This is generally not required in this context and should be left to the default = None. It exists as part of the model function interface for internal XSPEC usage (particularly mix model components).
- initString: Optional input string for model functions which may
take additional initialization information. [string]
Generally not required in this context. Defaults to None.
Examples:
# Create an energy array of 5 bins, each bin centered on 1-5 keV, # and pass to a powerlaw table model file named testpo.mod to # calculate the flux. The table model requires 1 parameter, the # photon index. engs = (.5, 1.5, 2.5, 3.5, 4.5, 5.5) # can be a tuple or list pars = [2.0] # tuple or list flux = [] # must be a list callTableModel('a','testpo.mod', engs, pars, flux) # flux array will now be size 5 with the calculated values