Last modified: 8 Feb 2022

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

Grouping a Grating Spectrum

CIAO 4.15 Science Threads


Overview

Synopsis:

In order to use Gaussian statistics to fit a model to a dataset it is often necessary to "group" the data - i.e. combine channels until you have enough counts - before use. Since it is not possible to group all the rows in a PHA2 spectrum file at once, the individual spectra first need to be "split" from the file with dmtype2split. Then the dmgroup tool is used to perform the desired grouping.

If you will be fitting the data in Sherpa, it is not necessary to group the files first. It is possible to set and change the grouping of a file after it has been read into Sherpa by using the group commands, as shown in the Changing the grouping scheme of a data set thread.

Purpose:

To show how to split a PHA2 file into multiple PHA1 files, and then group the individual spectra.

Related Links:

Last Update: 8 Feb 2022 - Review for CIAO 4.14. No changes.


Contents


Get Started

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

unix% download_chandra_obsid 459,460 pha2

Split the PHA File

The tool dmtype2split creates a PHA1 file for selected rows of a PHA2 file. It is only necessary to set the infile and outfile parameters:

  • infile: a filter is used to select the desired spectra from the input file. The Examining Grating Spectra thread explains the rows in the PHA2 file.

  • outfile: the number of outfile names given must match the number of rows in the infile parameter. The name of the output block - usually [SPECTRUM] - must be specified.

Single spectrum

To obtain one particular spectrum from the PHA2 file:

unix% dmtype2split "acisf00459N004_pha2.fits[tg_part=1,tg_m=-3]" "459_heg_m1.fits[SPECTRUM]"

The 459_heg_m1.fits output file contains the HEG -3 order spectrum. This information is stored in the header of the new file:

unix% dmkeypar 459_heg_m1.fits TG_M echo-
unix% pget dmkeypar value
-3

unix% dmkeypar 459_heg_m1.fits TG_PART echo+
1

Multiple spectra

If no filter is specified, the tool creates a PHA1 file for every row in the input. For this case, we must specify a stack of output filenames:

unix% dmtype2split hrcf00460N005_pha2.fits "leg_m1.fits[SPECTRUM], leg_p1.fits[SPECTRUM]"

The output names could also have been provided in an external file:

unix% cat output.lis 
leg_m1_b.fits[SPECTRUM]
leg_p1_b.fits[SPECTRUM]

unix% dmtype2split hrcf00460N005_pha2.fits @output.lis

Either command will create two spectra, one from each row in the HRC-S/LETG file. The content of the parameter file may be examined with plist dmtype2split.


Group the Spectra

The PHA1 files are simply grouped with dmgroup. In this example, we add every 10 bins in the original file together:

unix% dmgroup infile="leg_p1.fits[SPECTRUM]" outfile=leg_p1_bin10.pha \
      binspec="1:16384:10" grouptypeval="" grouptype=BIN ycolumn="counts" \
      xcolumn="channel"

The dmgroup help file explains all the available grouping options. The content of the parameter file may be examined with plist dmgroup.

Resolution and default grids

The PHA2 file default grid oversamples the instrumental resolution by a factor of about 4-5. While the desired bin size depends upon the analysis, a factor of 2 can always be accommodated without degrading the resolution. For detection and identification of spectral features without an RMF-based model, grouping to the FWHM of the resolution may be desirable. For line profile modeling using a grating RMF, oversampling is appropriate. For continuum modeling, grouping by much more than the resolution for sufficient statistical significance may be preferred. For modeling of lines and continuum with current incomplete atomic line models, oversampling provides a more reliable empirical continuum determination.

For any grouping, use of the grating RMF will correctly represent the convolved model.

For guidance, here are the resolution (FWHM) and default grids (from tgextract or mkgrmf) for each of the gratings:

Grating Part Resolution (Å) Default Binsize (Å) Oversampling Factor
HEG 0.012 0.0025 4.8
MEG 0.023 0.005 4.6
LEG 0.05 0.0125 4.0

Summary

If you have not yet created instrument response files (gRMFs and gARFs), follow the appropriate CIAO Grating threads to do so.

Otherwise, proceed to the Sherpa grating threads for information on how to model and fit the data:



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


        infile = hrcf00460N005_pha2.fits Input type II file
       outfile = @output.lis      Enter output file name(s)
      (clobber = no)              OK to overwrite existing output file(s)?
      (verbose = 0)               Verbosity level
         (mode = ql)              
    


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


        infile = leg_p1.fits[SPECTRUM] Input dataset name
       outfile = leg_p1_bin10.pha Output dataset name
     grouptype = BIN              Grouping type
  grouptypeval = 0                Grouping type value
       binspec = 1:16384:10       Binning specification
       xcolumn = channel          Name of x-axis
       ycolumn = counts           Name of y-axis
      (tabspec = )                Tab specification
    (tabcolumn = )                Name of tab column
     (stopspec = )                Stop specification
   (stopcolumn = )                Name of stop column
    (errcolumn = )                Name of error column
      (clobber = no)              Clobber existing output file?
      (verbose = 0)               Verbosity level
    (maxlength = 0)               Maximum size of groups (in channels)
         (mode = ql)              
    

History

08 Apr 2005 original version, new for CIAO 3.2
12 Apr 2005 changes made to Resolution and default grids section (renamed from "Binning to instrumental resolution")
05 Dec 2005 reviewed for CIAO 3.3: no changes
01 Dec 2006 reviewed for CIAO 3.4: no changes
11 Jan 2008 updated for CIAO 4.0: specify output block name ("[SPECTRUM]") for dmtype2split; Sherpa links point to the Sherpa Beta website
12 Feb 2009 updated for CIAO 4.1: Sherpa links point to 4.1 website
14 Jan 2009 updated for CIAO 4.2: ObsID 459 file versions
15 Dec 2010 updated for CIAO 4.3: the deprecated rows parameter has been removed from dmtype2split; use a Data Model filter to select the desired rows, as shown below.
10 Jan 2012 reviewed for CIAO 4.4: added a pget command to workaround a dmkeypar bug with negative integers
03 Dec 2012 Review for CIAO 4.5; remove #row filter in dmtype2split
11 Dec 2012 Review for CIAO 4.6; no changes.
22 Dec 2014 Review for CIAO 4.7; no changes.
08 Feb 2022 Review for CIAO 4.14. No changes.