up

User Defined Spectral Models

EXSAS is designed to allow a user to include his own spectral models. Up to 20 additive (ua01, tex2html_wrap_inline68 , ua20) and multiplicative (um01, tex2html_wrap_inline68 , um20) user defined models can be added to the spectral analysis package at run time. The code of a user defined model can be written in any language (i.e. FORTRAN, C, etc.) as long as the user takes care of appropriate variable and function call handling and referencing to the EXSAS FORTRAN 77 code. An example of an additive user defined spectral model can be found in

$XEXSAS/spectral/Models/std/ua01.for.

An example of a user defined multiplicative model is given in

$XEXSAS/spectral/Models/abs/um01.for.

In general, a user defined model has to have the same parameter list as given in the following FORTRAN examples:

SUBROUTINE UAXY(E,P,NP,F,IERR)
SUBROUTINE UMXY(E,P,NP,F,IERR)
where tex2html_wrap_inline72

Here, E is the energy variable and P the parameter list of NP model parameters. The output parameters are the photon flux F and an error flag, which can be set to 0, if no important decision has to be made. The variables E, P and F have to be declared as double precision, the remaining two parameters NP and IERR as integer. The unit of the independent variable E is keV and of the dependent variable F is keV tex2html_wrap_inline74 s tex2html_wrap_inline74 cm tex2html_wrap_inline78 .

Before adding one or more user defined spectral models to EXSAS one has to define an environment variable $user_def (for example in your login file) which defines the path to a directory where the source code of your model is stored. Assume you run EXSAS on a UNIX like operating system and you want to include an additive spectral model, something like a modified power-law or so. The model is your first and only user defined spectral model you want to add to EXSAS. Let's call the file with the FORTRAN code of your model ua01.for. Make a subdirectory, for example named my_models using mkdir /home/..../my_models and define the path to it in your .login file by adding the line setenv user_def /home/....../my_models to your login script. Then copy the shell script $XEXSAS/spectral/modespe/modespe.sh to the $user_def directory and make sure that it is executable (chmod u+x modespe.sh). This script file comes with EXSAS and was designed to help you with the inclusion of your model (compilation, linking, copying of library files to $user_def etc).

Assuming now that you are in $user_def and have copied modespe.sh to this directory, executing

modespe.sh ua01

from the UNIX command line will then first copy the EXSAS spectral model library modespe.a and the FORTRAN source code modespe_p.fom of the EXSAS executable modespe.exe to your directory $user_def. Subsequently ua01.for will be compiled to ua01.o and added to the library modespe.a. Finally the EXSAS executable modespe.exe is created by compiling modespe_p.fom and linking it with modespe.a. If there is no error in your model file ua01.for and the script file modespe.sh finished successful the file modespe.exe is created in the directory $user_def.

If you want to include more as one user defined model just give all model names separated by a "," as parameter to modespe.sh, for example like:

modespe.sh ua01, ua02, um01, um02

Note that you have to add all your user defined models in one step since the default EXSAS spectral model library modespe.a is copied from $XEXSAS/lib to $user_def every time you execute prisma.sh so that your old modespe.a file will be over written. This makes sure that you always add your user defined models to the newest and most up-to-date EXSAS library. Access to your user defined model is archived by checking the existence of the file modespe.exe in the directory $user_def. If the file modespe.exe exists in $user_def it will be executed, for example, by model/spectrum. Otherwise EXSAS executes its private copy of modespe.exe which it finds in $XEXSAS/exe.




Author: Werner Becker (e-mail: web@mpe-garching.mpg.de ) / Page last modified: 18-MAY-98