Xspec Tutorial
Xspec Tutorial
Xspec Tutorial
1
0.5
2103
normalized counts s1 chan1
0.1
5104
0.05
200 400 600 800 1000 1200 0.5 1 data 2 5
Channel Energy (keV)
1
xspec> setplot rebin 10 30
0.5
normalized counts s1 keV1
0.2
minimum significance max number of bins
0.1
0.5 1 2 5
Energy (keV)
Syntax:
M1*M2*(A1+A2+M3*A3)
xspec> nh
parameter
number
of
number
the
component
data and folded model
1
xspec> fit 100 model
0.5
normalized counts s1 keV1
0.2
Bad fit
0.1
High chi2/dof
0.05
0.5 1 2 5
Energy (keV)
1
normalized counts s1 keV1
0.01
0.5
103
0.1
104
0.05
105
0
n 2
(Ok Ek)
=
2
2
k=1
k
S = (Si Bi t s /t b mi t s ) /(( ) + ( ) )
2 2
S i
2
B i
i OK EK K
where Si = src counts in the I={1,,N} data bins with exposure tS,
Bi = background counts with exposure tB and mi = model predicted
count rate; (S)2 and (B)2 = variance on the src and background
counts, typically estimated by Si and Bi
BUT
the 2 statistic fails in low-counting regime
(few counts in each data bin)
Alternative solutions in case of low photon statistics
i. To rebin the data so that each bin contains a large enough number of
counts
Calculate
Model
Compare to
data
14
Global vs. local minimum
If the fit process is started at the right place, then it will converge to the true
minimum
The more complicated the model and the more highly correlated the parameters,
then the more likely that the algorithm will hardly find the true minimum
Avni76
These are
NOT the
errors
Integre Technical Publishing Co., Inc. Moore/McCabe November 16, 2007 1:29 p.m. moore page T-20
Ex.1: Error at 90% confidence level
for one parameter of interest:
xspec> error #param 2.71
T-20 Tables
Ex. 2: Error at 90% confidence level
for two parameters of interest:
xspec> error #param 4.61
TABLE F
2 distribution critical values
Tail probability p
df .25 .20 .15 .10 .05 .025 .02 .01 .005 .0025 .001 .0005
Parameter of interest 1 1.32 1.64 2.07 2.71 3.84 5.02 5.41 6.63 7.88 9.14 10.83 12.12
2 2.77 3.22 3.79 4.61 5.99 7.38 7.82 9.21 10.60 11.98 13.82 15.20
3 4.11 4.64 5.32 6.25 7.81 9.35 9.84 11.34 12.84 14.32 16.27 17.73
4 5.39 5.99 6.74 7.78 9.49 11.14 11.67 13.28 14.86 16.42 18.47 20.00
5 6.63 7.29 8.12 9.24 11.07 12.83 13.39 15.09 16.75 18.39 20.51 22.11
6 7.84 8.56 9.45 10.64 12.59 14.45 15.03 16.81 18.55 20.25 22.46 24.10
7 9.04 9.80 10.75 12.02 14.07 16.01 16.62 18.48 20.28 22.04 24.32 26.02
8 10.22 11.03 12.03 13.36 15.51 17.53 18.17 20.09 21.95 23.77 26.12 27.87
9 11.39 12.24 13.29 14.68 16.92 19.02 19.68 21.67 23.59 25.46 27.88 29.67
10 12.55 13.44 14.53 15.99 18.31 20.48 21.16 23.21 25.19 27.11 29.59 18
31.42
Step 5a: contour plots
xspec> steppar par1 min_value max_value #steps par2 min max #steps
Perform a fit while stepping the value of a parameter through a given range
99%
90%
0.48
Parameter: nH (1022 cm2)
68%
+
0.46
0.44
90% c.l.: the photon index varies in the range 1.581.62 (vs. 1.581.61 using the error command).
Slight differences are explained because in the case of the error command, the uncertainty was
computed for one parameter of interest.
Step 6: source flux and luminosity
xspec> flux 2 10 (flux band in keV)
xspec> lum 2 10 0.048 (lum band redshift)
Flux is observed (no correction for absorption) and in the observed-frame band
Luminosity needs to be intrinsic (so, put NH = 0) and is reported in the source rest frame
Step 7: the F-test
Model 1: absorbed powerlaw
Model 2: absorbed powerlaw + iron emission line
xspec> addcomp 3 zgauss
xspec> fit 100
2/dof=33.5/2
2/dof=1253.3/1294
vs. 1286.8/1296 (no line)
xspec> ftest chi2_mod2 dof_mod2 chi2_mod1 dof_mod1
Low F value: low statistical significance of the added component
Use the F-test to evaluate the improvement to a spectral fit due to the
assumption of a different model, with additional terms
Conditions: (a) the simpler model is nested within the more complex model;
(b) the extra parameters have Gaussian distribution (not truncated by the
parameter space boundaries) BUT see also Protassov+02 on caveats
2
1 / 1 2 The larger this ratio is,
Pf ( f ;1, 2 ) = 2 / k the larger the improvement
2 / 2 is in the spectral fitting
k=number of additional
parameters
Other useful commands
in XSPEC
> setplot rebin #1 #2 (to rebin the data; #1 indicates the number of )
> show all
> show files
> show notice
> save all bestfit.xcm (save the best fit model with the data)
> save model bestmodel.xcm (save only the best fit model, without the data)
in PLOT
> time off
> csize 2 (character size)
> msize (marker size)
> label top (title of the plot)
> label filename (title of the file)
> hardcopy nomefile.ps/cps (save a figure)
> plot
> wen nomefile (writes two files, one with data and the other with plot settings)
Step 7: the F-test
Model 1: pow
Model 2: pow+line
Use the F-test to evaluate the improvement to a spectral fit due to the
assumption of a different model, with additional terms
Conditions: (a) the simpler model is nested within the more complex model;
(b) the extra parameters have Gaussian distribution (not truncated by the
parameter space boundaries)
2
1 / 1 2 The larger this ratio is,
Pf ( f ;1, 2 ) = 2 / k the larger the improvement
2 / 2 is in the spectral fitting
k=number of additional
parameters