Dealing with background in XSPEC


When the background requires a different response to the source

Suppose we have a model for the background spectrum which requires a different response to that for the source spectrum. Read in the source and background spectra as separate files :

XSPEC12>data 1:1 source.pha 2:2 back.pha

We set the response for the source :

XSPEC12>response 1 source.rsp

Now we tell xspec that both these datasets will have a second model which must be multiplied by the back.rsp response matrix.

XSPEC12>response 2:1 back.rsp 2:2 back.rsp

Set up the model for the source. Here we will take the simple case of an absorbed power-law :

XSPEC12>model phabs(pow)

Input parameter value, delta, min, bot, top, and max values for ...
              1      0.001          0          0     100000      1e+06
1:data group 1::phabs:nH>
              1       0.01         -3         -2          9         10
2:data group 1::powerlaw:PhoIndex>
              1       0.01          0          0      1e+24      1e+24
3:data group 1::powerlaw:norm>

Now we need to set up the background model for both datasets. In this case take the simple example of a single power-law

XSPEC12>model 2:myback pow

Input parameter value, delta, min, bot, top, and max values for ...
              1       0.01         -3         -2          9         10
1:myback:data group 1::powerlaw:PhoIndex>
              1       0.01          0          0      1e+24      1e+24
2:myback:data group 1::powerlaw:norm>

Input parameter value, delta, min, bot, top, and max values for ...
              1       0.01         -3         -2          9         10
3:myback:data group 2::powerlaw:PhoIndex>
              1       0.01          0          0      1e+24      1e+24
4:myback:data group 2::powerlaw:norm>

We have now set up xspec so that the source data is modeled by a source model multiplied by the source response plus a background model multiplied by the background response and the background data is modeled by the background model multiplied by the background response. The background models fitted to the source and background data are constrained to be the same.

XSPEC12>show model

Current model list:

Model phabs<1>*powerlaw<2> Source No.: 1   Active/On
      For Data Group(s): 1 

Model myback:powerlaw<1> Source No.: 2   Active/On
      For Data Group(s): 1 2 

   Using energies from responses.

XSPEC12> show par

Parameters defined:
========================================================================
Model phabs<1>*powerlaw<2> Source No.: 1   Active/On
Model Model Component  Parameter  Unit     Value
 par  comp
                           Data group: 1
   1    1   phabs      nH         10^22    1.00000      +/-  0.0          
   2    2   powerlaw   PhoIndex            1.00000      +/-  0.0          
   3    2   powerlaw   norm                1.00000      +/-  0.0          
________________________________________________________________________

========================================================================
Model myback:powerlaw<1> Source No.: 2   Active/On
Model Model Component  Parameter  Unit     Value
 par  comp
                           Data group: 1
   1    1   powerlaw   PhoIndex            1.00000      +/-  0.0          
   2    1   powerlaw   norm                1.00000      +/-  0.0          
                           Data group: 2
   3    1   powerlaw   PhoIndex            1.00000      = myback:1
   4    1   powerlaw   norm                1.00000      = myback:2
________________________________________________________________________

Including particle background

A particular case of background requiring a different response is particle background. This is assumed to depend on the instrumental response but not on the telescope effective areas. In xspec v11 and earlier a particle background model could be included by appending /b to additive components at the end of the model definition. These components were multiplied by the response file but not the arf. To do the equivalent in the current version of xspec suppose that our source.rsp in the example above can be split into source.rmf, the instrument response, and source.arf, the telescope effective area. To read the data in this case we do the following :

XSPEC12>data 1:1 source.pha 2:2 back.pha
XSPEC12>response 1 source.rmf
XSPEC12>arf 1 source.arf
XSPEC12>response 2:1 source.rmf 2:2 source.rmf

We can then define the source and background models in the same way as the previous example.

If separate rmf and arf files are not available then the v11 behavior can be replicated by using the script split_rsp_to_rmf_arf to split the response into a unit-normalized matrix and an effective area vector. If the response matrix is source.rsp then running

split_rsp_to_rmf_arf source

will generate the source.rmf and source.arf files required.

Simulating a spectrum with particle background

Suppose we don't yet have a background spectrum but want to simulate a dataset which includes the particle background. We need a spectrum file - it doesn't matter what is in it - and the rmf and arf files.

XSPEC12>data test.pha
XSPEC12>response source.rmf
XSPEC12>arf source.arf
XSPEC12>response 2:1 source.rmf

Now define the source and background models and run fakeit eg :

XSPEC12>model phabs(pow)

Input parameter value, delta, min, bot, top, and max values for ...
              1      0.001          0          0     100000      1e+06
1:phabs:nH>
              1       0.01         -3         -2          9         10
2:powerlaw:PhoIndex>
              1       0.01          0          0      1e+24      1e+24
3:powerlaw:norm>

XSPEC12>model 2:myback pow

Input parameter value, delta, min, bot, top, and max values for ...
              1       0.01         -3         -2          9         10
1:myback:powerlaw:PhoIndex>
              1       0.01          0          0      1e+24      1e+24
2:myback:powerlaw:norm>

XSPEC12>fakeit

background (last edited 2013-08-05 21:01:56 by KeithArnaud)