skip to content

The HEASARC welcomes your participation in a brief survey to capture how users access and utilize HEASARC data, software, and services. The outcome(s) of this survey will be used to guide, prioritize, and plan our activities and development in the coming years. It contains 20 questions, generally takes just a few minutes to complete, and your answers will remain totally anonymous. The survey is open until Dec 18, 2023. We thank you in advance for your valuable feedback.

XMM-Newton Guest Observer Facility


EPIC-MOS (TIMING mode), Command Line


Prepare the Data
Reprocess the Data
Apply Standard Filters
Make a Light Curve
Extract the Source and Background Spectra
Check for Pile Up
Determine the Spectrum Extraction Areas
Create the Photon Redistribution Matrix (RMF) and Ancillary File (ARF)

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 set the environment parameter and make the ccf.cif file, type

   cd ODF
   setenv SAS_ODF /full/path/to/ODF/directory/
   setenv SAS_ODFPATH /full/path/to/ODF/directory/

To use the updated CIF file in further processing, you will need to reset the environment variable SAS_CCF:

   setenv SAS_CCF /full/path/to/ODF/ccf.cif

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. After running odfingest, you will need to reset the environment variable SAS_ODF to its output file. To run odfingest and reset the environment variable, type

   setenv SAS_ODF /full/path/to/ODF/full_name_of_*SUM.SAS

You will likely find it useful to alias these environment variable resets in your login shell (.cshrc, .bashrc, etc.).

Reprocess the Data

To reprocess the data, make a new working directory and call emproc.
   cd ../
   mkdir PROC
   cd PROC

By default, intermediate files that are generated are not kept. Emproc designates its output event files with "TimingEvts.ds". It is convenient to rename them something easy to type:

   cp 0201_0070740101_EMOS1_S001_TimingEvts.ds mos1_te.fits

If you are likely to want to extract a background spectrum for your source, you will also need to consider the imaging event file. We might as well deal with that while we're here. Remember that whatever filtering is done on the timing event file must also be done on the image event file.

   cp 0201_0070740101_EMOS1_S001_ImagingEvts.ds mos1_ie.fits

Apply Standard Filters

The filtering expression for the MOS in TIMING mode is the same as for IMAGING mode:

   (PATTERN <= 12)&&(PI in [200:12000])&&#XMMEA_EM

The first two expressions will select good events with PATTERN in the 0 to 12 range. The PATTERN value is similar the GRADE selection for ASCA data, and is related to the number and pattern of the CCD pixels triggered for a given event. Single pixel events have PATTERN == 0, while double pixel events have PATTERN in [1:4] and triple and quadruple events have PATTERN in [5:12].

The second keyword in the expressions, PI, selects the preferred pulse height of the event. For the MOS, it should be between 200 and 12000 eV. This should clean up the image significantly with most of the rest of the obvious contamination due to low pulse height events. Setting the lower PI channel limit somewhat higher (e.g., to 300 or 400 eV) will eliminate much of the rest.

Finally, the #XMMEA_EM filter provides a canned screening set of FLAG values for the event. (The FLAG value provides a bit encoding of various event conditions, e.g., near hot pixels or outside of the field of view. Setting FLAG == 0 in the selection expression provides the most conservative screening criteria and usually is not necessary for the MOS.)

To filter the data, type

   evselect table=mos1_te.fits filteredset=mos1_te_filt.fits \ 
      expression='(PATTERN <= 12) && (PI in [200:12000]) && #XMMEA_EM' 
and, if you're using the image event file,
   evselect table=mos1_ie.fits filteredset=mos1_ie_filt.fits \
      expression='(PATTERN <= 12) && (PI in [200:12000]) && #XMMEA_EM'

table - input event table
expression - filtering expression
filteredset - output file name

Make a Light Curve

Sometimes, it is necessary to use filters on time in addition to those mentioned above. This is because of soft proton background flaring, which can have count rates of 100 counts/sec or higher across the entire bandpass.

To determine if our observation is affected by background flaring, we can make a light curve and display it with, for instance, fv:

   evselect table=mos1_te_filt.fits rateset=mos1_ltcrv.fits maketimecolumn=yes \
      timebinsize=20 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

The output file mos1_ltcrv.fits can be viewed by using fv, as shown in Figure 1. No flares are evident, so we will continue to the next section. However, if a dataset does contain flaring, it should be removed in the same way as shown for EPIC IMAGING mode data here.

fv mos1_ltcrv.fits &

Figure 1: The Mkn 841 light curve.

Extract the Source and Background Spectra

First, we will need to make an image of the filtered event file:
   evselect table=mos1_te_filt.fits imagebinning=binSize \
      imageset=mos1_te_image.fits withimageset=yes \
      xcolumn=RAWX ycolumn=TIME ximagebinsize=1 yimagebinsize=1
where the keywords are the same as for applying standard filters, and

imagebinning - method of filtering
imageset - name of output image
xcolumn - column with x-coordinates
ycolumn - column with y-coordinates
ximagebinsize - binning factor for x-axis
yimagebinsize - binning factor for y-axis

Figure 2: Mkn 841 timing data.

The image can be displayed with ds9. As can be seen in Figure 2, the source is centered on RAWX=314. We will extract this and the 10 pixels on either side of it, keeping only the highest quality, single pattern events (FLAG==0 && PATTERN==0).

   evselect table=mos1_te_filt.fits withspectrumset=yes \
      spectrumset=source_pi.fits energycolumn=PI spectralbinsize=5 \
      withspecranges=yes specchannelmin=0 specchannelmax=11999 \
      withfilteredset=yes filteredset=mos1_te_filt_source.fits \
      expression='(FLAG==0) && (PATTERN==0) && (RAWX in [304:324])'
where the keywords are the same as above, and

spectrumset - output spectrum name
energycolumn - name of the energy column
spectralbinsize - binning factor for spectrum
specchannelmin - minimum channel number
specchannelmax - maximum channel number

If needed, we can also extract a background spectrum. For this, we will use the imaging event list, since we want the background to be as far away from the source as possible. As with the source spectrum, we will need to make an image first.

   evselect table=mos1_ie_filt.fits imagebinning=binSize \
      imageset=mos1_ie_image.fits withimageset=yes \
      xcolumn=DETX ycolumn=DETY ximagebinsize=100 yimagebinsize=100
The image is shown in Figure 3, with the background extraction region overlayed. Once again, we will only keep the high quality events, but we'll loosen the restriction on the event pattern a bit, using patterns 0, 1, and 3, since we're using the outer CCDs.
   evselect table=mos1_ie_filt.fits withspectrumset=yes spectrumset=bkg_pi.fits \
      energycolumn=PI spectralbinsize=5 withspecranges=yes specchannelmin=0 \
      specchannelmax=11999 withfilteredset=yes filteredset=mos1_filt_bkg.fits \
      expression='(FLAG==0)&&((DETX,DETY) in BOX(301.5,-13735.5,10700,4000,0))&&(PATTERN==0)'
Figure 3: The filtered imaging event file for Mkn 841. The green box indicates the region where the background spectrum was extracted.

Check for Pile Up

Depending on how bright the source is and what modes the EPIC detectors are in, 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 such cases the energies of the two events are in effect added together to form one event. Pile up and how to deal with it is discussed at length here and here, respectively, and users are strongly encouraged to refer to those sections.

In our example case, the source is too faint to be piled up, but it is always a good idea to check anyway.

   epatplot set=mos1_te_filt_source.fits useplotfile=yes \
      withbackgroundset=yes backgroundset=mos1_filt_bkg.fits
where the keywords are

set - the selected region's event file
plotfile - output file name
useplotfile - use "plotfile" as output file name, or default nomenclature?
withbackgroundset - use a background event set for background subtraction
backgroundset - name of background event set

The output is shown in Figure 4. Examining the lower plot, we see that there is excellent agreement between the modeled and observed single and double pattern events, and the observed-to-model fraction for doubles is < 1.0, indicating that the observation is not affected by pile up.

It should be noted, however, that if you are working with a dataset that is piled up, it should be treated the same way as piled up PN TIMING (or IMAGING) data, that is, by using only single pixel events, and/or removing the regions with very high count rates, checking the amount of pile up, and repeating until it is no longer a problem. A walk-through that details how to deal with piled up TIMING data can be found here.

Figure 4: The output of epatplot.

Determine the Spectrum Extraction Areas

The source and background region areas can now be found. (This process is identical to that used for IMAGING data.) This is done with the task backscale, which takes into account any bad pixels or chip gaps, and writes the result into the BACKSCAL keyword of the spectrum table. To find the source and background extraction areas:

   backscale spectrumset=source_pi.fits badpixlocation=mos1_te_filt.fits
   backscale spectrumset=bkg_pi.fits badpixlocation=mos1_ie_filt.fits

Create the Photon Redistribution Matrix (RMF) and Ancillary File (ARF)

Making the RMF for MOS data in TIMING mode is exactly the same as in IMAGING mode, which is demonstrated here. If you are using SAS v. 14 or higher, making the ARF is the same, as well, even if the data was piled up and thus the boresight columns were removed. To make the RMF,

    rmfgen spectrumset=source_pi.fits rmfset=source_rmf.fits

rmfset - output file
spectrumset - spectrum file

and to make the ARF,

   arfgen spectrumset=source_pi.fits arfset=source_arf.fits withrmfset=yes \
      rmfset=source_rmf.fits badpixlocation=mos1_te_filt.fits detmaptype=psf
However, if you excised piled up regions to make a spectrum and are using SAS v. 13.x or older, you will need to make an ARF for the full extraction area, another one for the piled up area, and then subtract the two to find the ARF for the non-piled regions. Users are referred to this discussion, where the procedure is demonstrated on PN TIMING data.

The spectrum can be fit using HEASoft or CIAO packages, as SAS does not include fitting software.

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.