skip to content

HEASARC support for unencypted FTP access will be ending possibly as early as July 31, 2019. Please see this notice for details.

XMM-Newton Guest Observer Facility


RGS, Hera Command Window


Prepare the Data
Reprocess the Data
Make Images
Make a Light Curve
Generate and Apply a New GTI
Create the Photon Redistribution Matrix (RMF)
Check for Pile Up
Combining Spectra

Prepare the Data

Please note that the two tasks in this section (cifbuild and odfingest) must be run in the ODF directory. These are the only tasks with that requirement, and after this section, we will work exclusively in our reprocessing directory.

Many SAS tasks require calibration information from the Calibration Access Layer (CAL). Relevant files are accessed from the set of Current Calibration File (CCF) data using a CCF Index File (CIF). To make the ccf.cif file, navigate into the ODF directory and in the Command Window, type

The task odfingest extends the Observation Data File (ODF) summary file with data extracted from the instrument housekeeping data files and the calibration database. It is only necessary to run it once on any dataset, and will cause problems if it is run a second time. If for some reason odfingest must be rerun, you must first delete the earlier file it produced. This file largely follows the standard XMM naming convention, but has SUM.SAS appended to it. To run odfingest, just type in the Command Window
Hera automatically resets the relevant environmental parameters to the output of these tasks, so we can continue merrily on our way.

Reprocess the Data

To reprocess the data, go up one directory in the tree and make a new working directory using the buttons in the upper left corner of the User Account Window. When you are in the working directory, call rgsproc by typing in the Command Window
This takes several minutes, and outputs 12 files per RGS, plus 3 general use FITS files. It is convenient to rename them something easy to type; this can be done by clicking on the pen icon next to the file name in the User Account Window. We'll assume the new name for the RGS1 and RGS2 event files are r1_evt1.fits and r2_evt1.fits, respectively. The pipeline task rgsproc is very flexible and can address potential pitfalls for RGS users. If the default parameters are sufficient for your data (and they should be for most), feel free to skip ahead. However, there are some cases where the standard processing may not be appropriate. These are discussed next.

My data has a bright optical source near the target!

First, if the data includes a nearby bright optical source, with certain pointing angles, zeroth-order optical light may be reflected off the telescope optics and onto the RGS CCD detectors. If this falls on an extraction region, the current energy calibration will require a wavelength-dependent zero-offset. Stray light can be detected on RGS DIAGNOSTIC images taken before, during and after the observation. This test, and the offset correction, are not performed on the data before delivery. To check for stray light and apply the appropriate offsets,

   rgsproc calcoffsets=yes withoffsethistogram=no
calcoffsets - calculate PHA offsets from diagnostic images
withoffsethistogram - produce a histogram of uncalibrated excess for the user

My data has a bright X-ray source near the target!

If the data includes a nearby bright X-ray background source that is well-separated from the target in the cross-dispersion direction, a mask can be created that excludes it from the background region. Here the source has been identified in the EPIC images and its coordinates have been taken from the EPIC source list which is included among the pipeline products. The bright neighboring object is found to be the third source listed in the sources file. The first source is the target:

   rgsproc orders='1 2' withepicset=yes epicset=PiiiiiijjkkaablllEMSRLInmmm.FTZ 
withepicset - calculate extraction regions for the sources contained in
   an EPIC source list
epicset - name of the EPIC source list, such as generated by emldetect
   or eboxdetect procedures
exclsrcsexpr - expression to identify which source(s) should be excluded
   from the background extraction region

I want to define my own target.

If the true coordinates of an object are not included in the EPIC source list or the science proposal, the user can define the coordinates of a new source:

   rgsproc withsrc=yes srclabel=Mkn421 srcstyle=radec srcra=166.113808 srcdec=+38.208833
withsrc - make the source be user-defined
srclabel - source name
srcstyle - coordinate system in which the source position is defined
srcra - the source's right ascension in decimal degrees
srcdec - the source's declination in decimal degrees

Make Images

Two commonly-made plots are those showing PI vs. BETA_CORR (also known as "banana plots") and XDSP_CORR vs. BETA_CORR.

To make a banana plot, type

   evselect table=r1_evt1.fits imageset=pi_bc.fits xcolumn=BETA_CORR ycolumn=PI
      imagebinning=imageSize ximagesize=600 yimagesize=600 
table - make the source be user-defined
imageset - source name
xcolumn - coordinate system in which the source position is defined
ycolumn - the source's right ascension in decimal degrees
imagebinning - the source's declination in decimal degrees
ximagesize - size of the image on x axis
yimagesize - size of the image on y axis
Plots comparing BETA_CORR to XDSP_CORR may be made in a similar way. The output files can be viewed via Hera with js9, or downloaded and displayed with ds9. They are shown in Figure 1.

Figure 1. Plots of PI vs. BETA_CORR (left) and XDSP vs. BETA_CORR (right).

Make a Light Curve

The XMM-Newton Observatory is susceptible to soft particle flaring, so it is necessary to examine the light curve to determine how much of the data is useful. We will extract a region, CCD9, that is most susceptible to these events and generally records the least source events due to its location close to the optical axis. Also, to avoid confusing background for source variability, a region filter that removes the source from the final event list should be used. The region filters are kept in the source file product P*SRCLI_*.FIT.

More experienced users should be aware that with SAS 13, the *SRCLI* file's column information changed. rgsproc now outputs an M_LAMBDA column instead of BETA_CORR, and M_LAMBDA should be used to generate the light curve. (The *SRCLI* file that came with the PPS products still contains a BETA_CORR column if you prefer to use that instead.)

To create a light curve, type

   evselect table=r1_evt1.fits rateset=r1_ltcrv.fits maketimecolumn=yes 
      timebinsize=100 makeratecolumn=yes 

table - input event table
rateset - name of output light curve file
maketimecolumn - make a time column
timebinsize - time binning (seconds)
makeratecolumn - make a count rate column, otherwise a count column will be created
expression - filtering criteria

The output file r1_ltcrv.fits can be download and viewed with fv, as shown in Figure 2.

fv r1_ltcrv.fits &

Figure 2: The light curve as seen in fv.

Generate and Apply a New GTI

Examination of the lightcurve shows that there is a noisy section at the end of the observation, after 1.36975e8 seconds, where the count rate is well above the normal background count rate of about 0.05 count/second. There are two procedures that make the GTI file (gtibuild and tabgtigen) that, when applied to the event file in another run of rgsproc, will excise these sections.

The first method, using gtibuild, requires a text file uploaded from your local machine as input. In the first two columns, refer to the start and end times (in seconds) that you are interested in, and in the third column, indicate with either a + or - sign whether that region should be kept or removed. Each good (or bad) time interval should get its own line. In the example case, we would write in our ASCII file gti.txt:

   1.36958e8 1.36975e8 + 
Upload the file by browsing your local directory in the User Account Window, and proceed to gtibuild:
   gtibuild file=gti.txt table=gti.fits

file - input text file
table - output GTI table

We can apply the GTI to the event file by running rgsproc again. rgsproc is a complex task, running several steps, with five different entry and exit points. It is not necessary to rerun all the steps in the procudure, only the ones involving filtering.

   rgsproc auxgtitables=gti.fits entrystage=3:filter finalstage=5:fluxing 

auxgtitables - gti file in FITS format
entrystage - stage at which to begin processing
finalstage - stage at which to end processing

Create the Photon Redistribution Matrix (RMF)

Response matrices (RMFs) are not provided as part of the pipeline product package, so you must create your own before analyzing data. The task rgsproc generates a response matrix automatically (with the nomenclature *RSPMAT*.FIT), but as noted above the source coordinates are under the observer's control. The source coordinates have a profound influence on the accuracy of the wavelength scale as recorded in the RMF that is produced automatically by rgsproc, and each RGS instrument and each order will have its own RMF.

Making the RMF is easily done with rgsrmfgen. Please note that, unlike with EPIC data, it is not necessary to make ancillary response files (ARFS).

To make the RMFs, type

   rgsrmfgen spectrumset=P0153950701R1S001SRSPEC1001.FIT rmfset=r1_o1_rmf.fits
      evlist=r1_evt1.fits emin=0.4 emax=2.5 rows=5000 

spectrumset - spectrum file
evlist - event file
emin - lower energy limit of the response file
emax - upper energy limit of the response file
rows - number of energy bins; this should be greater than 3000
rmfset - output FITS file

At this point, the spectra can be either analyzed or combined with other spectra. However, if your source is very bright (total count rate in all orders > 12 cts/s in RGS1, and 6 cts/s in RGS2), it is a good idea to check it for pile up first.

Check for Pile Up

Depending on how bright the source is event pile up may be a problem. Pile up occurs when a source is so bright that incoming X-rays strike two neighboring pixels or the same pixel in the CCD more than once in a read-out cycle. In the RGS, it will cause two coincident 1st order photons to combine into a single 2nd order event at the same spatial position on the detector but at half the wavelength; this results in photons moving from 1st order to 2nd order, and 2nd order to 3rd. Further, it can increase the number of complicated event patterns of the sort that the on-board processing removes; this results in differences in pile up between the two RGS detectors, and between CCD locations.

One way to determine if there is pile up is to examine the ratio of 1st and 2nd order fluxed spectra. Non-piled sources should have fluxed spectra that agree within a few percent, while piled sources will show discrepancies of about 10% or higher.

When rgsproc is run through the 5:fluxing stage, one of the outputs is fluxed spectra. They follow the naming convention *OBX*fluxed1000.FIT and *OBX*fluxed1000.FIT, for the 1st and 2nd orders, respectively. They can be downloaded and viewed with fv, as in Figure 3. If for some reason rgsproc wasn't run through that stage, fluxed spectra are easy enough to produce with rgsfluxer, if you have response matrices for both RGS instruments. We'll say that the 1st order RGS2 response matrix is r2_o1_rmf.fits. Then for the 1st order:

   rgsfluxer pha='P0153950701R1S001SRSPEC1001.FIT P0153950701R2S002SRSPEC1001.FIT' 
      rmf='r1_o1_rmf.fits r2_o1_rmf.fits' file=fluxed_o1.fits

pha - list of spectrum files
rmf - list of response matrices
file - output spectrum

Fluxed 2nd order spectra are made in a similar way. The spectra are shown in Figure 3. There is good agreement between them, so we can continue.

Figure 3. The fluxed 1st (left) and 2nd (right) order spectra from the Mkn 421 observation.

Unfortunately, if your spectrum is piled up, there is not a lot you can do to fix it; there is no tried-and-true method like with the EPIC and what there is applies only to certain cases, such as if you assume the 2nd order spectrum is composed entirely of piled up 1st order photons. For more information, see Ness et al. 2007, ApJ, 665, 1334.

Combining Spectra

Spectra from the same order in RGS1 and RGS2 can be safely combined to create a spectrum with higher signal-to-noise if they were reprocessed using rgsproc with spectrumbinning=lambda, which is the default setting. The task we will use to merge source spectra, rgscombine also merges response files and background spectra. When merging response files, be sure that they have the same number of bins. For this example, we assume that RMFs were made for order 1 in both RGS1 and RGS2 with rgsproc, which has a default bin number of 4000.

To merge RGS1 and RGS2 spectra,

   rgscombine pha='P0153950701R1S001SRSPEC1001.FIT P0153950701R2S002SRSPEC1001.FIT'
      rmf='r1_o1_rmf.fits r2_o1_rmf.fits'
      bkg='P0153950701R1S001BGSPEC1001.FIT P0153950701R2S002BGSPEC1001.FIT'
      filepha='r12_o1_srspec.fits' filermf='r12_o1_rmf.fits'
      filebkg='r12_o1_bgspec.fits' rmfgrid=4000 

pha - list of spectrum files
rmf - list of response matrices
bkg - list of bakcground spectrum files
filepha - output merged spectrum
filermf - output merged response matrix
filebkg - output merged badkground spectrum
rmfgrid - number of energy bins; should be the same as the input RMFs

If you have any questions concerning XMM-Newton send e-mail to

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

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.