An excellent introduction to the concept of fitting X-ray spectra can be found in one of Keith Arnaud's PowerPoint presentations.
set spectrum_filename "104357.47-593251.3.pi"
).
set extra_spectrum_filename "104357.47-593251.3_grp5.0.pi"
or C-statistic.
set ignore_spec "1-34,549-**"
set extra_ignore_spec "1,98"
set model_name "nogrp_tbabs_vapec"
set c_stat_flag 1
or the C-statistic.
set spectrum_description "NET_CNTS=150-10.7"
set bkg_ignore_spec "1-7,686-**"
set cplinear_energies {0.5 1.0 1.5 2.0 3.0 4.0 5.0 6.0 7.0 8.0}
set model_directory "/users/research/patb/TARA/code/ae/xspec_scripts"
set interactive_flag 0
When the
statistic is used, AE will skip any source which has
groups (
``noticed'' groups) in its spectrum. Most fitting scripts will of course require more groups than that to function; it's the responsibility of the script to check that the number of noticed groups is adequate before attempting the fit.
Fitting scripts should assume that the multi-ObsId background spectrum, ARF, and RMF are listed in the standard FITS keywords BACKFILE, ANCRFILE and RESPFILE in the source spectrum.
EXAMPLE:
idl
tee fit_spectra.log
acis_extract, 'all.srclist', /FIT_SPECTRA, CHANNEL_RANGE=[35,548], MODEL_FILENAME='~/my_models/tbabs_vapec.xcm'
EXAMPLE:
idl
tee fit_spectra.log
acis_extract, 'all.srclist', /FIT_SPECTRA, CHANNEL_RANGE=[35,548], MODEL_FILENAME='~/my_models/tbabs_vapec.xcm', MODEL_CHANGES_FILENAME='~/my_models/NH_frozen.xcm', /CSTAT
EXAMPLE:
idl
tee fit_spectra.log
acis_extract, 'all.srclist', /FIT_SPECTRA, CHANNEL_RANGE=[35,548], MODEL_FILENAME='~/my_models/tbabs_vapec.xcm', /CSTAT, SNR_RANGE=[1,5], NUM_GROUPS_RANGE=[6,250]
This is provided for observers who prefer the traditional approach to grouping in which a threshold number of source counts is required for each group.
# AE CUSTOMIZATIONSafter the script has set up the spectral model. (The scripts distributed with AE support this.) AE inserts after this line the contents of the file MODEL_CHANGES_FILENAME which should contain an XSPEC script fragment that changes the default behavior of the fitting script as desired. For example, the inserted script fragment could contain XSPEC commands to freeze a parameter, or to change an abundance.
WARNING! It is very easy to introduce typograpical mistakes into the model-changes script that silently defeat the intended changes to fitting script variables that you intend, expecially since variable names in the TCL language are case-sensitive. We strongly recommend that model-changes scripts should verify that a variable name exists before trying to change its value. The example model-changes script below first makes a table of (name, value) pairs for the script variables you wish to update, then runs a little block of TCL code that verifies that the specified variable names already exist in the fitting script:
set custom_value(kT0) 2.0
set custom_value(NH0) 1.0
foreach variable_name [array names custom_value] {
if [info exists $variable_name] {
set $variable_name $custom_value($variable_name)
} else {
puts "ERROR: '$variable_name' is not the name of a variable in the fitting script!"
tclexit 98
}
}
To freeze a parameter, set its initial value and parameter range to the same value, for example:
set custom_value(kT0_min) 15.0
set custom_value(kT0) 15.0
set custom_value(kT0_max) 15.0
foreach variable_name [array names custom_value] {
if [info exists $variable_name] {
set $variable_name $custom_value($variable_name)
} else {
puts "ERROR: '$variable_name' is not the name of a variable in the fitting script!"
tclexit 98
}
}
AE looks in two places for the specified MODEL_CHANGES_FILENAME. For example suppose
MODEL_FILENAME='~/my_models/tbabs_vapec.xcm' and
MODEL_CHANGES_FILENAME='~/my_models/NH_frozen.xcm'
AE first looks for a file named tbabs_vapec_NH_frozen.xcm in the source directory. If that is not found then AE looks for a file at the exact path supplied, '~/my_models/NH_frozen.xcm'. In this way you can use a single XSPEC script fragment to modify all source fits in the same way, and/or you can modify individual source fits independently, e.g. specifying a different frozen
value for each source.
If an XSPEC script fragment is found its basename is appended to the model_name used in the various fitting files and in the HDU that stores the fit results, e.g. grp5.0_tbabs_vapec_NH_frozen.
If you wish to apply multiple customization scripts then MODEL_CHANGES_FILENAME should be an array of file names.
The AE package contains compiled versions of this model for several platforms. If the AE scripts cannot load this model you may need to compile it for your platform as shown below. Note the use of back-quotation marks around the uname shell commands.
% cd <AE package>/xspec_scripts % xspec XSPEC12> initpackage acis_extract model.dat ./ XSPEC12> quit % setenv DIR `uname -s`_`uname -p` % mkdir $DIR % mv libacis_extract.* $DIR
To use this feature, the observer must configure their XSPEC environment to access a small TCL program interact.tcl distributed with AE:
% cd ~/.xspec % cp <AE package>/xspec_scripts/interact.tcl . % xspec XSPEC12> auto_mkindex . XSPEC12> exit
AE's fitting scripts include a placeholder for loading a frozen observer-supplied model for background components that are not represented by the background observation that has been extracted. For example, when the ACIS ``stowed'' observations are extracted as the background spectrum for a diffuse source, then the observer will want to supply a model for the celestial background components (which are not present in the stowed data). You should ponder whether it is more appropriate for this celestial background model to be frozen or free:
If the log file is no help, then your next debugging step should be to repeat the XSPEC run manually in a shell in order to reproduce the failure outside the context of AE. Although the unix command line that AE spawns to run XSPEC (shown in the IDL window) is complex at first glance, the heart of it is simply the normal syntax required to have XSPEC run a TCL script, for example:
xspec - spectral_models/grp3.0_tbabs_pow.xcm
Although you can manually run the fitting script in that manner (supplying it as a parameter to XSPEC on the command line), you will often find that XSPEC will exit immediately after the problem is encountered, preventing you from exploring the state of the model, looking at the fit, etc.
Thus, it is often better to start XSPEC and then load the script, for example:
xspec
@spectral_models/grp2.0_tbabs_pow.xcm
If the fitting script is running normally, but the spectral model parameters are running ``off into the weeds'', then you should first suspect that the problem is arising during execution of the ``error'' command. When a model parameter is poorly constrained, the ``error'' command can explore astrophysically extreme realms of parameter space while searching for a rise in the fit statistic commensurate with the specified uncertainty. Sometimes, a second and slightly better local maximum will be found during that search and will be adopted as the new best fit, even if its model parameters are astrophysically extreme (e.g. very high NH and very low kT in a thermal plasma). The best-fit XSPEC model that existed before estimation of parameter errors is saved in the file model_before_errors.xcm (see below). Estimation of parameter errors can be disabled by setting the skip_errors variable in the AE fitting script, a task most easily accomplished via the MODEL_CHANGES_FILENAME mechanism.