Creation of EPIC merged background subtracted and exposure corrected images

Introduction

This thread describes how to create EPIC merged background subtracted and exposure corrected images combining data from three ObsIDs and the three instruments.

This thread uses data from three observations of M101: ObsIDs 0104260101, 0164560701, and 0212480201. These data are also used as the Mosaicking Analysis example where a script and output files are provided.

Expected Outcome

The final outcome of this thread are images of the merged data of M101.

SAS Tasks to be Used

Prerequisites

This thread starts with the assumption that data from the three EPIC instruments from the three individual observations have been processed following the Image Analysis thread, with the slight complication of processing three energy bands: 0.4-0.75 keV, 0.75-1.3 keV, and 2.0-7.2 keV. SAS must be active and the $SAS_CCF environment variable should point to the ccf.cif file from one of the obsevations.

Useful Links

Caveats

Last Reviewed: 21 June 2018, for SAS v17.0

Last Updated: 30 October 2014

 

Procedure
 

This thread contains a step-by-step recipe to create EPIC background subtracted and exposure corrected images from merged observations of the nearby galaxy M101.

 

  1. Process data from the three observations and three detectors following the Image Analysis thread in the three energy bands: 0.4-0.75 keV, 0.75-1.3 keV, and 2.0-7.2 keV. For convenience, use the directory structure (for example),
     

    /M101/merge
    /M101/0104260101/proc
    /M101/0104260101/odf
    /M101/0164560701/proc
    /M101/0164560701/odf
    /M101/0212480201/proc
    /M101/0212480201/odf

    where /M101/merge is the directory for the merged image processing, the proc directories contain the individual ObsID image processed data, and the podf directories contain the individual ObsID ODF files. SAS must be active and the $SAS_CCF environment variable should point to the ccf.cif file from one of the observations, for example,

    /M101/0104260101/proc/ccf.cif

  2. Create two ASCII files which contain paths to the individual observation exposures (dir.dat) and paths to the individual ObsID processing directories (dir-only.dat). They can be the relative paths.
     

    dir.dat

    ../0104260101/proc/mos1S001
    ../0104260101/proc/mos2S006
    ../0104260101/proc/pnS005
    ../0164560701/proc/mos1S001
    ../0164560701/proc/mos2S002
    ../0164560701/proc/pnS003
    ../0212480201/proc/mos1S001
    ../0212480201/proc/mos2S002
    ../0212480201/proc/pnS003

    dir-only.dat

    ../0104260101/proc/
    ../0164560701/proc/
    ../0212480201/proc/

  3. Merge the individual components (count, exposure, particle background, and soft proton images) from the three observations, three instruments, and three bands. The first time will include point sources. Currently the tasks require the path to the additional CalDB files required for XMM-ESAS (in this case, /XMM/sas/CCF/esas/).
     

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=1 elow=400 \
      ehigh=750 maskcontrol=0 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=2 elow=400 \
      ehigh=750 maskcontrol=0 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=3 elow=400 \
      ehigh=750 maskcontrol=0 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=4 elow=400 \
      ehigh=750 maskcontrol=0 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=1 elow=750 \
      ehigh=1300 maskcontrol=0 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=2 elow=750 \
      ehigh=1300 maskcontrol=0 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=3 elow=750 \
      ehigh=1300 maskcontrol=0 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=4 elow=750 \
      ehigh=1300 maskcontrol=0 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=1 elow=2000 \
      ehigh=7200 maskcontrol=0 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=2 elow=2000 \
      ehigh=7200 maskcontrol=0 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=3 elow=2000 \
      ehigh=7200 maskcontrol=0 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=4 elow=2000 \
      ehigh=7200 maskcontrol=0 xdim=1100 ydim=1100

  4. Create background subtracted, exposure corrected, and adaptively smoothed images in the three individual bands and a combined soft band.
     

     adapt_merge smoothingcounts=50 thresholdmasking=0.02 elowlist=400 \
      ehighlist=750 binning=2 withpartcontrol=yes withsoftcontrol=yes \
      withmaskcontrol=no

     adapt_merge smoothingcounts=50 thresholdmasking=0.02 elowlist=750 \
      ehighlist=1300 binning=2 withpartcontrol=yes withsoftcontrol=yes \
      withmaskcontrol=no

     adapt_merge smoothingcounts=50 thresholdmasking=0.02 elowlist='400 750' \
      ehighlist='750 1300' binning=2 withpartcontrol=yes withsoftcontrol=yes \
      withmaskcontrol=no

     adapt_merge smoothingcounts=50 thresholdmasking=0.02 elowlist=2000 \
      ehighlist=7200 binning=2 withpartcontrol=yes withsoftcontrol=yes \
      withmaskcontrol=no

    Rename the files.

     mv adapt-400-750.fits adapt-400-750-ps.fits
     mv adapt-750-1300.fits adapt-750-1300-ps.fits
     mv adapt-400-1300.fits adapt-400-1300-ps.fits
     mv adapt-2000-7200.fits adapt-2000-7200-ps.fits

    Then display the results.

     ds9 adapt-400-750-ps.fits adapt-750-1300-ps.fits adapt-400-1300-ps.fits \
      adapt-2000-7200-ps.fits &

     

    Figure 1: Merged EPIC image of the nearby galaxy M101 including point sources.

  5. Next create images which exclude point sources using the cheese masks for the individual observations.
     

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=1 elow=400 \
      ehigh=750 maskcontrol=1 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=2 elow=400 \
      ehigh=750 maskcontrol=1 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=3 elow=400 \
      ehigh=750 maskcontrol=1 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=4 elow=400 \
      ehigh=750 maskcontrol=1 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=1 elow=750 \
      ehigh=1300 maskcontrol=1 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=2 elow=750 \
      ehigh=1300 maskcontrol=1 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=3 elow=750 \
      ehigh=1300 maskcontrol=1 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=4 elow=750 \
      ehigh=1300 maskcontrol=1 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=1 elow=2000 \
      ehigh=7200 maskcontrol=1 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=2 elow=2000 \
      ehigh=7200 maskcontrol=1 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=3 elow=2000 \
      ehigh=7200 maskcontrol=1 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=4 elow=2000 \
      ehigh=7200 maskcontrol=1 xdim=1100 ydim=1100

    Create background subtracted, exposure corrected, and adaptively smoothed images in the three individual bands and a combined soft band.

     adapt_merge smoothingcounts=50 thresholdmasking=0.02 elowlist=400 \
      ehighlist=750 binning=2 withpartcontrol=yes withsoftcontrol=yes \
      withmaskcontrol=no

     adapt_merge smoothingcounts=50 thresholdmasking=0.02 elowlist=750 \
      ehighlist=1300 binning=2 withpartcontrol=yes withsoftcontrol=yes \
      withmaskcontrol=no

     adapt_merge smoothingcounts=50 thresholdmasking=0.02 elowlist='400 750' \
      ehighlist='750 1300' binning=2 withpartcontrol=yes withsoftcontrol=yes \
      withmaskcontrol=no

     adapt_merge smoothingcounts=50 thresholdmasking=0.02 elowlist=2000 \
      ehighlist=7200 binning=2 withpartcontrol=yes withsoftcontrol=yes \
      withmaskcontrol=no

    Rename the files.

     mv adapt-400-750.fits adapt-400-750-nps.fits
     mv adapt-750-1300.fits adapt-750-1300-nps.fits
     mv adapt-400-1300.fits adapt-400-1300-nps.fits
     mv adapt-2000-7200.fits adapt-2000-7200-nps.fits

    Then display the results.

     ds9 adapt-400-750-nps.fits adapt-750-1300-nps.fits adapt-400-1300-nps.fits \
      adapt-2000-7200-nps.fits &

     

    Figure 2: Merged EPIC adaptively smoothed image of the nearby galaxy M101 excluding
    point sources. Note that slightly extended sources and others may ne be removed.

  6. Make simple binned images.
     

     bin_image_merge thresholdmasking=0.02 elowlist='400 750' \
      ehighlist='750 1300' binning=8 withpartcontrol=yes withsoftcontrol=yes \
      withswcxcontrol=no withmaskcontrol=no

     bin_image_merge thresholdmasking=0.02 elowlist=400 ehighlist=750 binning=8 \
      withpartcontrol=yes withsoftcontrol=yes withswcxcontrol=no \
      withmaskcontrol=no

     bin_image_merge thresholdmasking=0.02 elowlist=750 ehighlist=1300 binning=8 \
      withpartcontrol=yes withsoftcontrol=yes withswcxcontrol=no \
      withmaskcontrol=no

     bin_image_merge thresholdmasking=0.02 elowlist=2000 ehighlist=7200 binning=8 \
      withpartcontrol=yes withsoftcontrol=yes withswcxcontrol=no \
      withmaskcontrol=no

    Then display the results.

     ds9 bin-400-750.fits bin-750-1300.fits bin-400-1300.fits bin-2000-7200.fits &

     

    Figure 3: Merged EPIC binned image of the nearby galaxy M101 excluding point
    sources. Note that slightly extended sources and others may ne be removed.
    Uncertainty maps are also produced.

  7. Create a merged source list from the individual ObsIDs.
     

     merge_source_list dirfile=dir-only.dat maxlikelim=15

  8. Use the merged source list to create individual masks. This requires jumping to the individual ObsID processing directories.
     

     cd ../0104260101/proc/
     make_mask_merge prefix=1S001 inmask=mos1S001-mask-im-750-1300.fits \
      srclist=../../merge/merged-source-list.fits flimtot=0.5 flimsoft=0.0 \
      flimhard=0.0 scale=0.5 seper=20 maxlikelim=15.0

     make_mask_merge prefix=2S006 inmask=mos2S006-mask-im-750-1300.fits \
      srclist=../../merge/merged-source-list.fits flimtot=0.5 flimsoft=0.0 \
      flimhard=0.0 scale=0.5 seper=20 maxlikelim=15.0

     make_mask_merge prefix=S005 inmask=pnS005-mask-im-750-1300.fits \
      srclist=../../merge/merged-source-list.fits flimtot=0.5 flimsoft=0.0 \
      flimhard=0.0 scale=0.5 seper=20 maxlikelim=15.0

     cd ../../0164560701/proc/
     make_mask_merge prefix=1S001 inmask=mos1S001-mask-im-750-1300.fits \
      srclist=../../merge/merged-source-list.fits flimtot=0.5 flimsoft=0.0 \
      flimhard=0.0 scale=0.5 seper=20 maxlikelim=15.0

     make_mask_merge prefix=2S002 inmask=mos2S002-mask-im-750-1300.fits \
      srclist=../../merge/merged-source-list.fits flimtot=0.5 flimsoft=0.0 \
      flimhard=0.0 scale=0.5 seper=20 maxlikelim=15.0

     make_mask_merge prefix=S003 inmask=pnS003-mask-im-750-1300.fits \
      srclist=../../merge/merged-source-list.fits flimtot=0.5 flimsoft=0.0 \
      flimhard=0.0 scale=0.5 seper=20 maxlikelim=15.0

     cd ../../0212480201/proc/
     make_mask_merge prefix=1S001 inmask=mos1S001-mask-im-750-1300.fits \
      srclist=../../merge/merged-source-list.fits flimtot=0.5 flimsoft=0.0 \
      flimhard=0.0 scale=0.5 seper=20 maxlikelim=15.0

     make_mask_merge prefix=2S002 inmask=mos2S002-mask-im-750-1300.fits \
      srclist=../../merge/merged-source-list.fits flimtot=0.5 flimsoft=0.0 \
      flimhard=0.0 scale=0.5 seper=20 maxlikelim=15.0

     make_mask_merge prefix=S003 inmask=pnS003-mask-im-750-1300.fits \
      srclist=../../merge/merged-source-list.fits flimtot=0.5 flimsoft=0.0 \
      flimhard=0.0 scale=0.5 seper=20 maxlikelim=15.0

     cd ../../merge

  9. Merge the various components, this time with point sources excluded using the merged source list.
     

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=1 elow=400 \
      ehigh=750 maskcontrol=3 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=2 elow=400 \
      ehigh=750 maskcontrol=3 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=3 elow=400 \
      ehigh=750 maskcontrol=3 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=4 elow=400 \
      ehigh=750 maskcontrol=3 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=1 elow=750 \
      ehigh=1300 maskcontrol=3 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=2 elow=750 \
      ehigh=1300 maskcontrol=3 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=3 elow=750 \
      ehigh=1300 maskcontrol=3 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=4 elow=750 \
      ehigh=1300 maskcontrol=3 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=1 elow=2000 \
      ehigh=7200 maskcontrol=3 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=2 elow=2000 \
      ehigh=7200 maskcontrol=3 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=3 elow=2000 \
      ehigh=7200 maskcontrol=3 xdim=1100 ydim=1100

     merge_comp_xmm caldb=/XMM/sas/CCF/esas/ dirfile=dir.dat coord=2 \
      crvaln1=210.85 crvaln2=54.35 pixelsize=0.03 component=4 elow=2000 \
      ehigh=7200 maskcontrol=3 xdim=1100 ydim=1100

    Create backgruond subtracted, exposure corrected, and adaptively smoothed images in the three individual bands and a combined soft band.

     adapt_merge smoothingcounts=50 thresholdmasking=0.02 elowlist=400 \
      ehighlist=750 binning=2 withpartcontrol=yes withsoftcontrol=yes \
      withmaskcontrol=no

     adapt_merge smoothingcounts=50 thresholdmasking=0.02 elowlist=750 \
      ehighlist=1300 binning=2 withpartcontrol=yes withsoftcontrol=yes \
      withmaskcontrol=no

     adapt_merge smoothingcounts=50 thresholdmasking=0.02 elowlist='400 750' \
      ehighlist='750 1300' binning=2 withpartcontrol=yes withsoftcontrol=yes \
      withmaskcontrol=no

     adapt_merge smoothingcounts=50 thresholdmasking=0.02 elowlist=2000 \
      ehighlist=7200 binning=2 withpartcontrol=yes withsoftcontrol=yes \
      withmaskcontrol=no

    Rename the files.

     mv adapt-400-750.fits adapt-400-750-mnps.fits
     mv adapt-750-1300.fits adapt-750-1300-mnps.fits
     mv adapt-400-1300.fits adapt-400-1300-mnps.fits
     mv adapt-2000-7200.fits adapt-2000-7200-mnps.fits

    Then display the results.

     ds9 adapt-400-750-mnps.fits adapt-750-1300-mnps.fits adapt-400-1300-mnps.fits \
      adapt-2000-7200-mnps.fits &

     

    Figure 4: Merged EPIC adaptively smoothed image of the nearby galaxy
    M101 excluding point sources from the merged source list. This time
    the point-source exclusion may have been a bit overly enthusiastic.

     


 

Caveats

For information about known issues, refer to the ESAS Warnings and Watchouts pages.