Chandra X-Ray Observatory
	(CXC)
Skip to the navigation links
Last modified: 15 Dec 2014

URL: http://cxc.harvard.edu/ciao/threads/add_grating_spectra/

Add Grating Spectra and Average ARFs

CIAO 4.7 Science Threads


Overview

Synopsis:

The combine_grating_spectra script adds an arbitrary number of grating spectra and creates averaged response files (ARF and RMF). The output spectrum can be grouped if desired. It can be used, for example, to add spectra of sources from different observations.

[NOTE]
Changes in CIAO 4.7: add_grating_spectra?

The add_grating_spectra script has been replaced by the more general combine_grating_spectra tool.

Purpose:

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

Related Links:

Last Update: 15 Dec 2014 - Updated for CIAO 4.7. Now uses combine_grating_spectra. New datasets are used.


Contents


Get Started

Download the sample data: 8985 (ACIS-S/HETG, H1743-322); 8986 (ACIS-S/HETG, H1743-322)

unix% download_chandra_obsid 8985,8986 

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 898?/repro/*
8985/repro/acisf08985_001N002_bpix1.fits
8985/repro/acisf08985_001N002_fov1.fits
8985/repro/acisf08985_001N002_msk1.fits
8985/repro/acisf08985_001N002_mtl1.fits
8985/repro/acisf08985_001N002_stat1.fits
8985/repro/acisf08985_asol1.lis
8985/repro/acisf08985_evt1a.fits
8985/repro/acisf08985_repro_bpix1.fits
8985/repro/acisf08985_repro_evt2.fits
8985/repro/acisf08985_repro_fov1.fits
8985/repro/acisf08985_repro_pha2.fits
8985/repro/acisf08985_tgmask.fits
8985/repro/acisf319781625N002_pbk0.fits
8985/repro/pcadf319779046N002_asol1.fits

8986/repro/acisf08986_001N002_bpix1.fits
8986/repro/acisf08986_001N002_fov1.fits
8986/repro/acisf08986_001N002_msk1.fits
8986/repro/acisf08986_001N002_mtl1.fits
8986/repro/acisf08986_001N002_stat1.fits
8986/repro/acisf08986_asol1.lis
8986/repro/acisf08986_evt1a.fits
8986/repro/acisf08986_repro_bpix1.fits
8986/repro/acisf08986_repro_evt2.fits
8986/repro/acisf08986_repro_fov1.fits
8986/repro/acisf08986_repro_pha2.fits
8986/repro/acisf08986_tgmask.fits
8986/repro/acisf320289394N002_pbk0.fits
8986/repro/pcadf320289352N002_asol1.fits

8985/repro/tg:
acisf08985_repro_heg_m1.arf  acisf08985_repro_meg_m1.arf
acisf08985_repro_heg_m1.rmf  acisf08985_repro_meg_m1.rmf
acisf08985_repro_heg_m2.arf  acisf08985_repro_meg_m2.arf
acisf08985_repro_heg_m2.rmf  acisf08985_repro_meg_m2.rmf
acisf08985_repro_heg_m3.arf  acisf08985_repro_meg_m3.arf
acisf08985_repro_heg_m3.rmf  acisf08985_repro_meg_m3.rmf
acisf08985_repro_heg_p1.arf  acisf08985_repro_meg_p1.arf
acisf08985_repro_heg_p1.rmf  acisf08985_repro_meg_p1.rmf
acisf08985_repro_heg_p2.arf  acisf08985_repro_meg_p2.arf
acisf08985_repro_heg_p2.rmf  acisf08985_repro_meg_p2.rmf
acisf08985_repro_heg_p3.arf  acisf08985_repro_meg_p3.arf
acisf08985_repro_heg_p3.rmf  acisf08985_repro_meg_p3.rmf

8986/repro/tg:
acisf08986_repro_heg_m1.arf  acisf08986_repro_meg_m1.arf
acisf08986_repro_heg_m1.rmf  acisf08986_repro_meg_m1.rmf
acisf08986_repro_heg_m2.arf  acisf08986_repro_meg_m2.arf
acisf08986_repro_heg_m2.rmf  acisf08986_repro_meg_m2.rmf
acisf08986_repro_heg_m3.arf  acisf08986_repro_meg_m3.arf
acisf08986_repro_heg_m3.rmf  acisf08986_repro_meg_m3.rmf
acisf08986_repro_heg_p1.arf  acisf08986_repro_meg_p1.arf
acisf08986_repro_heg_p1.rmf  acisf08986_repro_meg_p1.rmf
acisf08986_repro_heg_p2.arf  acisf08986_repro_meg_p2.arf
acisf08986_repro_heg_p2.rmf  acisf08986_repro_meg_p2.rmf
acisf08986_repro_heg_p3.arf  acisf08986_repro_meg_p3.arf
acisf08986_repro_heg_p3.rmf  acisf08986_repro_meg_p3.rmf

Run combine_grating_spectra

By default, each of the ACIS HETG pha2 file contains 12 different spectra: positive and negative first, second, and third orders for each the MEG and HEG grating arms. In this example two observations H1743-322 will are combined using combine_grating_spectra.

To make things easier stacks of input files are created.

unix% /bin/ls */repro/*pha2.fits > pha.lis
unix% /bin/ls */repro/tg/*arf > arf.lis
unix% /bin/ls */repro/tg/*rmf > rmf.lis

Since there are two ACIS/HETG pha2 files in the input there are a total of 24 RMF and ARF files in each of the arf and rmf list files. The combine_grating_spectra script will use the information in the headers to associate each of the RMFs and ARFs to the correct observation and spectrum (order and arm).

With the lists created, the combine_grating_spectra parameters can be set:

unix% pset combine_grating_spectra infile=@pha.lis
unix% pset combine_grating_spectra arf=@arf.lis
unix% pset combine_grating_spectra rmf=@rmf.lis
unix% pset combine_grating_spectra add_plusminus=yes
unix% pset combine_grating_spectra outroot=h1743-322

The default combine_grating_spectra will automatically combine all the grating orders and all the grating arms it finds in the input PHA2 files. In this example the positive and negative orders will also be combined. Now the tool can be executed

unix% combine_grating_spectra
Source PHA1/PHA2 grating spectra to combine; enter list or '@stack' (@pha.lis): 
Root name for output file(s) (h1743-322): 
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 2 spectra
...

Created output source spectrum 'h1743-322_meg_abs1.pha'
    with background spectrum 'h1743-322_meg_abs1_bkg.pha'
    with source ARF 'h1743-322_meg_abs1.arf'
    with source RMF 'h1743-322_meg_abs1.rmf'

Created output source spectrum 'h1743-322_meg_abs3.pha'
    with background spectrum 'h1743-322_meg_abs3_bkg.pha'
    with source ARF 'h1743-322_meg_abs3.arf'
    with source RMF 'h1743-322_meg_abs3.rmf'

Created output source spectrum 'h1743-322_heg_abs3.pha'
    with background spectrum 'h1743-322_heg_abs3_bkg.pha'
    with source ARF 'h1743-322_heg_abs3.arf'
    with source RMF 'h1743-322_heg_abs3.rmf'

Created output source spectrum 'h1743-322_heg_abs2.pha'
    with background spectrum 'h1743-322_heg_abs2_bkg.pha'
    with source ARF 'h1743-322_heg_abs2.arf'
    with source RMF 'h1743-322_heg_abs2.rmf'

Created output source spectrum 'h1743-322_meg_abs2.pha'
    with background spectrum 'h1743-322_meg_abs2_bkg.pha'
    with source ARF 'h1743-322_meg_abs2.arf'
    with source RMF 'h1743-322_meg_abs2.rmf'

Created output source spectrum 'h1743-322_heg_abs1.pha'
    with background spectrum 'h1743-322_heg_abs1_bkg.pha'
    with source ARF 'h1743-322_heg_abs1.arf'
    with source RMF 'h1743-322_heg_abs1.rmf'

There is a large amount of text output to the terminal as the tool combines each of the 12 spectrum from the two observations and then finally combines the positive and negative orders for each grating arm.


Examining the Output Files

The output is 6 pha files (one each arm for each order), with associated ARFs, RMFs, and background PHA files.

unix% /bin/ls h1743*
h1743-322_heg_abs1.arf      h1743-322_heg_abs3.arf      h1743-322_meg_abs2.arf
h1743-322_heg_abs1.pha      h1743-322_heg_abs3.pha      h1743-322_meg_abs2.pha
h1743-322_heg_abs1.rmf      h1743-322_heg_abs3.rmf      h1743-322_meg_abs2.rmf
h1743-322_heg_abs1_bkg.pha  h1743-322_heg_abs3_bkg.pha  h1743-322_meg_abs2_bkg.pha
h1743-322_heg_abs2.arf      h1743-322_meg_abs1.arf      h1743-322_meg_abs3.arf
h1743-322_heg_abs2.pha      h1743-322_meg_abs1.pha      h1743-322_meg_abs3.pha
h1743-322_heg_abs2.rmf      h1743-322_meg_abs1.rmf      h1743-322_meg_abs3.rmf
h1743-322_heg_abs2_bkg.pha  h1743-322_meg_abs1_bkg.pha  h1743-322_meg_abs3_bkg.pha

[New] (15 Dec 2014)

In CIAO 4.7, stacks of spectra can be loaded into sherpa and can be manipulated simultaneously using Data Stacks. Below stacks of pha files are specified using the "?" character as single character wildcard in the stack syntax.

unix% sherpa
-----------------------------------------------------
Welcome to Sherpa: CXC's Modeling and Fitting Package
-----------------------------------------------------
CIAO 4.7 Sherpa version 1 Thursday, December 4, 2014

sherpa> from sherpa.astro.datastack import *

sherpa> load_data("h1743-322_?eg_abs?.pha")
WARNING: systematic errors were not found in file 'h1743-322_heg_abs1.pha'
statistical errors were found in file 'h1743-322_heg_abs1.pha' 
but not used; to use them, re-read with use_errors=True
read ARF file h1743-322_heg_abs1.arf
read RMF file h1743-322_heg_abs1.rmf
read background file h1743-322_heg_abs1_bkg.pha
WARNING: systematic errors were not found in file 'h1743-322_heg_abs2.pha'
statistical errors were found in file 'h1743-322_heg_abs2.pha' 
but not used; to use them, re-read with use_errors=True
read ARF file h1743-322_heg_abs2.arf
read RMF file h1743-322_heg_abs2.rmf
read background file h1743-322_heg_abs2_bkg.pha
WARNING: systematic errors were not found in file 'h1743-322_heg_abs3.pha'
statistical errors were found in file 'h1743-322_heg_abs3.pha' 
but not used; to use them, re-read with use_errors=True
read ARF file h1743-322_heg_abs3.arf
read RMF file h1743-322_heg_abs3.rmf
read background file h1743-322_heg_abs3_bkg.pha
WARNING: systematic errors were not found in file 'h1743-322_meg_abs1.pha'
statistical errors were found in file 'h1743-322_meg_abs1.pha' 
but not used; to use them, re-read with use_errors=True
read ARF file h1743-322_meg_abs1.arf
read RMF file h1743-322_meg_abs1.rmf
read background file h1743-322_meg_abs1_bkg.pha
WARNING: systematic errors were not found in file 'h1743-322_meg_abs2.pha'
statistical errors were found in file 'h1743-322_meg_abs2.pha' 
but not used; to use them, re-read with use_errors=True
read ARF file h1743-322_meg_abs2.arf
read RMF file h1743-322_meg_abs2.rmf
read background file h1743-322_meg_abs2_bkg.pha
WARNING: systematic errors were not found in file 'h1743-322_meg_abs3.pha'
statistical errors were found in file 'h1743-322_meg_abs3.pha' 
but not used; to use them, re-read with use_errors=True
read ARF file h1743-322_meg_abs3.arf
read RMF file h1743-322_meg_abs3.rmf
read background file h1743-322_meg_abs3_bkg.pha

sherpa> show_stack()
1: h1743-322_heg_abs1.pha OBS_ID: Merged MJD_OBS: 54515.1400341
2: h1743-322_heg_abs2.pha OBS_ID: Merged MJD_OBS: 54515.1400341
3: h1743-322_heg_abs3.pha OBS_ID: Merged MJD_OBS: 54515.1400341
4: h1743-322_meg_abs1.pha OBS_ID: Merged MJD_OBS: 54515.1400341
5: h1743-322_meg_abs2.pha OBS_ID: Merged MJD_OBS: 54515.1400341
6: h1743-322_meg_abs3.pha OBS_ID: Merged MJD_OBS: 54515.1400341

sherpa> group_counts([], 10)
           [None, None, None, None, None, None]
sherpa> plot_data([])

which will display each of the 6 spectra in separate windows.


Summary

The thread is now complete. See the Introduction to Fitting PHA Spectra thread for more information.


History

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.
15 Dec 2014 Updated for CIAO 4.7. Now uses combine_grating_spectra. New datasets are used.


Last modified: 15 Dec 2014
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:   cxcweb@head.cfa.harvard.edu Smithsonian Institution, Copyright © 1998-2014. All rights reserved.