About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: 1 Dec 2006
Hardcopy (PDF): A4 | Letter

Grouping a Grating Spectrum

[CIAO 3.4 Science Threads]



Overview

Last Update: 1 Dec 2006 - reviewed for CIAO 3.4: no changes

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.

It is also possible to set and change the grouping of a file after it has been read into Sherpa by using routines from the group module.

Purpose:

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

Read this thread if:

you want to group the data in a PHA file.

Related Links:

Proceed to the HTML or hardcopy (PDF: A4 | letter) version of the thread.




Contents



Get Started

Sample ObsIDs used: 459 (HETG/ACIS-S, 3C 273); 460 (LETG/HRC-S, 3C 273)

File types needed: 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 row filter is used to select the desired spectra from the input file. Note that there is a rows parameter in dmtype2split, but it has been deprecated and will be removed in the future. 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.

Single spectrum

To obtain one particular spectrum from the PHA2 file:

unix% dmtype2split "acisf00459N002_pha2.fits[#row=1]" 459_heg_m1.fits

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+
-3
unix% dmkeypar 459_heg_m1.fits TG_PART echo+
1

Users are not limited to row filters, however. You can explicitly pick the data using any DM filter, such a grating part and order:

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

This filter doesn't require you to know which row of the PHA file corresponds to which spectrum.


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 hrcf00460N004_pha2.fits "leg_m1.fits, leg_p1.fits"

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

unix% cat output.lis 
leg_m1.fits
leg_p1.fits

unix% dmtype2split hrcf00460N004_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


Using the group Module in Sherpa

The information in the Re-grouping PHA data in Sherpa thread can also be used on data that was not grouped before being read into Sherpa. As is noted in that thread, this can be useful for two reasons:

  1. You can use the routines to find the best grouping scheme for your data without having to re-run the dmgroup tool and re-load the data into Sherpa.
  2. You can fit the un-grouped data with the Cash statistic and then use the functions to make it easier to compare the fit to the data in plots.

Please refer to the Sherpa thread for more information.

Note, however, that not all the dmgroup grouping options are replicated in the group module. For instance, none of the routines includes the BIN option used in this thread.




Summary

This thread is now complete. If you have not yet created instrument response files (gRMFs and gARFs), refer to the appropriate CIAO Grating threads. Otherwise proceed to the the Sherpa fitting threads for information on how to model and fit the data.




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


        infile = hrcf00460N004_pha2.fits Input type II file
       outfile = @output.lis      Enter output file name(s)
         (rows = )                Row numbers
      (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

Return to Threads Page: Top | All | Grating
Hardcopy (PDF): A4 | Letter
Last modified: 1 Dec 2006


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-2004. All rights reserved.