Skip to the navigation links
Last modified: 14 Jan 2009
Where are the PDFs?

Add Grating Spectra and Average ARFs

CIAO 4.2 Science Threads


Last Update: 14 Jan 2009 - updated for CIAO 4.2: ObsID 459 file versions and corresponding minor changes to screen output


add_grating_spectra is a script which lets the user add two grating spectra and average their 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 generate and group two coadded grating spectra and ARFs.

Read this thread if:

you are working with ACIS/HETG, ACIS/LETG, or HRC/LETG observational data and would like to add the grating orders.

Related Links:


Get Started

Sample ObsIDs used: 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.

Downloading add_grating_spectra

The thread uses the add_grating_spectra script, which is part of the CIAO Scripts distribution. The CIAO scripts package should be the following version or newer:

17 Apr 2009

Please check that you have at least this version of the scripts package installed before continuing. If you do not have the scripts installed or need to update to a newer version, refer to the Scripts page.

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

Return to Threads Page: Top | All | Grating

Where are the PDFs?
Last modified: 14 Jan 2009