Chandra X-Ray Observatory
Skip to the navigation links
Last modified: 25 Nov 2013


Add Grating Spectra and Average ARFs

CIAO 4.6 Science Threads



The add_grating_spectra script adds two grating spectra and averages the associated ARFs. The output spectrum can be grouped if desired. It can be used, for example, to add spectra of sources from different observations.


To create coadded grating spectra and ARFs for ACIS/HETG, ACIS/LETG, or HRC/LETG observational data.

Related Links:

Last Update: 25 Nov 2013 - Review for CIAO 4.6. No changes.


Get Started

Download the sample data: 459 (HETG/ACIS-S, 3C 273); 2463 (HETG/ACIS-S, 3C 273)

To run this thread, you need two PHA grating spectra and the corresponding ARFs:

unix% ls
2463_MEG_1.arf          459_MEG_1.arf
2463_MEG_1_NONE.pha     459_MEG_1_NONE.pha

Both observations must have been taken with the same instrumental configuration:


The files used here were created with the Extract Coadded and Grouped Nth-Order Source & Background Spectra and ARFs thread.

How to handle the RMFs

The RMF files for the observations should not be summed, and so they must be considered before adding the spectra together.

If the data being used are all near on-axis (as they usually are for gratings), then the RMFs made for one observation can be used for the summed spectrum file.

If RMFs are different enough to matter, then the spectra should not be summed at all. Analyze the spectra simultaneously instead. Note that RMFs are nearly indistinguishable for ACIS/HETG, but they might differ near plate boundaries for LETG data.

Note: The combine_grating_spectra script does combine input RMFs when associated ARFs are also available (it writes an ARF- and exposure-weighted summed RMF), however the caveats listed above still apply.

Run add_grating_spectra

The script executes the following tools in order:

  1. dmtcalc: to rename columns and perform math on them in temporary PHA and ARF files.
  2. dmpaste: to merge the final columns into the output PHA and ARF files.
  3. dmgroup: to group the final PHA file.
  4. dmhedit: to update header keywords of the output files.

In this example, we are summing together the first-order MEG arms of HETG spectra and the corresponding gARFs:

unix% punlearn add_grating_spectra
unix% pset add_grating_spectra pha1=2463_MEG_1_NONE.pha
unix% pset add_grating_spectra pha2=459_MEG_1_NONE.pha
unix% pset add_grating_spectra garf1=2463_MEG_1.arf
unix% pset add_grating_spectra garf2=459_MEG_1.arf
unix% pset add_grating_spectra gtype=BIN
unix% pset add_grating_spectra gspec=10
unix% pset add_grating_spectra root=3C273_summed

unix% add_grating_spectra
First input PHA spectrum (2463_MEG_1_NONE.pha): 
Second input PHA spectrum (459_MEG_1_NONE.pha): 
First input ARF (2463_MEG_1.arf): 
Second input ARF (459_MEG_1.arf): 
Root name for output files (3C273_summed): 

Input pha1 file is: 2463_MEG_1_NONE.pha (INSTRUMENT=ACIS-MEG, ORDER=1)
Input pha2 file is: 459_MEG_1_NONE.pha (INSTRUMENT=ACIS-MEG, ORDER=1)
Using ACIS-MEG grating ARF order 1: 2463_MEG_1.arf
Using ACIS-MEG grating ARF order 1: 459_MEG_1.arf
The root filename for the output files is: 3C273_summed

Exposure(2463_MEG_1_NONE.pha) = 26688.950683895
Exposure(459_MEG_1_NONE.pha) = 38663.461139311
New Exposure = 65352.411823206

BACKSCUP(2463_MEG_1_NONE.pha) = 4.50
BACKSCDN(2463_MEG_1_NONE.pha) = 4.50
BACKSCUP(459_MEG_1_NONE.pha) = 4.50
BACKSCDN(459_MEG_1_NONE.pha) = 4.50
New BACKSCUP = 4.50
New BACKSCDN = 4.50

ACIS-MEG 3C273_summed_ACIS-MEG_1.pha will be grouped by 10 = .0500000000 Angstrom

The output spectrum is named     3C273_summed_ACIS-MEG_1_BIN10.pha
The Averaged Effective Area is named 3C273_summed_ACIS-MEG_1.arf

The content of the parameter file may be checked using plist add_grating_spectra.


The thread is now complete. The output containing the summed counts from both input PHA files is 3C273_summed_ACIS-MEG_1_BIN10.pha; the averaged effective area is named 3C273_summed_ACIS-MEG_1.arf.

To load this data into Sherpa:

sherpa> load_data("3C273_summed_ACIS-MEG_1_BIN10.pha")
sherpa> load_arf("3C273_summed_ACIS-MEG_1.arf")

See the Introduction to Fitting PHA Spectra thread for more information.

Parameters for /home/username/cxcds_param/add_grating_spectra.par

          pha1 = 2463_MEG_1_NONE.pha First input PHA spectrum
          pha2 = 459_MEG_1_NONE.pha Second input PHA spectrum
         garf1 = 2463_MEG_1.arf   First input ARF
         garf2 = 459_MEG_1.arf    Second input ARF
          root = 3C273_summed     Root name for output files
        (gtype = BIN)             Spectrum grouping type
        (gspec = 10)              Spectrum grouping specs (NONE,10,etc)
      (clobber = no)              Clobber existing output files?
      (verbose = 0)               Debug Level(0-5)
         (mode = ql)              


14 Dec 2004 updated for CIAO 3.2: created Downloading add_grating_spectra section
06 Dec 2005 reviewed for CIAO 3.3: no changes
01 Dec 2006 reviewed for CIAO 3.4: no changes
04 Feb 2008 updated for CIAO 4.0: add_grating_spectra v3.4 (several broken Unix "tail" commands were replaced with the CIAO tool dmkeypar); links point to Sherpa Beta website
30 May 2008 add_grating_spectra v3.6 (Unix head and tail commands replaced by pget and dmkeypar)
06 Jun 2008 added How to handle the RMFs section
12 Feb 2009 updated for CIAO 4.1: minor change to exposure value in screen output, due to file reprocessing
06 May 2009 check the version of the CIAO scripts package instead of the individual script
14 Jan 2009 updated for CIAO 4.2: ObsID 459 file versions and corresponding minor changes to screen output
12 Jan 2011 reviewed for CIAO 4.3: no changes
09 Jan 2012 reviewed for CIAO 4.4: no changes
03 Dec 2012 Review for CIAO 4.5; no changes
25 Nov 2013 Review for CIAO 4.6. No changes.

Last modified: 25 Nov 2013
Smithsonian Institute Smithsonian Institute

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email: Smithsonian Institution, Copyright © 1998-2014. All rights reserved.