MPE/xray/wave
Max-Planck-Institut für extraterrestrische Physik

XMM-Newton Data Analysis - Example
 

Verweis Deutsche Version .  MPE . HEG  . X-Ray Astronomy . Wave . XMM-Newton . Data Analysis . MOS Data . spectral
X-Ray Astronomy
Wave
ROSAT
XMM-Newton
General
Highlights
Gallery
Telescope Scientist
Eur. Photon Im. Cam.
Survey Science Centre
Overview on Services
Proposal-tools
Data Analysis
Introduction
Data Archives
Pipeline Products
Data Preparation
PN Data
MOS Data
spatial
spectral
timing
RGS Data
OM Data
Documents
Problems
Chandra
Other Projects
Data Center
Exsas

Search
Impressum
Contact

Valid HTML 4.01!

[Visit MPE's Home Page] XMM-Newton Data Center at MPE
Extract point source spectrum + background
from EPIC MOS event file
[Visit XMM-Newton at MPE]

input file: P0123700101M1S002MIEVLI0000.FIT
output file: source.fits, backgr.fits, source_bg.fits
instrument: EPIC MOS, IMAGING mode

This page describes

  1. the selection of source and background events to get a spectrum
  2. the preparations that have to be done to be able to fit the spectrum
  3. an example script file for generating a spectrum starting from the event list
  4. an interactive method of selecting events and preparing for spectral analysis by using the Graphical User Interface (GUI) task xmmselect.

    Remark:
    It might seem possible to use also FTOOLS, which can be faster than the XMMSAS tasks listed below. However, it is strongly recommended to use the XMMSAS tasks, because FTOOLS are very basic tools. They do not provide all the header information which eventually may be requested by some other tasks for further analysis, nor do they take into account any pecularities of the detectors as the XMMSAS tasks do at various points.
1. The selection of source and background spectra.

Spectra of point sources and background can be extracted by using the XMMSAS task evselect:

  • Define the regions you want to select for your point source and background region. A general description is available on the select region page

    The background photons may be selected within a ring around the source or at some convenient other location. Because of the faster read-out time, the out-of-time events do not play such a significant role for EPIC-MOS as they do for EPIC-PN.

  • There are two columns referring to spectral properties, the Pulse Height Analyser PHA channels and the Pulse Height Invariant PI channels. The PHA are the raw channels while the PIs are gain and CTE corrected plus recombined. This means that doubles and triples and so on are combined to one single event. So the latter are the ones to be used for spectral analysis.

    For EPIC-MOS it is recommended to choose the PI channels between 0 and 11999 and spectralbinsize=15.

  • PATTERN describes basically how the charge cloud released by the infalling photon was distributed over the pixels. This is more difficult for MOS data than for EPIC PN events, because of the smaller pixel size of the EPIC MOS CCDs. Please have a look at the Description of an EPIC MOS event file page to see how the PATTERN is defined for this detector. For spectral analysis it is recommended to use PATTERN.le.12 . If you prefer for your spectrum to stay on the secure side you may concentrate on singles only, PATTERN.eq.0. The fractions of singles, doubles, etc. can be viewed by the XMMSAS task epatplot. Please also check the Single/Double Fraction page.

  • Pile-ups are a severe problem for spectral analysis, because if those events are not screened they will change the spectral shape of your spectrum. For information how to detect pile-ups in your observation check the Single/Double Fraction page. If you notice pile-ups in your observation, exclude the inner region of the source and display the spectrum with epatplot again.

  • The FLAG defines the quality of the data. For spectral analysis it is highly recommended to use FLAG.eq.0 only. FLAG.eq.0 means that all events that are at the edge of a CCD and at the edge to a bad pixel are excluded. Those events otherwise might have lost some part of their charge into the undefined regions/pixels and would therefore give a different, wrong spectrum.

    Example for the selection of a spectrum by task evselect

    For an example we choose the Lockman Hole exposure event file P0123700101M1U002MIEVLI0000.FIT and take an object with the sky coordinates X=26150, Y=22750 with an extraction radius of 500 sky pixel.

    for the source counts:

    evselect table=P0123700101M1U002MIEVLI0000.FIT withspectrumset=true \
          expression='circle(26150,22750,500,X,Y) .and.PATTERN.le.12' \
          withspecranges=true specchannelmin=0 specchannelmax=11999 \
          spectralbinsize=15 energycolumn=PI spectrumset=source.fits
    
    for the background counts:
    evselect table=P0123700101M1U002MIEVLI0000.FIT withspectrumset=true \
          expression='ring(26150,22750,600,1200,X,Y) .and.PATTERN.le.12' \
          withspecranges=true specchannelmin=0 specchannelmax=11999 \
          spectralbinsize=15 energycolumn=PI spectrumset=backgr.fits
    

2. Preparations to be able to fit the spectrum

The most commonly used spectral fitting package is XSPEC. At MPE you may enable XSPEC by doing source /util/lheasoft-setup.sh. A short description of its use may be found here .

To become ready to perform spectral fitting, you have to

  • calculate the area of the source and the background region by using the XMMSAS task backscale . Thereby the locations of the bad pixels are to be got from the event list:

    backscale spectrumset=source.fits \
       withbadpixcorr=yes badpixlocation=P0123700101M1U002MIEVLI0000.FIT
    backscale spectrumset=backgr.fits \
       withbadpixcorr=yes badpixlocation=P0123700101M1U002MIEVLI0000.FIT
    

    Please note that for backscale to be working correctly the location of the calibration files has to be specified beforehand:

      cifbuild 
      export SAS_CCF=./ccf.cif
    

  • group the PHA channels so as to contain at least a minimal number #min of photons

    grppha source.fits sourceg.fits comm="group min #min  & exit" clobber=yes
    

    e.g. group min 20 means that at least 20 counts are to be contained in each bin (a common value).

  • calculate the Effective Area. This is described in detail on the Response Matrices page. For a point source you write:

    arfgen spectrumset=sourceg.fits arfset=source.arf \
       detmaptype=psf badpixlocation=P0123700101M1U002MIEVLI0000.FIT

  • calculate the Detector Response Matrix (RMF=Redistribution Matrix). This is described in detail on the Response Matrices page:

    rmfgen spectrumset=sourceg.fits rmfset=source.rmf 

Now you are ready to fit the spectrum with XSPEC.

3. Example: script to generate a spectrum from the event list

This is a script file prepared by Frank Haberl, that summarizes the generation of the source and background spectra and of the response files.

    #!/usr/local/bin/bash
    # script to create EPIC-MOS spectra and response files
    # --------------------------------------------------------------------
    # specify the ODF directory:
    # --------------------------------------------------------------------
    export SAS_ODF=`your ODF directory'
    gzip -rd $SAS_ODF
    # --------------------------------------------------------------------
    # specify the location of the calibration files (if not yet done):
    # --------------------------------------------------------------------
    cifbuild
    export SAS_CCF=./ccf.cif
    # --------------------------------------------------------------------
    # some abreviations (for EPIC_MOS):
    specr="withspecranges=true specchannelmin=0 specchannelmax=11999 "
    specs="spectralbinsize=15 energycolumn=PI withspectrumset=true"
    # --------------------------------------------------------------------
    spec=$specr$specs
    out1="keepfilteroutput=true withfilteredset=true "
    out2="destruct=true filteredset"
    outset=$out1$out2
    #
    # e.g. id=P0123700101M1U002MIEVLI0000.FIT, rad=600
    id =`your event list ID'
    rad=`your extraction radius'
    X_source=`your source_X_position'
    Y_source=`your source_Y_position'
    X_backgr=`your backgr_X_position'
    Y_backgr=`your backgr_Y_position'
    gzip -d ${id}.FIT.gz
    # --------------------------------------------------------------------
    # select all events from source and background area
    # --------------------------------------------------------------------
    evselect table=${id}.FIT \
             expression="CIRCLE(${X_source},${Y_source},${rad},X,Y)" \
             $outset=${id}_sc.fits
    evselect table=${id}.FIT \
             expression="CIRCLE(${X_backgr},${Y_backgr},${rad},X,Y)" \
             $outset=${id}_bg.fits
    # --------------------------------------------------------------------
    # bin spectrum for the source:
    # --------------------------------------------------------------------
    # event patterns:
    pat="FLAG==0 && PATTERN>-1 && PATTERN<13" 
    in=${id}_sc 
    evselect table=${in}.fits expression="$pat" $spec spectrumset=${in}.pi
    # --------------------------------------------------------------------
    # calculate area of the source region taking into account bad pixels
    # --------------------------------------------------------------------
    backscale spectrumset=${in}.pi withbadpixcorr=yes \
              badpixlocation=${id}.FIT
    # --------------------------------------------------------------------
    # group PHA channels so as to contain at least min photons
    # --------------------------------------------------------------------
    min=100
    grppha ${in}.pi ${in}g.pi comm="group min ${min} & exit" clobber=yes
    
    # --------------------------------------------------------------------
    # make the same for the background photons
    # --------------------------------------------------------------------
    in=${id}_bg
    evselect table=${in}.fits expression="$pat" $spec spectrumset=${in}.pi
    backscale spectrumset=${in}.pi withbadpixcorr=yes \
              badpixlocation=${id}.FIT
    
    # --------------------------------------------------------------------
    # Now calculate the ancillary and detector response files ARF and RMF:
    # --------------------------------------------------------------------
    # for a point source
    arfgen spectrumset=${id}_scg.pi arfset=${id}_sc.arf \
           detmaptype=psf badpixlocation=${id}.FIT
    rmfgen spectrumset=${id}_scg.pi rmfset=${id}_sc.rmf
    # now you are ready to fit the spectrum with e.g. XSPEC
    

4. GUI xmmselect

With xmmselect a Graphical User Interface is started, which in the newer versions (e.g. xmmselect-2.47.8) allows to generate source and background spectra as well as detector response matrices (RMF) and effective area (ARF) files.

If you wish, you may generate these products interactively by marking the source and background regions by cursor on an image which has been produced by xmmselect as well, using DS9.

A detailed description of how to use xmmselect for extracting spectra from an event file is given on the EPIC-PN spectral analysis page.


© X-Ray Group at MPE (group)
last update:2004/01/12 19:29:09, editor of this page:dgrupe


up © Max-Planck-Institut für extraterrestrische Physik