Theoretical Model Implementation
Redesign Home Problem Fitting Plotting Data Modeling CCfits

Making Models: The "models" which describe sources (additive models) and modifiers (multiplicative, convolution, etc) are represented by Component objects with subtypes AddComponent, MulComponent, ConComponent, MixComponent etc. These differ by implementing the notion of "calculating" differently. The class Model represents a sum of one or more ComponentGroup objects, which in turn consists of one or more Component objects together with an expression that retains how they are to be combined. The Composite implementation allows the calculation/combination procedure to proceed recursively by combining [i.e. calculating, then multiplying, convolving, mixing, etc expressions such as

phabs(powerlaw + gaussian)]

ComponentGroups into single Component type objects that are then summed for the model. As a result, XSPEC12 can compute more complex expressions and is also able to express model calculation by abstract high level code, which is a definite advantage for future developers. The cost is a little overhead to the job of calculating models.

Language Support: XSPEC12 explicitly supports model flux calculation functions in fortran77, double precision fortran77, C, and C++ (and can be extended easily to other languages if that were ever desirable). Individual model functions are stored as function pointers in a dynamic associative array. As a consequence, the set of models available to the user can be augmented at runtime.

Local Models: Apart from allowing code in new languages, there are two new commands that allow models to be developed from within XSPEC12 itself. One command (initpackage) takes user code and model initialization file (lmodel.dat) and creates and compiles a shared library from the XSPEC prompt. The other (localmodel) loads those models. A third minor enhancement to the program gives the user the ability to plot a model on a user specified energy array (i.e. without first reading  any data). Thus models can be developed iteratively within XSPEC12 by successively editing the code, reinitializing the new model and plotting its appearance.

Parameter Types: Three parameter types are now provided, ModParam, ScaleParam, and SwitchParam. The first is the traditional XSPEC model fitting parameter, while the latter two are non-fitting scaling factors and switches that can switch the mode of the model. Using the latter two types is an optional convenience, obviating the need to freeze parameters that should not be varied.

Enhanced Parameter Linking: A parameter can now be linked to a polynomial expression in all of the model parameters (as opposed to being a linear relation between one parameter and another). This is achieved by a Singleton master list of all links between parameters, where a "link" consists of a list of parameters and an expression. The expression parser, NumericExpression,  is actually a subclass type of the Expression class used to parse model expressions (it implements all four arithmetic operators rather than just add and multiply). This is another example of code reuse within the program. There are obvious extensions to allowing algebraic and transcendental expressions in parameter links by subclassing the parser further.

[Redesign Home]
[Design]
[Problem]
[Scripting]
[Compatibility]

Xspec Xspec Home Page


HEASARC Home | Observatories | Archive | Calibration | Software | Tools | Students/Teachers/Public

Last modified: Wednesday, 02-Mar-2011 11:29:07 EST