Examining Grating Spectra and Regions: PHA2 files
![[CXC Logo]](../../imgs/cxc-logo.gif)
CIAO 4.2 Science Threads
Overview
Last Update: 19 Jul 2010 - the S-Lang syntax has been removed from this thread as it is not supported in CIAO 4.2 Sherpa v2.
Synopsis:
An overview of displaying grating data Type II PHA files and the source and background extraction regions.
Related Links:
- Analysis Guide for Chandra High Resolution Spectroscopy: an in-depth discussion of grating analysis.
Contents
- What is a PHA2 File?
- Examining the Files with Prism
- Displaying the Spectrum
- Displaying ACIS and HRC Extraction Regions
- History
-
Images
- Figure 1: ACIS-S/HETG dataset in prism
- Figure 2: ACIS-S/LETG dataset in prism
- Figure 3: HRC-S/LETG dataset in prism
- Figure 4: HRC-I/LETG dataset in prism
- Figure 5: Plot of +1 order spectrum in ChIPS
- Figure 6: +/-1 order plot in Sherpa: count rate per keV
- Figure 7: +/-1 order plot in Sherpa: counts
- Figure 8: ACIS/HETG data with source and background regions overlaid
- Figure 9: HRC-S/LETG data with bow-tie extraction region
What is a PHA2 File?
A Type II PHA file is a standard FITS format in which each row contains several columns. The PHA file is a product of standard data processing and is identified by the pha2.fits extension; note that the "2" in the filename refers to the fact that it is a level=2 data product, not that it is a Type II file. In the case that the user has to manually reprocess an event file (e.g. when applying an updated order sorting table), the PHA2 spectrum file is obtained from the level 2 event file by tgextract; see the HETG/ACIS-S Grating Spectra for an example of this.
The SPECTRUM block of a PHA2 file has 13 columns of data:
ColNo Name Description 1 SPEC_NUM Spectrum Number 2 TG_M Diffraction order (m) 3 TG_PART Spectral component (HEG, MEG, LEG, HESF parts) 4 TG_SRCID Source ID, output by tgdetect 5 X X sky coord of source 6 Y Y sky coord of source 7 CHANNEL[8192] Vector of spectral bin numbers. 8 COUNTS[8192] Counts array (a spectrum) 9 STAT_ERR[8192] Statistical uncertainty (error) on counts colum 10 BACKGROUND_UP[8192] Upper Background count vector. 11 BACKGROUND_DOWN[8192] Lower Background count vector. 12 BIN_LO[8192] Bin boundary, left edge 13 BIN_HI[8192] Bin boundary, right edge
There are two columns that are especially relevant when doing analysis:
- TG_M indicates the order of the spectrum (+/- 1, +/-2, +/- 3)
- TG_PART indicates the spectral component / grating arm (1 = HEG, 2 = MEG, 3 = LEG)
Examining the Files with Prism
Sample ObsIDs used: 459 (HETG/ACIS-S 3C 273); 460 (LETG/HRC-S, 3C 273); 1198 (LETG/ACIS-S, 3C 273); 1800 (LETG/HRC-I, PKS2155-304)
File types needed: evt2; pha2
ACIS-S HETG/LETG Observations
We can use prism to examine the PHA2 file for ObsID 459:
unix% prism acisf00459N004_pha2.fits &
as shown in Figure 1. In this example, there are twelve rows - all the +/- orders for both HEG and MEG - for the observation. The columns CHANNEL, COUNTS, BIN_LO, etc. are all so-called "vector columns"; each contains a vector of elements which, in this example, is 8192 elements long.
An ACIS-S/LETG observation (ObsID 1198) looks similar in prism (Figure 2) but only contains 6 rows (+/- orders for the LEG).
HRC-S/HRC-I LETG Observations
Examining an HRC-S/LETG observation (ObsID 460) is done in the same way as an ACIS grating observation:
unix% prism hrcf00460N004_pha2.fits &
but there is an important difference in the results. As seen in the prism display (Figure 3), there are only two rows for the LEG observation. HRC-S cannot resolve orders and the COUNTS in the +/- 1 order are in fact the total counts of all orders combined. Also, the BIN_LO and BIN_HI columns should be considered for reference only; they actually represent the boundary wavelength of the +/- 1 order alone, while photons from all orders are included in the spectra.
The same holds true for HRC-I/LETG observations, as seen Figure 4 in the example of ObsID 1800.
Displaying the Spectrum
With ChIPS
In order to display a spectrum with ChIPS, we need to specify which row in the file should be plotted. This example uses row 4, the +1 order HEG spectrum for the observation, chosen by the "[#row=4]" filter:
unix% chips ----------------------------------------- Welcome to ChIPS: CXC's Plotting Package ----------------------------------------- CIAO 4.2 Tuesday, July 6, 2010 chips> make_figure (S-Lang or Python help)("acisf00459N004_pha2.fits[#row=4][cols bin_lo,counts]") chips> set_curve (S-Lang or Python help)("symbol.style=none") chips> set_plot_title (S-Lang or Python help)("ACIS+HEG order=+1")
These commands produce the plot shown in Figure 5. Quit ChIPS before continuing:
chips> quit
With Sherpa
Sherpa can also be used to plot a PHA2 spectrum. Sherpa reads all the rows and allows you to specify individual ones for plotting or fitting purposes:
unix% sherpa ----------------------------------------------------- Welcome to Sherpa: CXC's Modeling and Fitting Package ----------------------------------------------------- CIAO 4.2 Sherpa version 2 Tuesday, July 6, 2010 sherpa> load_pha("acisf00459N004_pha2.fits") statistical errors were found in file 'acisf00459N004_pha2.fits' but not used; to use them, re-read with use_errors=True read background_up into a dataset from file acisf00459N004_pha2.fits read background_down into a dataset from file acisf00459N004_pha2.fits Multiple data sets have been input: 1-12 sherpa> set_analysis("energy") sherpa> plot_data(3) sherpa> add_plot() (S-Lang or Python help) sherpa> grid_objects (S-Lang or Python help)(1,2,0.18,0.18) sherpa> plot_data(4, overplot=True) sherpa> current_plot (S-Lang or Python help)("all") sherpa> limits (S-Lang or Python help)(X_AXIS, AUTO, 5)
Figure 6 shows the plot of the HEG -1 order (row 3, upper drawing area) and +1 order (row 4, lower drawing area) that is created.
Figure 6: +/-1 order plot in Sherpa: count rate per keV
The HEG -1 order (row 3) is in the upper plot and the HEG +1 order (row 4) is in the lower plot.
To plot the data in CHANNEL vs. COUNTS:
sherpa> clear sherpa> set_analysis("channel",type="rate") sherpa> plot_data(3) sherpa> add_plot() sherpa> grid_objects(1,2,0.18,0.18) sherpa> plot_data(4, overplot=True)
These commands create Figure 7.
Figure 7: +/-1 order plot in Sherpa: counts
The HEG -1 order (row 3) is in the upper plot and the HEG +1 order (row 4) is in the lower plot.
sherpa> quit
Displaying ACIS and HRC Extraction Regions
Each pha2 file has a second block, named REGION, which stores the regions used by tgextract to extract the source and background spectra.
There are three regions associated with each order: source, upper background, and lower background. For an ACIS/HETG observation, this gives 36 regions: 12 spectral components (+/- 3, +/- 2, and +/- 1 for HEG and MEG) times 3 regions apiece (source and two backgrounds).
To look at the columns of a REGION block:
unix% dmlist "acisf00459N004_pha2.fits[REGION]" cols -------------------------------------------------------------------------------- Columns for Table Block REGION -------------------------------------------------------------------------------- ColNo Name Unit Type Range 1 SPEC_NUM Int2 1:32767 Spectrum number 2 ROWID String[64] Source or a background 3 SHAPE String[16] Shape of region 4 TG_LAM angstrom Real4 0: 400.0 Dispersion coordinate 5 TG_D degrees Real4 -2.0: 2.0 Cross-dispersion coordinate 6 R[2] (angstrom , degrees) Real4(2) -Inf:+Inf Raduis vector for SHAPE 7 ROTANG degrees Real4 -360.0: 360.0 Rotation angle for SHAPE 8 TG_PART Int2 0:9 Grating part index (HEG=1, MEG=2, LEG=3) 9 TG_SRCID Int2 1:32767 Source identification number 10 TG_M Int2 -62:62 Diffraction order 11 COMPONENT Int2 - Component number
ds9 cannot display these regions as they are written in the pha2 file. In order to view them, we need to rename the (TG_LAM,TG_D) columns to (X,Y) so that ds9 knows how to interpret them. We will also need to create images in (TG_LAM,TG_D) coordinates, on which we can display the regions.
The following dmcopy commands create image and region files for the 1st and 3rd orders of the MEG arm:
unix% dmcopy \ "acisf00459N004_evt2.fits[bin tg_lam=0:30:0.08,tg_d=-0.01:0.01:0.00008][tg_m=-1,1,tg_part=2]" \ 459_order1.fits opt=all unix% dmcopy \ "acisf00459N004_evt2.fits[bin tg_lam=0:15:0.08,tg_d=-0.01:0.01:0.00008][tg_m=-3,3,tg_part=2]" \ 459_order3.fits opt=all unix% dmcopy \ "acisf00459N004_pha2.fits[region][tg_m=1,tg_part=2][cols x=tg_lam,y=tg_d,*]" \ region_order1.fits opt=all unix% dmcopy \ "acisf00459N004_pha2.fits[region][tg_m=3,tg_part=2][cols x=tg_lam,y=tg_d,*]" \ region_order3.fits opt=all
In creating the images, the filter includes + and - orders to obtain more events in the image. Since the regions are the same for +/- orders, it is only necessary to copy one (the + orders were used here). The image limits are typical for ACIS/HETG observations, but will need to be adjusted for other configurations.
To display the event files with the regions overlaid:
unix% ds9 -tile 459_order1.fits -region region_order1.fits -cmap a -scale log \ 459_order3.fits -region region_order3.fits -cmap a -scale log
which produces Figure 8. We can see that all events are contained within at least one extraction region.
![[Thumbnail image: The images in wavelength coordinates are displayed side-by-side in ds9.]](regions.thumb300.png)
[Version: full-size]
![[Print media version: The images in wavelength coordinates are displayed side-by-side in ds9.]](regions.png)
Figure 8: ACIS/HETG data with source and background regions overlaid
The first order (left) and third order (right) images with extraction regions overlaid.
For HRC/LETG data, a bow-tie extraction region is used. Using similar dmcopy commands as for the ACIS data:
unix% dmcopy \ "hrcf00460N004_evt2.fits[bin tg_lam=0:210:0.25,tg_d=-2:2:0.0008][tg_m=-1,1,tg_part=3]" \ hrc_order1_img.fits opt=all unix% dmcopy \ "hrcf00460N004_pha2.fits[REGION][tg_m=1,tg_part=3][cols x=tg_lam,y=tg_d,*]" \ hrc_region_order1.fits opt=all
To display the file and regions:
unix% ds9 hrc_order1_img.fits -region hrc_region_order1.fits -cmap b -scale log
which produces Figure 9.
![[Thumbnail image: The image in wavelength coordinates is displayed in ds9.]](bowtie.thumb300.png)
[Version: full-size]
![[Print media version: The image in wavelength coordinates is displayed in ds9.]](bowtie.png)
Figure 9: HRC-S/LETG data with bow-tie extraction region
The scale parameters have been adjusted to highlight the source counts along the center of the display. A pixel distribution of 19:404 is used.
History
01 Jun 2004 | reviewed for CIAO 3.2: no changes |
06 Dec 2005 | updated for CIAO 3.3: version numbers |
01 Dec 2006 | updated for CIAO 3.4: ChIPS and Sherpa versions |
24 Jan 2008 | updated for CIAO 4.0: updated ChIPS and Sherpa syntax |
06 Jun 2008 | added "opt=all" to dmcopy commands so all blocks are kept in the grating files |
06 Feb 2009 | updated for CIAO 4.1: prism was rewritten in GTK, so some cosmetic changes (updated all thread images); images are inline; Python and S-Lang syntax included for ChIPS and Sherpa plotting |
14 Jan 2009 | updated for CIAO 4.2: ObsID 459 file versions |
19 Jul 2010 | the S-Lang syntax has been removed from this thread as it is not supported in CIAO 4.2 Sherpa v2. |