Last modified: 13 Jan 2022

URL: https://cxc.cfa.harvard.edu/ciao/threads/add_grating_orders/

Extract Coadded and Grouped Nth-Order Source & Background Spectra and ARFs

CIAO 4.16 Science Threads


Overview

Synopsis:

This thread shows how to use the combine_grating_spectra script to combine the positive and negative orders in a Chandra grating dataset.

Purpose:

To create a coadded positive and negative order grating spectrum and ARF for ACIS/HETG, ACIS/LETG, or HRC/LETG data.

Related Links:

Last Update: 13 Jan 2022 - Reviewed for CIAO 4.14. No changes


Contents


Get Started

Download the sample data: 8986 (ACIS-S/HETG, H 1743-322)

The rest of this thread assumes that the data have been reprocessed with chandra_repro and/or the input ARF and RMF files have been created with the mktgresp script.

unix% /bin/ls repro/*
repro/acisf08986_001N003_bpix1.fits  repro/acisf08986_repro_evt2.fits
repro/acisf08986_001N003_fov1.fits   repro/acisf08986_repro_flt2.fits
repro/acisf08986_001N003_msk1.fits   repro/acisf08986_repro_fov1.fits
repro/acisf08986_001N003_mtl1.fits   repro/acisf08986_repro_pha2.fits
repro/acisf08986_001N003_stat1.fits  repro/acisf08986_tgmask.fits
repro/acisf08986_asol1.lis           repro/acisf320289394N003_pbk0.fits
repro/acisf08986_evt1a.fits          repro/pcadf08986_001N001_asol1.fits
repro/acisf08986_repro_bpix1.fits

repro/tg:
acisf08986_repro_heg_m1.arf      acisf08986_repro_meg_m1.arf
acisf08986_repro_heg_m1.pha      acisf08986_repro_meg_m1.pha
acisf08986_repro_heg_m1.rmf      acisf08986_repro_meg_m1.rmf
acisf08986_repro_heg_m1_bkg.pha  acisf08986_repro_meg_m1_bkg.pha
acisf08986_repro_heg_m2.pha      acisf08986_repro_meg_m2.pha
acisf08986_repro_heg_m2_bkg.pha  acisf08986_repro_meg_m2_bkg.pha
acisf08986_repro_heg_m3.pha      acisf08986_repro_meg_m3.pha
acisf08986_repro_heg_m3_bkg.pha  acisf08986_repro_meg_m3_bkg.pha
acisf08986_repro_heg_p1.arf      acisf08986_repro_meg_p1.arf
acisf08986_repro_heg_p1.pha      acisf08986_repro_meg_p1.pha
acisf08986_repro_heg_p1.rmf      acisf08986_repro_meg_p1.rmf
acisf08986_repro_heg_p1_bkg.pha  acisf08986_repro_meg_p1_bkg.pha
acisf08986_repro_heg_p2.pha      acisf08986_repro_meg_p2.pha
acisf08986_repro_heg_p2_bkg.pha  acisf08986_repro_meg_p2_bkg.pha
acisf08986_repro_heg_p3.pha      acisf08986_repro_meg_p3.pha
acisf08986_repro_heg_p3_bkg.pha  acisf08986_repro_meg_p3_bkg.pha

Run combine_grating_spectra

In this example, the first order MEG source and background spectra and response files are combined using the combine_grating_spectra script.

unix% punlearn combine_grating_spectra
unix% pset combine_grating_spectra infile=repro/acisf08986_repro_pha2.fits 
unix% pset combine_grating_spectra outroot=repro/8986
unix% pset combine_grating_spectra add_plusminus=yes
unix% pset combine_grating_spectra garm=MEG
unix% pset combine_grating_spectra order=1
unix% pset combine_grating_spectra arf="repro/tg/*meg*.arf"
unix% pset combine_grating_spectra rmf="repro/tg/*meg*.rmf"

A stack of arf and rmf files must be specified for the tool to locate them; however, users can provide a superset of file names and the tool will only use the files it needs. In this example all 3 MEG orders are supplied using the UNIX "*" wildcard. The order of the arf and rmf file names is arbitrary.

Also note that since add_plusminus=yes, only order=1 is required. When add_plusminus=yes the tool treats the order as an absolute value.

With the parameters set, the tool is then run:

unix% combine_grating_spectra 
Source PHA1/PHA2 grating spectra to combine; enter list or '@stack' (repro/acisf08986_repro_pha2.fits): 
Root name for output file(s) (repro/8986): 
Input TYPE:II pha file(s).  The output will be one or more TYPE:I pha files
Splitting TYPE:II pha files into TYPE:I
Combining spectra across observations
Prepared to combine 1 spectra

source PHA: repro/8986_tmp00_meg_p1.pha
       ARF: repro/tg/acisf08986_repro_meg_p1.arf
       RMF: repro/tg/acisf08986_repro_meg_p1.rmf
    background PHA: repro/8986_tmp00_meg_p1_bkg.pha
               ARF: None
               RMF: None

The following files were created:
  repro/8986_meg_p1.pha
  repro/8986_meg_p1_bkg.pha
  repro/8986_meg_p1.arf
  repro/8986_meg_p1.rmf
Prepared to combine 1 spectra

source PHA: repro/8986_tmp00_meg_m1.pha
       ARF: repro/tg/acisf08986_repro_meg_m1.arf
       RMF: repro/tg/acisf08986_repro_meg_m1.rmf
    background PHA: repro/8986_tmp00_meg_m1_bkg.pha
               ARF: None
               RMF: None

The following files were created:
  repro/8986_meg_m1.pha
  repro/8986_meg_m1_bkg.pha
  repro/8986_meg_m1.arf
  repro/8986_meg_m1.rmf
Combining plus and minus orders
Prepared to combine 2 spectra

source PHA: repro/8986_meg_p1.pha
       ARF: repro/8986_meg_p1.arf
       RMF: repro/8986_meg_p1.rmf
    background PHA: repro/8986_meg_p1_bkg.pha
               ARF: None
               RMF: None
source PHA: repro/8986_meg_m1.pha
       ARF: repro/8986_meg_m1.arf
       RMF: repro/8986_meg_m1.rmf
    background PHA: repro/8986_meg_m1_bkg.pha
               ARF: None
               RMF: None

The following files were created:
  repro/8986_meg_abs1.pha
  repro/8986_meg_abs1_bkg.pha
  repro/8986_meg_abs1.arf
  repro/8986_meg_abs1.rmf
Created output source spectrum 'repro/8986_meg_abs1.pha'
    with background spectrum 'repro/8986_meg_abs1_bkg.pha'
    with source ARF 'repro/8986_meg_abs1.arf'
    with source RMF 'repro/8986_meg_abs1.rmf'

The verbose output above shows how the script combines the data. First it combines data across observations, which is only 1 in this example, and then combines the positive and negative orders together.

The output spectrum, repro/8986_meg_abs1.pha, can be loaded directly into sherpa or can be grouped with dmgroup, though in general the CXC does not recommend grouping grating spectra.

Should data be combined?

Given the sharp detector edges and other discontinuities in the responses, the CXC generally advocates that user not routinely combine spectra. Users are encouraged to analyze their data simultaneously.


Summary

The thread is now complete. The coadded 1st-order spectra are contained in the PHA1-like file named repro/8986_meg_abs1.pha

To load this data into Sherpa, see the Introduction to Fitting PHA Spectra thread.


History

14 Dec 2004 updated for CIAO 3.2: created Downloading add_grating_orders section
06 Dec 2005 reviewed for CIAO 3.3: no changes
01 Dec 2006 reviewed for CIAO 3.4: no changes
23 Jan 2008 updated for CIAO 4.0: add_grating_orders v2.0 (specify an output block name of "SPECTRUM" in the dmtype2split commands, kernel parameter removed from dmtcalc and dmpaste); Sherpa syntax updated; Sherpa link points to Beta website
30 May 2008 add_grating_orders v2.6 (Unix head and tail commands replaced by pget and dmkeypar)
06 Jun 2008 added How to handle the RMFs section
12 Feb 2009 reviewed for CIAO 4.1: no changes
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
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
12 Dec 2014 Updated for CIAO 4.7. The thread has been rewritten to make use of the combine_grating_spectra script.
15 Dec 2015 Updated for CIAO 4.8. No changes.
23 Dec 2016 Review for CIAO 4.9. No changes.
09 Aug 2021 Updated for CIAO 4.13, CALDB 4.9.5, and Repro-5 updates.
13 Jan 2022 Reviewed for CIAO 4.14. No changes