FunctionUtility

The FunctionUtility class stores information used by XSPEC models. There is a single instantiation. The private elements of FunctionUtility are all static and are as follows:

string s_XSECT Photoelectric cross-sections used
string s_ABUND Relative abundances used
const string CROSSSECTFILE File read for cross-sections
string s_abundanceFile File read for relative abundances
vector$<$string$>$ s_elements Names of elements
string s_managerPath Directory path for model.dat
const size_t s_NELEMS Number of elements
string s_modelDataPath Directory path for files required by models
string s_NOT_A_KEY String returned if an xset variable is not set
FunctionUtility::Cosmology s_COSMO Cosmology used
string s_abundPath Directory path for the abundance file
string s_atomdbVersion version of AtomDB used
string s_neiVersion version of NEI code used
bool s_abundChanged Relative abundance choice has been changed
int s_xwriteChatter Chatter value
vector$<$double$>$ s_tempsDEM Last CEI model temperatures calculated
vector$<$double$>$ s_DEM Last CEI model DEMs calculated
map$<$int, map$<$string, Real$>$ $>$ s_XFLT XLT#### keyword values
map$<$string,double$>$ s_valueDataBase Database of values calculated in model functions
     
map$<$string,vector$<$ float $>$ $>$ s_abundanceVectors Stores sets of abundances
map$<$string,string$>$ s_crossSections descriptions of cross-sections available
map$<$string,string$>$ s_abundDoc descriptions of relative abundance sets
abundance sets    
map$<$string,string$>$ s_modelStringDataBase Keywords and values defined by the xset command

These elements can be accessed using either C++ or C/Fortran routines as follows. The following tables list the method name, the C/Fortran wrapper (where available) and a brief description. To see the calling sequences look in FunctionUtility.h, xsFortran.cxx, and xsCFortran.c for the C++, C and Fortran interfaces, respectively.

Any program which uses the XSPEC function library needs to call FNINIT() to initialize the FunctionUtility object. The managerPath is the directory which contains the model.dat file as well as information about the cross-sections and abundance tables available. Usually, it does not have to be changed from the default (Xspec/src/manager). The modelDataPath is the directory containing files used as input by models.

FNINIT FNINIT standard initialization
managerPath FGDATD get s_managerPath
managerPath FPDATD set s_managerPath
modelDataPath FGMODF get s_modelDataPath
modelDataPath   set s_modelDataPath
NOT_A_KEY   get s_NOT_A_KEY

XSPEC has several options for photo-electric cross-sections and relative abundances. A user-defined set of relative abundances can also be read from a file.

XSECT FGXSCT get s_XSECT
XSECT FPXSCT set s_XSECT
checkXsect   check for valid cross-section table
crossSections   get description of cross-section table
ABUND FGSOLR get s_ABUND
ABUND FPSOLR set s_ABUND
getAbundance FGABND get relative abundance for an element
getAbundance FGABNZ get relative abundance for an atomic number
getAbundance FGTABN get relative abundance for an element from a table
getAbundance FGTABZ get relative abundance for an atomic number from a table
readNewAbundances RFLABD read relative abundances from a file
checkAbund   check for valid relative abundance table
abundanceVectors FPSLFL set the values of the file relative abundance table
abundDoc   get description of relative abundance table
abundanceFile FGABFL get the name of the file used for abundances
abundanceFile FPABFL set the name of the file used for abundances
abundPath FGAPTH get the directory path for the file used for abundances
abundPath FPAPTH set the directory path for the file used for abundances
abundChanged   get value of s_abundChanged flag
abundChanged   set value of s_abundChanged flag
readInitializers   set up cross-sections and relative abundances
elements FGELTI get name of element
NELEMS() FGNELT get number of elements

The AtomDB and NEI versions used can be set or retrieved

atomdbVersion FGATDV get AtomDB version in use
atomdbVersion FPATDV set AtomDB version in use
neiVersion   get NEI version in use
neiVersion   set NEI version in use

The (keyword, value) pairs defined using the xset command can be found using getModelString.

getModelString FGMSTR get entry from the model string database
setModelString FPMSTR set entry in the model string database
modelStringDataBase   get database as a map<string,string>
eraseModelStringDataBase   clear the model string database

XSPEC uses a cosmological model based on values of H$_0$, q$_0$, and $\lambda_0$ to calculate distances from redshifts. A routine to calculate the luminosity distance is included in Numerics with a C/Fortran wrapper in xsFortran.

setFunctionCosmoParams CSMPALL set the cosmology H$_0$, q$_0$, and $\lambda_0$
getq0 csmgq0 get cosmology q$_0$
setq0 csmpq0 set cosmology q$_0$
getH0 csmgh0 get cosmology H$_0$
setH0 csmph0 set cosmology H$_0$
getlambda0 csmgl0 get cosmology $\lambda_0$
setlambda0 csmpl0 set cosmology $\lambda_0$

XSPEC models have access to the values given by the keywords XFLT#### read from the SPECTRUM extension of the input file. These are stored internally as (key, value) pairs where the XFLT#### keywords are strings “key: value”.

getNumberXFLT DGNFLT get number of XFLT#### keywords for spectrum
getXFLT DGFILT get value of XFLT#### keyword for spectrum
inXFLT DGQFLT check whether XFLT#### keyword exists for spectrum
loadXFLT DPFILT set XFLT value(s) for spectrum
clearXFLT DCLFLT clear all XFLT values
getAllXFLT   get all XFLT values for spectrum

The calcMultiTempPlasma routine which underlies many of the collisional plasma models automatically saves its input temperatures and differential emission measures. This is used for the plot dem option but may have other uses.

tempsDEM   get the vector of temperatures
tempsDEM   set from a vector of temperatures
tempsDEM   set from a RealArray of temperatures
DEM   get the vector of DEMs
DEM   set from a vector of DEMs
DEM   set from a RealArray of DEMs

There is an internal database to which any model can add a (keyword,value) pair. This is useful for saving information during the calculation of the model which the user may need.

getDbValue GDBVAL get value for given keyword in internal database
loadDbValue PDBVAL set (keyword,value) pair in internal database
clearDb CDBASE clear all (keyword,value) pairs in internal database
getDbKeywords   get all keywords in internal database as a string
getAllDbValues   get all keywords in internal database as a map

The chattiness level set by the chatter command can be accessed from within in a model and strings can be output at the required level

xwriteChatter FGCHAT get current chatter level
xwriteChatter FPCHAT set current chatter level
xsWrite XWRITE write an output string

Usually table models are used in xspec through the atable or mtable model options but it also possible to write a model which reads a table and performs additional operations. There are two versions of tableInterpolate depending on whether additional xflt information. There is a C wrapper tabintxflt for the version which uses additional xflt information however it is not available from Fortran.

tableInterpolate TABINT get tabulated value


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

Last modified: Wednesday, 23-Mar-2022 17:16:48 EDT

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

Last modified: 23-Mar-2022