Skip banner and navigation tools.

 |  site map

Skip sidebars of related page links.

Extracting spectra using XSELECT

Here we demonstrate how to extract source and background spectra and make them suitable for fitting in XSPEC.

Alternatively, use the online tool to build spectra etc. This is almost always the better option for point sources!

The PC data from the first observation of GRB 091109A are used as an example.

           **  XSELECT V2.2a  ** 

> Enter session name >[xsel]
xsel:ASCA > read event
> Enter the Event file dir >[ ] ./
> Enter Event file list >[ ] sw00375246000xpcw3po_cl.evt

Got new mission: SWIFT
> Reset the mission ? >[yes]

Notes: XSELECT set up for      SWIFT
 Time keyword is TIME       in units of s
 Default timing binsize =   5.0000

 Image  keywords   = X          Y           with binning =    1
 WMAP   keywords   = X          Y           with binning =    1
 Energy keyword   = PI                     with binning =    1

Getting Min and Max for Energy Column...
Got min and max for PI:     0   1023

Got the minimum time resolution of the read data:   2.5073
MJDREF =  5.1910000742870E+04 with TIMESYS = TT
 Number of files read in:            1

******************** Observation Catalogue ********************

Data Directory is: /home/work/kpa/2009/grb091109a/00375246000-xrt/
HK Directory is: /home/work/kpa/2009/grb091109a/003752460001-xrt/

        OBJECT      OBS_ID      DATE-OBS    DATAMODE
      1 Burst (309. 00375246000 2009-11-09T PHOTON

> extract image

extractor v5.11    11 May 2009
 Getting FITS WCS Keywords
 Doing file: /home/work/kpa/2009/grb091109a/00375246000-xrt/sw00375246000xpcw3po_cl.evt
100% completed
          Total      Good    Bad: Time     Phase     Grade       Cut
           4165      4165            0         0         0         0
    Grand Total      Good    Bad: Time     Phase     Grade       Cut
           4165      4165            0         0         0         0
   in  12496.     seconds
 Image            has     4165 counts for 0.3333     counts/sec

> plot image
PC image
XSELECT output

Source and background regions should be defined within ds9 (examples). The region can be of any shape, though must be centred on the source; note that circular regions can be used for both WT and PC modes. If xrtpipeline was run with cleanup=no, the region produced (a 20 pixel radius circle) can be used if the source is not piled-up; if the source is bright, a 30-pixel radius may be a more suitable choice, whereas faint sources are better extracted using smaller areas.

In the case of this example dataset, the first snapshot of data is piled-up, such that the central 3-pixels should be excluded. See the pile-up walk-through for a complete step-by-step guide. To change the shape of the region from a default circle, click on the region button at the top of the ds9 window, move down to the "shape" option and pick annulus.

Note that, if the source lies over the bad columns, it may be difficult to determine by eye where the extraction region should be centred. If the coordinates of the source are known, it is often better to input these directly (click on the image in the ds9 field of view, to bring up a circle, then double click on the circle to bring up a box listing the position and radius. Set the coordinates to WCS and then either input the decimal degrees, or change the option to sexagesimal), since correction factors can vary significantly if the region is poorly placed with respect to the bad columns.

It is a good idea to use a larger region to extract the background spectrum (or light-curve) when using PC data, to get a better average value. A larger circle (radius of 50-60 pixels), multiple small circle or a large annulus centred on the source are all suitable options. Just make sure to avoid any field sources in the extraction region! For WT mode, the easiest method is to use the same size circle, just moved along (but still fully positioned inside) the window strip. Alternatively (and particularly useful if you have multiple WT observations at different roll angles, and don't want to keep redefining the background region), there is a different method.

It is also possible to extract a spectrum from combined event lists. These can be read into XSELECT, one after the other, before extracting the products. Expanding the above example, after reading in sw00375246000xpcw3po_cl.evt, and before extracting the image, you could continue with:

> read event sw00375246001xpcw3po_cl.evt.gz
> read event sw00375246002xpcw3po_cl.evt.gz
> read event sw00375246003xpcw3po_cl.evt.gz
> extract event copyall=yes 

Note, however, that if some of the data are piled-up and others aren't, you do still need to account for the pile-up, and it may be better to extract individual spectra and then combine them, to avoid having to throw away useful data. Of course, the online product generator will do all this for you!

Assuming the source extraction region is called ann.reg and the background, bgd.reg, then the following commands will result in the required spectra:

> filter region ann.reg
> extract spectrum
> save spectrum PC.pi
> clear region
> filter region bgd.reg
> extract spectrum
> save spectrum PCback.pi

The exposure map and ARF threads explain how to create a suitable ARF and how to determine the relevant RMF to use. This spectrum can then be passed through grppha to make it suitable for use in XSPEC.

> grppha
> Please enter PHA filename [ ] PC.pi
> Please enter output filename [ ] !PC.pi

  EXTNAME   - SPECTRUM        Name of this BINTABLE
  TELESCOP  - SWIFT           Mission/Satellite name
  INSTRUME  - XRT             Instrument/Detector
  FILTER    - NONE            Instrument filter in use
  EXPOSURE  - 12446.          Integration time (in secs) of PHA data
  AREASCAL  - 1.0000          Area scaling factor
  BACKSCAL  - 1.22400E-03     Background scaling factor
  BACKFILE  - none            Associated background file
  CORRSCAL  - 1.0000          Correlation scaling factor
  CORRFILE  - none            Associated correlation file
  RESPFILE  - none            Associated redistribution matrix file
  ANCRFILE  - none            Associated ancillary response file
  POISSERR  - TRUE            Whether Poissonian errors apply
  CHANTYPE  - PI              Whether channels have been corrected
  TLMIN1    - 0               First legal Detector channel
  DETCHANS  - 1024            No. of legal detector channels
  NCHAN     - 1024            No. of detector channels in dataset
  PHAVERSN  - 1.2.0           OGIP FITS version number
  STAT_ERR  - FALSE           Statistical Error
  SYS_ERR   - FALSE           Fractional Systematic Error
  QUALITY   - TRUE            Quality Flag
  GROUPING  - FALSE           Grouping Flag
GRPPHA [] bad 0-29
GRPPHA [] group min 1
GRPPHA [] chkey backfile PCback.pi
GRPPHA [] chkey ancrfile PC.arf
GRPPHA [] chkey respfile swxpc0to12s6_20010101v011.rmf
GRPPHA [] exit
 ... written the PHA data Extension
 ...... exiting, changes written to file : PC.pi
 ** grppha 3.0.1 completed successfully

Prefacing the spectral name with an exclamation mark over-writes the original file. The above commands entered within grppha set the binning of the spectrum. (All the commands can be undone if the users changes their mind: reset all unsets the binning commands.) XRT data should not be fitted below 0.3 keV, hence the first 30 channels are set to being "bad" (bad 0-29). group min 1 ensures there is at least 1 count per bin; this is required for fitting with Cash-statistics, which is generally advised (see Humphrey et al. 2009). statistic cstat should then be set within XSPEC, before fitting the spectra. If the user prefers to use χ2 fitting, then group min 20 should be used instead.

In addition, the relevant ARF (PC.arf), RMF(swxpc0to12s6_20010101v011.rmf) and background (PCback.pi) files have been set. See the ARF thread for details.

As described in the release note, a systematic error of about 3 percent is needed for high statistical quality spectra (generally sources bright in WT mode). In PC mode, the statistical error usually dominates. Systematic errors may not be accounted for when fitting using cstat, however.

This spectrum is now ready for fitting in XSPEC, though please see this comment on the BACKSCAL keyword for WT spectra.