Published on December 07, 2022 by LeaMarcotulli

6 min READ

Swift-XRT is an X-ray instrument that explores the soft X-ray band (from 0.1-10 keV). Detailed information and step-by-step analysis threads can be found here. Note that all the info detailed below are taken from the same website.

Source : Swift XRT Analysis Threads

Prerequisites

Before you get started with XRT analysis, you need to install the necessary software. Therefore, please go ahead and install HEASOFT. Select Source Code (and pick your operating system) and Swift (all relevant packages will be selected for you). Then you want the XRT calibration files (CALDB, and please make sure update them every 6 months or so).

NOTE 1: If you already know that you are going to use other X-ray satellites listed in the website, do yourself a favor and select them already from the list. Otherwise you will need to reinstall HEASOFT from stratch next time.

NOTE 2: Beware, you are surely going to struggle through this process. But once you’ve done it once, broke your computer, cried to your advisor, and wondered if it’s really worth it, you will know how to do this for the rest of your carreer.

Requirements

  • HEASOFT download page latest version
  • CALDB
  • Familiarity with basic bash commands (create/remove directories, navigate in your folders/subfolders, open/edit files from Terminal)

Dealing with XRT data

  1. Download the desired observation from here: insert the name of your source, select Swift from the list of instruments, check archived observations, click on the desired observation(s) and unselect BAT and UVOT from the list, download the products. Note that the FoV fof XRT is about 11’’, so if the center of the observation is further than that, then your source is not in the field. Pointless to analyse it. [INSERT IMAGE]
  2. Make sure you organize your directory structure neatly (e.g. Source Name –> Observations –> XRT –> obs number; Year –> Project –> Source –> Data –> XRT –> obs number; etc). You can pick your own system but BE NEAT so that both you and your advisor can easily find the necessary documents when needed. All XRT observations will be downloaded whose name is a number (e.g. 00030352011) which is the observation ID.
  3. Proceed to analyse the observation. From Terminal, go to the directory that contains the observation. For this example, I have downloaded one observation of MrK 421 and places it in my Project/Tutorial directory. So from my Terminal:

cd /home/lea/Project/Tutorial/Mrk_421/Data/XRT/

  1. (Assuming you have initialized heasoft and caldb)
  2. First thing you need to run is xrtpipeline. You can do this either interactively, typing xrtpipeline in the terminal and follow the prompts. Or you can condesate it all in one command line. So in your Terminal:

Generic: xrtpipeline indir=obsnumber outdir=./out(or whatever name you choose for the output folder) steminputs=swobsnumber srcra=OBJECT srcdec=OBJECT
For this example: xrtpipeline indir=00030352011/ outdir=./xrtout_00030352011 steminputs=sw00030352011 srcra=OBJECT srcdec=OBJECT

  1. This step has created a folder called xrtout_00030352011/ (which if you type ls if you Terminal should be listed) that contains the first level filter data. Now, enter this directory:

Generic: cd out(or whatever name you choose for the output folder)
For this example: cd xrtout_00030352011/

  1. As for many X-ray images, a big problem is that the level of the background is very high and the PSF is very large (for example if compared with the milliarcsecond resolution of radio images). Therefore, we need to know the background level in order to be able to subtract it from our source image, and get the best data products. Therefore, we are going to open the XRT image and (i) identify our source (ii) select a background region. For XRT, we are going to do all of this within xselect. In your Terminal type:

xselect
Enter session name >[xsel8479](hit ENTER)
read events swobsid (for this example: read events sw00030352011)
Reset the mission? > [yes] (hit ENTER)
extract image
plot image (this will open the image in ds9. Select a circle region around your source of few arcsec (10-15”) and name it source.reg. Then select an annulus background centered on your source and save it as bkg.reg. Close ds9 and go back to your terminal.)
filter region src.reg
extract spectrum
save spectrum src.pha
clear region
filter region bkg.reg
extract spectrum
save spectrum bkg.pha
clear region
exit
no

  1. The two .pha files you have created are the source and region backround spectra. If you noticed, xselect has already printed a lot of information about them for you. Read carefully the output of every command you ever type in your Terminal, and you will see a lot of information is already served to you on a silver platter.
  2. Another file you need is the ancillary response file, or arf. xrtpipeline does not provide one for you, so you need to create it using xrtmkarf. The following commands have to be used:

Generic: xrtmkarf expofile=swobsidxpcw2po_ex.img phafile=src.pha srcx=-1 srcy=-1 psfflag=yes outfile=out.arf(or whatever name you choose)
For this example: xrtmkarf expofile=sw00030352011xpcw2po_ex.img phafile=src.pha srcx=-1 srcy=-1 psfflag=yes outfile=xrtout.arf

  1. Finally, before you can deal with the X-ray spectra analysis (NOT PART OF THIS TUTORIAL), you want to bin your spectrum. If the source is very bright, you can go up to 15/20 counts per bin, but if very faint you go very low. The minimum you should use is 3 counts per bin. Before you bin your spectrum, make sure to locate and save the path to the latest xrt CALDB file (look for swxpc0to12s6_20130101v014.rmf). Once you have it go:

Generic: ` grppha infile=’src.pha’ outfile=’reb15.pha(or whatever name you choose)’ comm=’chkey ancrfile out.arf(or whatever name you chose)&chkey backfile bkg.pha&chkey respfile /savedpathtofile/swxpc0to12s6_20130101v014.rmf&group min 15&exit’<br> For this example: grppha infile=’src.pha’ outfile=’reb15_xrt.pha’ comm=’chkey ancrfile xrtout.arf&chkey backfile bkg.pha&chkey respfile /home/lea/Software/caldb/data/swift/xrt/cpf/rmf/swxpc0to12s6_20130101v014.rmf&group min 15&exit’`

NOTE: like before if you simply type grppha in your terminal, few prompts will show up and you can insert the same information as listed above one by one. It is important you remember to add to your .pha file the missing information about where to find the background file spectrum (chkey backfile), the ancillarey response file (chkey ancrfile) AND the instrument response file (chkey respfile).

Now you are good! You have your cleaned and rebinned XRT spectrum (reb15_xrt.pha), and you are ready to use XSPEC to extract all relevant X-ray spectral information!