next up previous contents
Next: model (and rmodel) Up: Model Commands Previous: lumin

mdefine: Define a simple model using an arithmetic expression.

 

Syntax:  mdefine  [name [expression [: [type] [emin emax]]]

 

where 'name' = the name of the model.  If "name" is a previously defined model with mdefine, the current definition will overwrite the old one, and the user is warned; if it is a built-in model, however, the user will be asked to use a different name.

'expression' = a string of arithmetic expression. Simple rules for expression:

1) The energy term, must be 'e' or 'E' in the expression.  Other words, which are not numerical constants nor internal functions, are assumed to be model parameters.

2) If a convolution model varies with the location on the spectrum to be convolved, the special variable ".e" or ".E" may be used to refer to the convolution point.

3) The expression may contain spaces for better readability.

'type' = user may optionally specify the type of the model, the valid types are (add, mul, con). (Mix models are not yet implemented as of v12.5.0) Please note that the character ":" must be used to separate the options from the "expression". If "type" is not given default is add.

'emin emax' = user may also specify the  minimum and maximum energy values for the model, the default values are 1.e-20 and 1.e+20, respectively.

 

Note that MDEFINE can also be used to display and delete previously defined models: 

1) To display the name, type and expression of all previously defined models:  

              XSPEC12>mdefine      

2) To display the name, type and expression of a previously defined model by the name, MNAME:

              XSPEC12> mdefine MNAME

3) To delete a previously defined model by the name, MNAME:

              XSPEC12> mdefine  MNAME :

 

Operators:

The following operators are recognized in an expression:

     +   =      plus operator

     -    =      minus operator

     *   =      multiplying  operator

     /    =      dividing  operator

     ** =      exponentiation operator

     ^   =      exponentiation operator

 

Functions:

The following internal functions are supported:

Unary Functions .............................                                                                     

EXP     (expr)       =    exp of a vector expression

SIN      (expr)       =    sine of  vector expression in rad 

SIND   (expr)       =    sine of a vector expression in degree

COS    (expr)       =    cosine of a vector expression in rad 

COSD (expr)       =    cosine of a vector expression in degree

TAN    (expr)       =    tangent of a vector expression in rad 

TAND (expr)       =    tangent of a vector expression in degree

LOG    (expr)       =    base 10 log of a vector expression

LN       (expr)       =    natural log of a vector expression

SQRT  (expr)       =    sqrt of a vector expression

ABS     (expr)       =    absolute value of a vector expression

INT      (expr)       =    integer part of a vector expression

ASIN   (expr)       =    sin^-1 of a vector expression in rad 

ACOS (expr)       =    cos^-1 of a vector expression in rad  

MEAN (expr)       =    mean value of a vector expression

DIM     (expr)       =    dimension of a vector expression

SMIN  (expr)       =    minimum value of a vector expression

SMAX (expr)       =    maximum value of a vector expression

Binary Functions ............................

MAX   (expr1, expr2)    =      maximum of the two vector expressions

MIN    (expr1, expr2)    =      minimum of the two vector expressions

 

 

Examples:

 

XSPEC12> mdef dplaw E**p1 + f*E**p2       ! define a model named "dplaw" with 3 parameters, p1, p2, f  

 

XSPEC12> mdef junk a*e+b*log(e)/sin(e)    ! define a model named "junk" with 2 parameters (a, b)

                                     

XSPEC12> mdef junk2  exp(-a*e) : mul      ! define a model named "junk2" with 1 parameter, a; the option following ":" says that it will be a multiplicative model. 

 

XSPEC12> mdef junk3  0.2+B*e : mul        ! define a model named "junk3" with 1 parameter, B, options following ":" says that this will be a multiplicative model

 

XSPEC12> mdef bb E**2/T**4/(exp(E/T)-1)   ! try to define a blackbody model with name "bb", you get warning:

 

***Warning: bb is a pre-defined model

Please use a different name for your model.

 

XSPEC12> mdef sg  exp(-E^2/(2*A*.E)) / sqrt(6.283*A*sqrt(.E))  :  con

 

                                          ! this defines a Gaussian convolution model with sigma varying with square root of energy.

 

 

XSPEC12> mdef junk2 :                     ! delete junk2

 

XSPEC12> mdef                             ! display all user-defined models

 

-- Name ---- Type ------ Expression -----

dplaw

add

E**p1+f*E**p2

junk

add

a*E+b*LOG(E)/SIN(E)

junk3

mul

a+b*E

sg

con

EXP(-E^2/(2*A*.E))/SQRT(6.283*A*SQRT(.E))

-----------------------------------------

 


 

next up previous contents
Next: model (and rmodel) Up: Model Commands Previous: lumin