2.8. 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 two user models user
(User: User defined model) and musr
(Musr: User defined multiplicative model) for additive and
multiplicative 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.
2.8.1. Python¶
The Python helper library for the user model is part of the pyspextools package. A general example of how to user the Python interface to the user model can be found here.
As a more specific example we also provide a method to calculate APEC models and import them to SPEX using the Python interface.
2.8.2. Fortran¶
Using the Fortran module moduser, we list a number of example user models below: