THE XMM-NEWTON ABC GUIDE, STREAMLINED
Fit an RGS Spectrum with Xspec (via Hera)
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.
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 cstatFor our purposes, a quick, preliminary fit of the spectrum is sufficient, so we will rebin and use χ2 statistics.
To rebin the spectrum with grppha, navigate to your working directory with the spectra in it, then enter in the Command Window:
grpphaand 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:fluxingwhere
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:fluxingwhere the parameters are as defined previously, and
nbetabins - number of bins in the dispersion direction; the default is 3400
To fit the spectrum, invoke Xspec in the Command Window:
xspecEnter 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.
If you have any questions concerning XMM-Newton send e-mail to email@example.com