4.1.27. Musr: User defined multiplicative model¶
The user model provides an interface to create an multiplicative model
component calculated by a user program. The interface is rather simple
and therefore very flexible. The interface uses a set of two ASCII
files: input-?-?.prm
and output-?-?.spc
, where the ’?’ stands for the
sector and component number of the musr model component.
The input-?-?.prm
is generated by the musr model and contains the
parameter values and the energy grid that SPEX uses to calculate the
model. The file has a fixed structure:
The first line contains one integer number containing the number of parameters that the model needs to calculate (current maximum is 40).
On the second line the array of parameter values is listed (with the length indicated on the previous line.
On the third line, an integer value is shown which indicates the number of model bins SPEX has in its model grid.
On the following lines, the model grid points are shown in three columns. The first column contains the bin upper boundary (egb), the second column is the bin center (eg) and the third column is the full bin width (deg). The energy values are in keV.
The user program is supposed to read the input file and calculate the
multiplicative factors for each energy bin on the grid. The spectrum
array is called sener
and has the same length as the energy grid. In
addition, it is also possible to calculate the model for the emission
weighted center of the bin. In that case the spectrum calculation is a
bit more complicated, but it leads to better results. The user has the
option of also calculating the weighted spectrum, which is the average
photon energy minus the bin centroid
times the flux (F):
The values end up in the wener
array. If you do not use
weighing by average photon energy, wener
values can be 0.
The user program should create an output ASCII file named output-?-?.spc
with the following structure:
On the first row, put the number of model bins. This should be the same number as written in the
input-?-?.prm
file.Write the
sener
andwener
values in two columns. The first column is thesener
value that represents the multiplication factor and the second column is thewener
value.
In How to use the SPEX user model some example user model programs can be found. The source code can be adapted to accommodate the user’s wishes.
The equivalent of musr
for additive models is User: User defined model.
The parameters of the model are:
exec
: User executable, for example ’./model.py’ for a python
script in the same directory where you run SPEX.npar
: Number of free parameters in the model. Current maximum is
40.p01...p40
: Model parameters of the user model.