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

Skip the navigation links
Last modified: 25 July 2006
Hardcopy (PDF): A4 | Letter

Using psextract to Extract ACIS Spectra and Response Files for Pointlike Sources



Overview

Last Update: 25 Jul 2006 - added Creating an RMF with mkacisrmf section, moved "Using Consistent Calibration: mkrmf vs mkacisrmf" section

Synopsis:

[New] (30 Mar 2006) The recommended use for the specextract script has been changed. It has been determined that the mkwarf tool, which is used for ARF generation by specextract, may not produce accurate results for point sources. The mkarf tool, used by psextract, is preferred for point source extraction.

specextract should be used for the analysis of extended sources only. Users working with point sources should instead use the psextract script. Analysis of point sources that was done with mkwarf/specextract should be redone with mkarf/psextract for the most accurate results, e.g. taking bad columns into account.

The psextract script allows you to compute different RMFs and ARFs for the source and background spectra, if needed. The output files are the source and (ungrouped) background spectra and the source RMF and ARF. If the source and background extraction regions have different average detector coordinates or the source and background event files are different, then the background RMF and ARF and a "linearly grouped" (by a factor of 20) background spectrum are also created.

Purpose:

To generate source and background PI (PHA) spectra of a pointlike ACIS source and build the proper RMFs and ARFs.

Read this thread if:

you are working with any ACIS observation, whether imaging or grating data. If the source is at the very edge of a CCD, subarray or window, do not use this thread. Instead, run the Step-by-Step Guide to Creating ACIS Spectra thread which includes the use of the mask file when making an ARF.

Calibration Updates:

  • CALDB v3.2.1 (15 Dec 2005): The gain for the back-illuminated (BI) chips - ACIS-S1 and S3 - for -120 GRADED mode observations has been upgraded. It is now possible to use mkacisrmf when creating responses for these chips only in GRADED mode. See How CALDB 3.2.1 Affects Your Analysis for details.
  • CALDB v3.2.0 (21 Nov 2005): The version 5 "phase 2" response file (acisD2000-01-29p2_respN0005.fits) was added to CALDB 3.2.0, released on 21 November 2005. Information on the changes in CALDB 3.2.0 is in the How CIAO 3.3 and CALDB 3.2.0 Affect Your Analysis section of the CIAO release notes.
  • CALDB v3.1.0 (23 Jun 2005): The version 4 "phase 2" response file (acisD2000-01-29p2_respN0004.fits) was added to the CALDB. In conjunction with the ACIS CTI and TGAIN calibration improvements in this CALDB release, the mkacisrmf tool can now be used to create RMFs for all -120 observations, except for those done in GRADED mode.
  • CALDB v2.26 (2 Feb 2004): New FEF files containing updated information for ACIS S3 were added to the CALDB; there are CTI-corrected and uncorrected versions available. The ACIS contamination files were also included in this update.
  • CALDB v2.21 (14 Feb 2003): The new CTI-corrected FEF file (acisD2000-01-29fef_pha_ctiN0002.fits) contains updated information for chips S0, S1, and S3-5, eliminating the calibration problem announced in December 2002. Applying the CTI correction to these chips will no longer have a negative effect on the data.
  • CALDB v2.8 (13 Sep 2001): New OSIP files make it possible to analyze -120 degrees S3 grating data with the gainmaps and FEFs that were in the prevous CALDB release. If you are working with an observation taken under these conditions, run the Apply an ACIS Gain Map thread before running this thread. If you need help determining the temperature of your observation, see this FAQ.

Related Links:

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




Contents



Get Started

Sample ObsID used: 459 (HETG/ACIS-S, 3C 273)

File types needed: evt2; asol1

Please ensure that you have set up ardlib to use the bad pixel file for your observation before following this thread.

Using Consistent Calibration: mkrmf vs mkacisrmf

The tool mkacisrmf was a new addition in CIAO 3.2 and represents an entirely new method for creating ACIS imaging response matrices. Details on the tool are available in the Creating ACIS RMFs why topic. This script uses the older tool mkrmf to create the RMF files. Users who wish to take advantage of the improvements in mkacisrmf may simply run it standalone to generate new RMFs after using the script to create the spectrum and ARF files. The Creating ACIS RMFs with mkacisrmf thread shows how to run the tool.

The mkacisrmf tool can be used to create RMFs for all -120 ACIS observations taken in any mode except for GRADED mode. For GRADED mode, it is possible to create responses for the back-illuminated chips (ACIS-S1 and S3) only. For more information, refer to the ACIS GRADED Mode Data section of the mkacisrmf thread.

It is important that the calibration applied to the event file is consistent with the RMF tool chosen, as explained in the "Using Consistent Calibration" section of the why topic. If necessary, reprocess your data with the correct gain file for before beginning this thread.



Downloading the Scripts

The most recent version of psextract is v3.3 (27 September 2005):

unix% grep version_ `which psextract`
version_str="3.3"
version_date="27 September 2005"

The most recent version of acis_fef_lookup is 1.11 (21 May 2003):

unix% grep Id `which acis_fef_lookup`
% $Id: acis_fef_lookup,v 1.11 2003/05/21 15:34:28 dburke Exp $

Please check that you are using the most recent version before continuing. If you do not have the scripts installed or need to update to a newer version, please refer to the Scripts page.



Build Source and Background Regions

We need to define two regions, one for the source and another for the background. To do this, first display the image:

unix% ds9 acisf00459N002_evt2.fits &

In this example, we define the jet as the source with a rectangle (see this FAQ on how to rotate shapes in ds9) and four 10-pixel radius circles for the background (from source-free parts of the image around the source). All the regions are shown on this image [Link to Image 1]. The background region can be also selected from a different event file.

To save the regions, follow these steps:

  1. Region -> File Format-> Ciao
  2. Region -> File Coordinate System -> Physical
  3. Region -> Save Regions... -> Save As "3c273.reg" (source) and "3c273_bg.reg" (background). To select multiple regions for saving, hold down the <SHIFT> key and click on each one.

Note that both the "CIAO" and "SAOtng" region formats are supported by this script; we choose to use "CIAO" here. The imaging window may be closed by choosing "File -> Exit".

The resulting region files will look something like this:

unix% more 3c273.reg
# Region file format: CIAO version 1.0
rotbox(4148.125,4043.625,7.58978,22.338761,44.516094)

unix% more 3c273_bg.reg
# Region file format: CIAO version 1.0
circle(4119,4014.75,10)
circle(4077,4025.75,10)
circle(4186.5,4023.25,10)
circle(4196.25,4064.5,10)


Run psextract

psextract runs the following tools in order:

  1. dmextract: to extract source and background spectra
  2. dmkeypar: to find out the start-time of the observation (for source and background)
  3. dmstat: to get statistics on chipx, chipy, ccd_id, x and y (for source and background)
  4. acis_fef_lookup: to find the proper FEF file (for source and background)
  5. mkrmf: to build the proper RMF(s)
  6. asphist: to create the aspect histogram(s)
  7. mkarf: to create the proper ARF(s) In the case of grating data, psextract reads the GRATING keyword from the header of the event file and passes it to mkarf
  8. dmgroup: to group the source spectrum and, if needed, the background spectrum
  9. dmhedit: to update the BACKFILE, RESPFILE and ANCRFILE keys in the source PHA file, and the RESPFILE and ANCRFILE keys in the "linearly grouped" background PHA file (if needed).

In this case, since we are using an ACIS/HETG observation, mkarf will extract the 0th order spectra and ARF.

To extract the spectra in PI space and group the source spectrum to contain the new grouping-scheme; that is, there will be a minimum number of 15 counts per new channel:

unix% punlearn psextract
unix% pset psextract events="acisf00459N002_evt2.fits[sky=region(3c273.reg)]"
unix% pset psextract bgevents="acisf00459N002_evt2.fits[sky=region(3c273_bg.reg)]"
unix% pset psextract root=3c273
unix% pset psextract asol=@pcad_asol1.lis
unix% pset psextract gtype=NUM_CTS
unix% pset psextract gspec=15

Running the tool with verbose=2 shows what it is doing:

unix% psextract verbose=2
Source events specification (acisf00459N002_evt2.fits[sky=region(3c273.reg)]): 
Background events specification (acisf00459N002_evt2.fits[sky=region(3c273_bg.reg)]): 
Root name for output files (3c273): 
Source aspect solution file (@pcad_asol1.lis): 
Background aspect solution file (): 
 
          events=acisf00459N002_evt2.fits[sky=region(3c273.reg)] 
          bgevents=acisf00459N002_evt2.fits[sky=region(3c273_bg.reg)] 
          root=3c273 
          aoff=@pcad_asol1.lis bgaoff=@pcad_asol1.lis 
          ptype=pi
          gtype=NUM_CTS grouping=15
          verbose=2
 
Extract source spectrum 3c273.pi from acisf00459N002_evt2.fits[sky=region(3c273.reg)]
dmextract infile="acisf00459N002_evt2.fits[sky=region(3c273.reg)][bin pi]" outfile=3c273.pi 
opt=pha1 clobber=no verbose=0
 
Extract background spectrum 3c273_bg.pi from acisf00459N002_evt2.fits[sky=region(3c273_bg.reg)]
dmextract infile="acisf00459N002_evt2.fits[sky=region(3c273_bg.reg)][bin pi]" outfile=3c273_bg.pi
opt=pha1 clobber=no verbose=0
Inspecting events file acisf00459N002_evt2.fits[sky=region(3c273.reg)]
Inspecting background events file acisf00459N002_evt2.fits[sky=region(3c273_bg.reg)]
Running dmstat on source and background events files:
 
Source Event statistics: CHIP 7 280.28940217 373.73097826   SKY 4146.0548958 4045.9470477
Background Event statistics: CHIP 7 290.40277778 379.9537037   SKY 4144.8603323 4032.6548281
 
Look up FEF spectral calibration file(s)
Source FEF file is /data/CALDB/test_2/data/chandra/acis/cpf/fefs/acisD1999-09-16fef_phaN0002.fits
[FUNCTION][ccd_id=7,chipx=257:288,chipy=353:384]
Background FEF file is /data/CALDB/test_2/data/chandra/acis/cpf/fefs/acisD1999-09-16fef_phaN0002.
fits[FUNCTION][ccd_id=7,chipx=289:320,chipy=353:384]
Verified Source FEF file is present
Verified background FEF file is present
 
Source and background FEFs are different
Building different RMFs and ARFs for source and background
 
Make source RMF file 3c273.rmf with mkrmf
mkrmf infile=/data/CALDB/test_2/data/chandra/acis/cpf/fefs/acisD1999-09-16fef_phaN0002.fits[FUNCTION]
[ccd_id=7,chipx=257:288,chipy=353:384] outfile=3c273.rmf logfile=./.psp.mlog axis1=energy=0.1:11.0:0.
01 axis2=pi=1:1024:1 clobber=no verbose=2
 
Created source RMF file 3c273.rmf
 
Make background RMF file 3c273_bg.rmf with mkrmf
mkrmf infile=/data/CALDB/test_2/data/chandra/acis/cpf/fefs/acisD1999-09-16fef_phaN0002.fits[FUNCTION]
[ccd_id=7,chipx=289:320,chipy=353:384] outfile=3c273_bg.rmf logfile=./.psp.bgmlog axis1=energy=0.1:11.
0:0.01 axis2=pi=1:1024:1 clobber=no verbose=2
 
Created background RMF file 3c273_bg.rmf
 
Running asphist to create source aspect histogram 3c273.asphist
asphist infile="@pcad_asol1.lis" outfile=3c273.asphist evtfile="acisf00459N002_evt2.fits[ccd_id=7]" clobber=no dtffile="" verbose=0
Running mkarf to create source 3c273.arf at (4146.0548958,4045.9470477)
mkarf detsubsys=ACIS-S3 outfile=3c273.arf asphistfile="3c273.asphist" sourcepixelx=4146.0548958 sourc
epixely=4045.9470477 grating=HETG obsfile="3c273.asphist" maskfile=NONE verbose=0 engrid="grid(3c273.
rmf[MATRIX][cols ENERG_LO,ENERG_HI])" clobber=no
***ARDLIB warning: Filename 3c273.asphist does not specify an extension. Assuming the first "interest
ing" extension.
Running mkarf to create background 3c273_bg.arf at (4144.8603323,4032.6548281)
mkarf detsubsys=ACIS-S3 outfile=3c273_bg.arf asphistfile="3c273.asphist" sourcepixelx=4144.8603323 so
urcepixely=4032.6548281 grating=HETG obsfile="3c273.asphist" maskfile=NONE verbose=0 engrid="grid(3c2
73_bg.rmf[MATRIX][cols ENERG_LO,ENERG_HI])" clobber=no
***ARDLIB warning: Filename 3c273.asphist does not specify an extension. Assuming the first "interest
ing" extension.
 
Group source spectrum using NUM_CTS 15
dmgroup infile=3c273.pi outfile=./3c273.tmp binspec= tabspec= grouptype=NUM_CTS grouptypeval=15 ycolu
mn=counts xcolumn=channel tabcolumn= clobber=no verbose=0
Source spectrum 3c273.pi has been grouped
 
Group Background spectrum using BIN=1:1024:20
dmgroup infile=3c273_bg.pi outfile=3c273_bg_grp.pi binspec="1:1024:20" tabspec= grouptype=BIN groupty
peval= ycolumn=counts xcolumn=channel tabcolumn= clobber=no verbose=0
Background spectrum 3c273_bg_grp.pi has been grouped
 
Updating PHA file 3c273.pi with BACKFILE RESPFILE ANCRFILE keys
Background spectrum (BACKFILE) = 3c273_bg.pi
SOURCE RMF (RESPFILE) = 3c273.rmf
SOURCE ARF (ANCRFILE) = 3c273.arf
Updating PHA file 3c273_bg_grp.pi with RESPFILE ANCRFILE key
BACKGROUND RMF (RESPFILE) = 3c273_bg.rmf
BACKGROUND ARF (ANCRFILE) = 3c273_bg.arf

The ARDLIB warning may be ignored as it does not adversely affect the output.

Important: the output source spectrum (in this case, 3c273.pi) is grouped if a grouping was specified; currently there is not an ungrouped spectrum created in this case.

The contents of the parameter file may be checked with plist psextract.

Creating an RMF with mkacisrmf

If you would like to create a new RMF with the mkacisrmf tool after running this script, follow the instructions in the Using mkacisrmf with the psextract script section of the mkacisrmf thread.



Update Background File Header

Currently psextract only updates the RESPFILE and ANCRFILE header keywords in the source and grouped background file. These should be added to the ungrouped background file as well, in order to integrate more smoothly with Sherpa.

unix% dmhedit infile=3c273_bg.pi filelist="" operation=add key=RESPFILE value=3c273_bg.rmf
unix% dmhedit infile=3c273_bg.pi filelist="" operation=add key=ANCRFILE value=3c273_bg.arf


Notes

There are several things to note about how the tool works:

  • Due to the satellite dithering, a point-like source can in principle move across all 4 nodes of a single chip (or different chips) during the observation. This tool builds ARFs and RMFs for the position occupied by the source during most of its exposure (> 50 %).

  • The output source and background spectra are by default created in the PI channel space, and so are the respective response matrices. To create PHA output files, set the ptype parameter to pha:

    unix% pset psextract ptype=pha
    
  • psextract uses a hardcoded binning for the RMF of axis2 = (energy=0.1:11.0:0.01), which defines the binning to go from Emin=0.1 keV to Emax=11 keV in steps of 0.01 keV.



Analysis Caveats

Users should be cautious about analyzing the data for sources near the edges of the ACIS CCDs.

  1. For X-rays passing through the mirrors, the very bottom of each CCD is obscured by the frame store. As a result, some of the events in rows with CHIPY <= 8 are not detected. (The set of rows affected varies from CCD to CCD.) Since the CIAO tools do not compensate for this effect, the ARFs and exposure maps for sources in these regions may be inaccurate.

  2. For sources within about thirty-two pixels of any edge of a CCD, the source may be dithered off the CCD during part of an observation. The aspect histogram, which is used to create ARFs and exposure maps, is designed to compensate for this effect.

  3. A contaminant has accumulated on the optical-blocking filters of the ACIS detectors, as described in the ACIS QE Degradation why topic. Since there is a gradient in the temperature across the filters (the edges are colder), there is a gradient in the amount of material on the filters. (The contaminant is thicker at the edges.) Within about 100 pixels of the outer edges of the ACIS-I and ACIS-S arrays, the gradient is relatively steep. Therefore, the effective low-energy (' 1 keV) detection efficiency may vary within the dither pattern in this region. The ARF and instrument map tools are designed to read a calibration file which describes this spatial dependence.



Fitting

If you would like to fit the background-subtracted source spectrum using a common RMF and ARF for source and background, simply read the source spectrum FITS file into Sherpa, subtract the background, and fit it. See the Introduction to Fitting PHA Spectra thread for details.

To fit source and background spectra simultaneously with proper and distinct RMFs and ARFs, load the source and background as different datasets. This procedure is discussed in the Independent Background Responses thread.




Summary

The thread is now complete. The source and the ungrouped background spectra are named 3c273.pi and 3c273_bg.pi; the grouped background spectrum is named 3c273_bg_grp.pi. The source and background (common) RMF is named 3c273.rmf, while source and background ARFs are named 3c273.arf and 3c273_bg.arf respectively.




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


        events = acisf00459N002_evt2.fits[sky=region(3c273.reg)] Source events specification
      bgevents = acisf00459N002_evt2.fits[sky=region(3c273_bg.reg)] Background events specification
          root = 3c273            Root name for output files
          asol = @pcad_asol1.lis  Source aspect solution file
        bgasol =                  Background aspect solution file
        (ptype = pi)              pi or pha
        (gtype = NUM_CTS)         Spectrum grouping type (same as grouptype in dmgroup)
        (gspec = 15)              Spectrum grouping specs (NONE,1:1024:10,etc)
      (clobber = no)              OK to overwrite existing output file?
      (verbose = 2)               Debug Level(0-5)
         (mode = ql)              
    

History

14 Dec 2004 updated for CIAO 3.2: created Using Consistent Calibration and Downloading the Scripts sections
23 Jun 2005 CIAO 3.2.2 patch: new calibration for mkacisrmf is available; see the Using Consistent Calibration: mkrmf vs mkacisrmf section
15 Dec 2005 updated for CIAO 3.3: the psextract script has been updated to version 3.3 for the new asphist tool syntax; note about specextract in the Overview; default value of dmextract error and bkgerror parameters is "gaussian" (this tool is called by psextract)
01 Feb 2006 added link to specextract thread
31 Mar 2006 specextract use update added to Overview; title changed from "Extract ACIS Spectra for Pointlike Sources and Make RMFs and ARFs" to "Using psextract to Extract ACIS Spectra and Response Files for Pointlike Sources"
14 Jun 2006 corrected link in "Calibration Updates"; clarified information on GRADED mode data
25 Jul 2006 added Creating an RMF with mkacisrmf section, moved "Using Consistent Calibration: mkrmf vs mkacisrmf" section

Return to Threads Page: Top | All | Imag Spec
Hardcopy (PDF): A4 | Letter
Last modified: 25 July 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.