How to Generate vignetting-corrected background-subtracted EPIC images


This threads deals with the creation of EPIC vignetting-corrected background-subtracted images. The method described in this thread can only be applied to images from EPIC-pn Full Frame and Extended Full Frame mode and EPIC-MOS Full Frame mode exposures.

This thread briefly explains how to create such images for a particular science observation. For this purpose, the XMM-Newton observation with id 0555630101 will be used throughout the thread. The observation corresponds to the extended source SN 1006-1, which is more suitable to illustrate image creation.

Expected Outcome

The expected outcome of this thread is a set of background-subtracted and vignetting-corrected EPIC science exposure images for different energy bands. For each energy band, an image of the science exposure, corresponding scaled out-of-time (OOT) (EPIC-pn only) and scaled Filter Wheel Closed (FWC) images, and a vignetting corrected exposure map and mask are created. This set of images is used to create the final background-subtracted and vignetting-corrected science exposure images for each energy band.

SAS Tasks to be Used


Useful Links


Last Reviewed: 25 MAY 2023, for SAS v21.0

Last Updated: 30 OCTOBER 2020




  1. Set up your SAS environment (see Prerequisites for this thread at the top of the page).
  2. Create standard EPIC event files for your science observation (see Prerequisites for this thread at the top of the page). The name of the event files for the example obsid used are:

       1594_0555630101_EPN_S003_ImagingEvts.ds   ; in Extended Full Frame mode
       1594_0555630101_EMOS1_S001_ImagingEvts.ds ; in Full Frame mode
       1594_0555630101_EMOS2_S002_ImagingEvts.ds ; in Full Frame mode

    Additionaly, for EPIC-pn, an Out-of-Time event file has to be created first. Run epproc with the option withoutoftime set to yes. It is best to run first epproc with this option to produce the out-of-time event file and then produce the standard file to avoid overwritting files:

       epproc withoutoftime=yes

    For the example obsid, 0555630101, rename the produced file to indicate that it corresponds to Out-of-Time events:





    Fig.1: Individual raw EPIC (from left to right; pn, MOS1 and MOS2) images in the 0.2-12 keV energy range. The plotting scale of the three images is the same, so images can be visually compared directly.

  3. If necessary, create Good Time Intervals (GTI) files defining time intervals clean of flaring particle background for your observation (see Prerequisites for this thread at the top of the page). The filtering procedure will result in a file with the definition of the GTI. It is not necessary to create a clean event file using these GTI files as the task eimageget will take care of it (see Caveats section at the bottom of this page). Let the name of the GTI files be:


    These files can be used as input for eimageget through the task parameter gtifile. Notice that this GTI selection will not be applied to the Filter Wheel Close event file produced by eimageget as it is not needed.

  4. Download the corresponding Filter Wheel Closed files from the repository and place them in the working directory together with the event files just created. In this case the needed files are:

       pn_closed_EFF_2019_v1.fits.gz    ; for Extended Full Frame mode
       mos1_closed_FF_2019_v1.fits.gz ; for Full Frame mode
       mos2_closed_FF_2019_v1.fits.gz ; for Full Frame mode

    where 2019 in the file name in this example indicates the year. Download the latest files available.
  5. In its simplest form, run the SAS task eimageget over each one of the EPIC event files.

       eimageget evtfile=1594_0555630101_EPN_S003_ImagingEvts.ds \
           ootfile=1594_0555630101_EPN_S003_OoT_ImagingEvts.ds \
           fwcfile=pn_closed_EFF_2019_v1.fits.gz \
           gtifile=pn_gti.fits \

       eimageget evtfile=1594_0555630101_EMOS1_S001_ImagingEvts.ds \
           fwcfile=mos1_closed_FF_2019_v1.fits.gz \
           gtifile=m1_gti.fits \

       eimageget evtfile=1594_0555630101_EMOS2_S002_ImagingEvts.ds \
           fwcfile=mos2_closed_FF_2019_v1.fits.gz \
           gtifile=m2_gti.fits \


    Notice that the Out-of-Time event file is only used in the call to eimageget for the case of EPIC-pn. These three calls will generate the following set of files:

           P0555630101[PNS003,M1S001,M2S002]_ima_[0-4].fits ; science exposure images
           P0555630101PNS003_ima_[0-4]oot.fits ; Out-of-Time exposure images (only for PN)
           P0555630101[PNS003,M1S001,M2S002]_ima_[0-4]fwc.fits ; Filter Wheel Close exposure images
           P0555630101[PNS003,M1S001,M2S002]_ima_[0-4]exp.fits ; Exposure maps
           P0555630101[PNS003,M1S001,M2S002]_ima_mask.fits ; A single mask valid for all energy bands

    Where [0-4] indicates a different energy range, by default:

           0: 0.2-0.5 keV
           1: 0.5-1.0 keV
           2: 1.0-2.0 keV
           3: 2.0-4.5 keV
           4: 4.5-12.0 keV

    A set of different energy ranges can be specified by using the task parameters pimin and pimax in the call to eimageget.

    Fig.2 shows the different images produced by eimageget for the case of EPIC-pn (the mask file is not shown). A similar result is obtained for EPIC-MOS1 and EPIC-MOS2.

    Fig.2: Result of applying eimageget to the EPIC-pn science exposure. Images correspond to the lowest energy range, 0.2-0.5 keV. From top lef to bottom right; science exposure image, scaled Out-of-Time exposure image, scaled Filter Wheel Close exposure image, and exposure map.
    The plotting scale of the first three images is the same, so images can be visually compared directly.
  6. The scaled Out-of-Time and Filter Wheel Close images can be subtracted directly from the corresponding exposure images and the resulting image can be divided by its exposure map. However, the subtraction of the images is not done by eimageget because in most cases the statistics will require some smoothing. In the case of adaptive smoothing, images from individual exposures should be combined first and be smoothed with the same smoothing template. The task eimagecombine can be used to conveniently combine the individual output images of eimageget. The meta-task eimagecombine combines the individual output images from the task eimageget to produce a background-subtracted, vignetting-corrected, and smoothed image of EPIC exposures. In order to do this, run the task eimagecombine in the same working directory where the products of eimageget are. In its simplest form, the task can be run as:


    which will set all of its parameters to their default value. Several intermediate step files are created, but the final product is a file per energy range used. In this example, the final 5 files produced follow this naming convention:


    Where, as before, [0-4] indicate the different energy ranges used. The corresponding images are shown in Fig.3.

    Fig.3: Results of applying eimagecombine to the EPIC science exposure produced by eimageget. The figure shows from top lef to bottom right the final background-subtracted, vignetting-corrected, and smoothed image of the combine EPIC (pn, MOS1 and MOS2) exposures for the five energy ranges considered (0.2-0.5, 0.5-1.0, 1.0-2.0, 2.0-4.5 and 4.5-12.0 keV). The plotting scale of all the images is the same, so images can be visually compared direclty


  • Both tasks used in this thread eimageget and eimagecombine allow to be run in a more complex way. For example, eimageget allows to flag and remove EPIC-MOS CCDs in anomalous states, or to produce images where coordinates are recalculated with respect to user defined positions if several exposures from different observations are going to be added later. eimagecombine, for example, allows to specify the weights of the EPIC-pn and EPIC-MOS exposures (the default is 0.4 for MOS and 1.0 for pn) or to define the type of smoothing desired as defined by the SAS task asmooth. For more information visit the tasks online documentation.
  • The task eimageget requires as input an event list file which still contains the out-field-of-view (out-FOV) events. Providing a pre-filtered event list file for which an event quality flag filtering was applied removing out-FOV events (e.g. FLAG==0, #XMMEA_EM or #XMMEA_EP) will disable the background subtraction using the filter wheel closed data. It is recommend to use the original event list files as generated by epproc/emproc together with a gti file excluding background flare periods. The task eimageget includes the quality flag filtering #XMMEA_EM or #XMMEA_EP.