How to use the SPEX user model#
Some users would like to add their own models to the SPEX program, similar to the local model option in Xspec. Since the developers of SPEX do not have the man power to implement all possible models out there in a SPEX variety, we have devised a quick way of running external models in SPEX.
SPEX contains three user models user (User: User defined model), musr (Musr: User defined multiplicative model) and cusr
(Cusr: User defined convolution model) for additive, multiplicative, and convolutional models respectively. These model components
communicate with the external model through an input and output file containing the model parameters, the energy
grid and the calculated spectrum. By creating a program that reads in the input parameters and energy grid, calculates
the spectrum, and writes the result to an output file in the right format, users have a very flexible way of using
any model in SPEX.
Since this setup offers many possibilities, we can only show a few examples of how these user model components can be used. We have prepared a helper library for Python and Fortran.
Python#
For Python we have created the User class to handle the reading and writing of SPEX input and
output files. An example script is also available in that section and in python/examples/usermodel.py
in the SPEX source directory.
Fortran#
Using the Fortran module moduser, we list a number of example user models below: