Spectral analysis of MOS point-like sources

Introduction

This thread describes how to extract the spectrum of a point-like source observed with the MOS cameras using SAS from the command line.

Expected Outcome

The final outcome of this thread is the standard suite of spectral products required by spectral analysis packages such as XSPEC:

  • A source+background (commonly referred to as "source") spectrum
  • A background spectrum
  • A redistribution matrix (commonly referred to as a "RMF" file)
  • an effective area vector (commonly referred to as an "ARF" file)

SAS Tasks to be Used

Prerequisites

Useful Links

This thread makes use of the image display software ds9.

Caveats

Last Reviewed: 4 June 2019, for SAS v18.0

Last Updated: 30 October 2014

 


Procedure
 

This thread contains a step-by-step recipe to extract MOS spectra of a point-like source observed in Imaging mode and to create associated response matrices, starting from a calibrated, concatenated event list (either produced with emproc or available as PPS product; here it has the assumed file name MOS.fits).

All the analysis steps are performed with single SAS tasks started from the command line to explain the general method of generating spectral products and to show explicitly the usage and setting of task parameters. The users should note that the SAS meta-task xmmselect allows them to interactively define source and background regions (via ds9) and to run backscale on the fly. Especially the xmmselect: Spectral Products generation method, which in addition offers an optimisation of the source extraction region and which creates source and background spectra as well as related ancillary and redistribution files in one go, might in some cases be a GUI based alternative to the command line method described below. For more details on how to use xmmselect for the generation of EPIC spectra, the reader is referred to the Users Guide to the XMM-Newton Science Analysis System.

  1. Set up your SAS environment (following the SAS startup Thread)
     
  2. If necessary, create a MOS cleaned and filtered for particle background event file for your observation (see the How to filter EPIC event lists for flaring particle background Thread). Let's assume that a filtered file has been created, with name: MOSclean.fits
     
  3. Extract an image (sky coordinates in this example; extraction in detector - DET[XY] - coordinates is possible as well, and may be preferable for some specific scientific needs)

    NOTE: arfgen/ rmfgen do not support spectra extracted from a region defined in RAW coordinates

     evselect table=MOSclean.fits imagebinning=binSize imageset=MOSimage.fits withimageset=yes \
       xcolumn=X ycolumn=Y ximagebinsize=80 yimagebinsize=80

     
  4. Display the image

     imgdisplay withimagefile=true imagefile=MOSimage.fits

    This command is equivalent to the following:

     ds9 MOSimage.fits
     
  5. Select the region, from which the spectrum shall be accumulated, using the Region/Circle in ds9 (see Fig.1)

     

    Fig.1: ds9 main window. A circular region (green circle) has been defined using the highlighted menu.

  6. Double-click with the cursor on the defined region. A window pops up, showing the properties of the region (Fig.2) (you need to set 'Coord -> Physical' and 'Radius -> Physical' to switch to physical coordinates). Write down the coordinates of the Center (30360.5,28400.5) and of the Radius (640) as they will be needed in step 8 to define the spatial filter expression.

    (These values would also be propagated into a Selection Expression if pressing the "2D region" button in xmmselect...)

     

    Fig.2: selection region properties window, pop'd-up by double-clicking on the region in the main ds9 window

  7. If you want to see the centre position in RA, Dec (J2000) coordinates, switch 'Coord -> WCS' (World Coordinate System) and select 'Equatorial J2000'. To display the radius of the selection region in arcseconds, switch to 'Radius -> WCS' and select 'ArcSec'. Units of sky coordinates (X,Y) are 0.05 arcseconds, hence the radius in our example is 32 arcseconds.
     
  8. Extract a source spectrum, using all the selection expressions defined so far & restricting the patterns to single and doubles. It is important to check withspecranges and use the following spectral bin range, specchannelmin=0 and specchannelmax=11999, to accumulate the spectrum (see caveats).

     evselect table=MOSclean.fits withspectrumset=yes spectrumset=MOSsource_spectrum.fits \
       energycolumn=PI spectralbinsize=5 withspecranges=yes specchannelmin=0 specchannelmax=11999 \
       expression='#XMMEA_EM && (PATTERN<=12) && ((X,Y) IN circle(30360.5,28400.5,640))'

     
  9. Extract a background spectrum. Have a look at the "EPIC status of calibration and data analysis" document (XMM-SOC-CAL-TN-0018) for latest recommendations on how to select source and background regions. In the following, we assume that the background is extracted from a source-free region on the same CCD and at roughly the same off-axis angle as the source under investigation.

     evselect table=MOSclean.fits withspectrumset=yes spectrumset=MOSbackground_spectrum.fits \
       energycolumn=PI spectralbinsize=5 withspecranges=yes specchannelmin=0 specchannelmax=11999 \
       expression='#XMMEA_EM && (PATTERN<=12) && ((X,Y) IN circle(30720.5,26360.5,640))'


    Alternatively the background spectrum can be extracted from an annulus surrounding the circular source extraction region. The corresponding selectlib expression is: ((X,Y) IN annulus(30360.5,28400.5,650,1000)).

    If you are interested in learning how to extract the background spectra from blank sky event lists, please go to the How to extract background spectra from blank fields event lists thread.
     
  10. Calculate the area of source and background region used to make the spectral files. The area is written into the header of the SPECTRUM table of the file as keyword BACKSCAL (if the spectrum is created via xmmselect, backscale will run automatically).
     

     backscale spectrumset=MOSsource_spectrum.fits badpixlocation=MOSclean.fits
     backscale spectrumset=MOSbackground_spectrum.fits badpixlocation=MOSclean.fits

  11. Generate a redistribution matrix. Currently there are two possible approaches:
     

    a) use the SAS task rmfgen to create a redistribution matrix for your previously extracted spectrum:

     rmfgen spectrumset=MOSsource_spectrum.fits rmfset=MOS.rmf

    NOTE: This can take long (>30 min) on low-performance computers...

    b) use the ready-made (canned) response matrices.

  12. Generate an ancillary file (for extended sources use extendedsource=yes detmaptype=flat or dataset)
     

    NOTE: arfgen reads in the pattern range from the Data Sub Space (DSS) information in the spectrum dataset, and accumulates the quantum efficiency curves over those patterns, which is then combined to the other constituents of the ARF. Be aware that the entire range of allowed patterns (0-31 for the MOS) are assumed if no pattern range is found in the DSS.

     arfgen spectrumset=MOSsource_spectrum.fits arfset=MOS.arf withrmfset=yes rmfset=MOS.rmf \
       badpixlocation=MOSclean.fits detmaptype=psf

  13. Rebin the spectrum and link associated files. In the following example the spectrum is rebinned in order to have at least 25 counts for each background-subtracted spectral channel and not to oversample the intrinsic energy resolution by a factor larger than 3.

     specgroup spectrumset=MOSsource_spectrum.fits mincounts=25 oversample=3 rmfset=MOS.rmf \
      arfset=MOS.arf backgndset=MOSbackground_spectrum.fits groupedset=MOS_spectrum_grp.fits

     

    The rebinning options shown in the example above, are by no means the only possible binning available, or the recommended one, more binning options are available in the description of the task specgroup.

  14. Fit the grouped spectrum: MOS_spectrum_grp.fits

 

Caveats
 

To extract a spectrum, withspecranges must be checked (set to yes), with specchannelmin set to 0, and specchannelmax set to 11999 for the MOS. It is important to use this PI range. Selecting a spectrum with a non-standard PI range results in wrong response matrices with an impact on any spectral results derived when using them. If a spectrum needs to be generated within a given energy range, this must be done through the selection expression and not by changing the PI range through specchannelmin and specchannelmax.

In general the user should use PATTERN 0-12. However, PATTERN 0 events can be used to minimise the effects of pile-up in bright sources and for sources in which the best-possible spectral resolution is crucial.

In case of MOS Timing mode observations, PATTERN 0 should only be selected for the source, and PATTERN 0,1,3 for the background spectra extracted from the outer CCDs. For details and the latest recommendations, see  XMM-SOC-CAL-TN-0018.