skip to content
 
XMM-Newton Guest Observer Facility

THE XMM-NEWTON ABC GUIDE, STREAMLINED

Fit an RGS Spectrum with Xspec (via Hera)


Contents


Approaches to Spectral Fitting and the Cash Statistic (cstat)
Rebinning the Spectrum
Fitting a Model

While various ftools and Xspec can be run from the Hera Parameter Window, it is easier to do it from the Command Window, so we will demonstrate that here.

Before we get to fitting the spectrum, a few words are in order about different approaches to take. We will use for our example the RGS spectrum of Mkn 421 (ObsID 0153950701) that we reprocessed elsewhere, and assume that we have already logged into Hera.

Approaches to Spectral Fitting and the Cash Statistic (cstat)

For data sets of high signal-to-noise and low background, where counting statistics are within the Gaussian regime, the data products above are suitable for analysis using the default fitting scheme in Xspec, χ2-minimization. However, for low count rates, in the Poisson regime, χ2-minimization is no longer suitable. With low count rates in individual channels, the error per channel can dominate over the count rate. Since channels are weighted by the inverse-square of the errors during χ2 model fitting, channels with the lowest count rates are given overly-large weights in the Poisson regime. Spectral continua are consequently often fit incorrectly, with the model lying underneath the true continuum level. This will be a common problem with most RGS sources. Even if count rates are large, much of the flux from these sources can be contained within emission lines, rather than the continuum. Consequently, even obtaining correct equivalent widths for such sources is non-trivial.

The traditional way to increase the signal-to-noise of a data set is to rebin or group the channels, since, if channels are grouped in sufficiently large numbers, the combined signal-to-noise of the groups will jump into the Gaussian regime. However, this results in the loss of information. For example, sharp features like an absorption edge or emission line can be completely washed out. Further, in the Poisson regime, the background spectrum cannot simply be subtracted, as is commonly done in the Gaussian regime, since this could result in negative counts. Therefore, rebinning should be reserved for fast, preliminary analysis of spectra without sharp features, or for making plots for publication. When working on the final analysis for a low-count data set, the (unbinned) background and source spectra should be fitted simultaneously using the Cash statistic. (If fitting with XSPEC, be sure you are running v11.1.0 or later. This is because RGS spectrum files have prompted a slight modification to the OGIP standard, since the RGS spatial extraction mask has a spatial-width which is a varying function of wavelength. Thus, it has become necessary to characterize the BACKSCL and AREASCL parameters as vectors (i.e., one number for each wavelength channel), rather than scalar keywords as they are for data from the EPIC cameras and past missions. These quantities map the size of the source extraction region to the size of the background extraction region and are essential for accurate fits. Only Xspec v11.1.0, or later versions, are capable of reading these vectors, so be certain that you have an up-to-date installation at your site.)

Finally, a caveat of using the Cash statistic in Xspec is that the scheme requires a "total" and "background" spectrum to be loaded into Xspec. This is in order to calculate parameter errors correctly. Consequently, be sure not to use the "net" spectra that were created as part of product packages by SAS v5.2 or earlier. To change schemes in Xspec before fitting the data, type in the Command Window:

   XSPEC>  statistic cstat
For our purposes, a quick, preliminary fit of the spectrum is sufficient, so we will rebin and use χ2 statistics.

Rebinning the Spectrum

There are two ways to rebin a spectrum: the FTOOL grppha, or the RGS pipeline. grppha can group channels using an algorithm which bins up consecutive channels until a count rate threshold is reached. This method conserves the resolution in emission lines above the threshold while improving statistics in the continuum. However, while channel errors are propagated through the binning process correctly, the errors column in the original spectrum product is not strictly accurate. The problem arises because there is no good way to treat the errors within channels containing no counts. To allow statistical fitting, these channels are arbitrarily given an error value of unity, which is subsequently propagated through the binning. Consequently, the errors are overestimated in the resulting spectra.

To rebin the spectrum with grppha, navigate to your working directory with the spectra in it, then enter in the Command Window:

   grppha 
and edit the parameters as needed:
   >Please enter PHA filename[] P0153950701R1S001SRSPEC1001.FIT
   >Please enter output filename[] P0153950701R1S001SRSPEC1001.bin30.FIT
   >GRPPHA[] group min 30 
   >GRPPHA[] exit

The other approach, which involves calling the RGS pipeline after it is complete, bins the data during spectral extraction. The following rebins the pipeline spectrum by a factor 3:

   rgsproc rebin=3 rmfbins=5000 entrystage=4:spectra finalstage=5:fluxing 
where

rebin - wavelength rebinning factor
rmfbins - number of bins in the response file; this should be greater than 3000
entrystage - entry stage to the pipeline
finalstage - exit stage for the pipeline

One disadvantage of this approach is that you can only choose integer binning of the original channel size. To change the sampling of the events, the pipeline must be run from the second stage ("angles") or earlier:

   rgsproc nbetabins=1133 rmfbins=5000 entrystage=2:angles finalstage=5:fluxing 
where the parameters are as defined previously, and

nbetabins - number of bins in the dispersion direction; the default is 3400
The disadvantage of using rgsproc is that the binning is linear across the dispersion direction. Velocity resolution is lost in the lines, so the accuracy of redshift determinations will be degraded, transition edges will be smoothed, and neighboring lines will become blended.

Fitting a Model

To fit the spectrum, invoke Xspec in the Command Window:

    xspec 
Enter the data, background, and response file at the prompts, and edit the fitting parameters as needed. Please note that in this example, we are using the output from rgsproc, not the PPS data that came with the data set, so the names are slightly different. If we were using the PPS data, the input spectrum would be *SBSPEC*. Since we did not include background correction when we ran rgsproc, we can correct for it now.

Hera will automatically open a new tab in your web browser and display the plot as a GIF file.

      XSPEC> data P0153950701R1S001SRSPEC1001.bin30.FIT ! input data 
      XSPEC> back P0153950701R1S001BGSPEC1001.bin30.FIT ! input background
      XSPEC> resp r1_o1_rmf.fits                        ! input response file
      XSPEC> ignore **-0.4                              ! set sensible limits
      XSPEC> model wabs*pow                             ! set spectral model to absorbed powerlaw
      1:wabs:nH> 0.01                                   ! enter reasonable initial values
      2:powerlaw:PhoIndex> 2.0
      3:powerlaw:norm> 1.0
      XSPEC> renorm
      XSPEC> fit
      XSPEC> setplot wave
      XSPEC> setplot command window all
      XSPEC> setplot command log x off
      XSPEC> plot data chi
      XSPEC> exit

Figure 4 shows the fit to the spectrum.

Figure 4: The 1st order RGS1 spectrum fitted with an absorbed power law model. The gap between 10-15Å is due to the absence of CCD7.


If you have any questions concerning XMM-Newton send e-mail to xmmhelp@lists.nasa.gov

This file was last modified on Tuesday, 19-Nov-2013 17:08:40 EST
Curator:Michael Arida (ADNET); michael.arida@nasa.gov

NASA Astrophysics

  • FAQ/Comments/Feedback
  • Education Resources
  • Download Adobe Acrobat
  • A service of the Astrophysics Science Division (ASD) at NASA/ GSFC

    XMM-Newton Project Scientist: Dr. Steve Snowden

    Responsible NASA Official: Phil Newman

    Privacy Policy and Important Notices.