Last modified: 31 Jan 2022

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

HETG/ACIS-S Grating ARFs

CIAO 4.16 Science Threads


Overview

Synopsis:

fullgarf is a script that creates a grating ARF for a particular order and grating of an observation. While the mkgarf tool will create a grating ARF for an individual chip given an aspect histogram, this script creates ARFS for each chip, creating aspect histograms as necessary. The script then combines the individual ARFS into one for the full array.

Purpose:

To create grating ARFs for an HETG/ACIS-S observation.

Related Links:

Last Update: 31 Jan 2022 - Review for CIAO 4.14. Added note about Repro-5 data.


Contents


About the Chandra Grating Data Archive and Catalog

The Chandra Grating Data Archive and Catalog (TGCat) is a browsable interface to analysis-quality spectral products (binned spectra and corresponding response files). TGCat makes it easy to find observations of a particular object, type of object, or type of observation, to quickly assess the quality and potential usefulness of the spectra with pre-computed graphics or custom-generated plots of binned and combined counts or fluxe spectra. Spectra, responses, event files, and summary products may be downloaded as a package.

TGCat runs standard CIAO tools, but also includes customized extractions for non-standard cases to refine the zeroth order position or to use regions appropriate for extended sources. Non-standard extractions details are provided in "verification and validation" comments for users.

Most public grating observations are available and new ones are added soon after they are released. See the list of of observations not included for exceptions. Many of the observations currently in this list will be included when we add enhanced processing for more difficult cases (multiple sources, very extended sources).

Please consider using the spectrum and responses (PHA, ARF, and RMF files) from TGCat in your analysis.


Repro V (5) data

Datasets which have been processed as part of Repro V (5), and those recently obtained data processed with ASCDSVER=10.8.3 and newer include grating ARFs and RMF files for the source spectrum extracted in the pha2 file. These files are located in the primary/responses directory.


Script It

The creation of the grating ARF and RMF is now automated.

chandra_repro will now automatically create the RMF and ARF for grating spectra. The results are stored in a tg/ subdirectory of the output directory.

Also, the mktgresp tool will create all the ARFs and RMFs for the grating spectra in a type II PHA file using the default grids and standard calibrations files. Just simply run

unix% mktgresp pha2 evt2 root_filename

where pha2 and evt2 are the filenames of your spectra output from tgextract or tgextract2 and the corresponding event file.

[WARNING]
Thread Complete

If you have run chandra_repro or mktgresp then you are done with this thread and may move onto fitting and modeling your spectra. If you need to customize your responses or want to learn more details of the step by step processing steps you can continue with this thread.


Get Started

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

[NOTE]
Early dataset

The data used in this thread was taken very early in the Chandra mission. It was not included in the bulk reprocessing metioned in the Watchout page. The keywords required for analysis with CIAO need to be added by running chandra_repro or r4_header_update.

It is assumed that you have created a gRMF for your observation by running the Create Grating RMFs for ACIS-S Observations thread, which is called rmf.fits.

Using the mask file

To make sure that the gARF file is correct, set the maskfile parameter to the observation-specific msk1.fits file. If you are working with continuous-clocking (CC) mode data, be sure to read the ACIS Pipeline-Processed Mask Files caveat as well.


Determine the Orders of the Observation

An ARF needs to be calculated for each order in the observation. We can use dmlist to examine the pha2 file and determine how many orders there are:

unix% dmlist acisf00459_repro_pha2.fits"[cols tg_m,tg_part]" data,clean
#  TG_M TG_PART
   -3    1
   -2    1
   -1    1
    1    1
    2    1
    3    1
   -3    2
   -2    2
   -1    2
    1    2
    2    2
    3    2

The tg_m column indicates the order of the observation (+/- 1, +/- 2, +/- 3) and the tg_part column indicates the grating (1 = HEG, 2 = MEG, 3 = LEG). The twelve rows (all +/- orders for HEG and MEG) for the HETG observation are shown.


Run fullgarf

It is necessary to run fullgarf for each order that will be modeled, up to twelve times (once for each row in the PHA file).

For row 1, HEG, order = -3:

unix% punlearn fullgarf
unix% pset fullgarf phafile=acisf00459_repro_pha2.fits
unix% pset fullgarf pharow=1
unix% pset fullgarf evtfile=acisf00459_repro_evt2.fits
unix% pset fullgarf asol=@pcad_asol1.lis
unix% pset fullgarf engrid="grid(rmf.fits[cols ENERG_LO,ENERG_HI])"
unix% pset fullgarf badpix=acisf00459_repro_bpix1.fits
unix% pset fullgarf maskfile=acisf00459_000N003_msk1.fits
unix% pset fullgarf dafile=CALDB
unix% pset fullgarf rootname=acisf00459

In some rare cases, there will be more than one aspect solution file (pcad_asol1.fits) for an observation. All the files must be input to the asol parameter, either as a list or a stack. Here we use:

unix% cat pcad_asol1.lis 
pcadf063874624N003_asol1.fits

Now run the tool:

unix% fullgarf
Will use /home/username/cxcds_param4/fullgarf.par for the parameter file.
   
/home/username/cxcds_param4/fullgarf.par contains 15 parameters . . . 
   
Input PHA file (Type I or II) (acisf00459_repor_pha2.fits): 
Row in Type II PHA file (ignored if Type I) (0:99) (1): 
Event file  (acisf00459_repro_evt2.fits): 
Aspect offsets file (@pcad_asol1.lis): 
Energy grid spec (grid(rmf.fits[cols ENERG_LO,ENERG_HI])): 
Dead time correction factor; ACIS->evt file; HRC -> dtf file (): 
Bad pixel file; (filename|NONE|CALDB) (acis_459_new_bpix1.fits): 
Output rootname (acisf00459): 
NONE, or name of ACIS window mask file (acisf00459_000N003_msk1.fits): 
Getting the pha file type . . .

Grating arm is HEG, order=-3
Source location is X=4122.22509765625, Y=4071.310546875 
  
Detector is ACIS 
Will run asphist for ccd_id= 4 5 6 7 
  
   
asphist infile=@pcad_asol1.lis outfile=acisf00459_ah4.fits 
evtfile=acisf00459_repro_evt2.fits[ccd_id=4] dtffile=
# asphist (CIAO 4.3): WARNING: 'pcadf063874624N003_asol1.fits' has no
records fall in event gti's. 

asphist infile=@pcad_asol1.lis outfile=acisf00459_ah5.fits 
evtfile=acisf00459_repro_evt2.fits[ccd_id=5] dtffile=
   
asphist infile=@pcad_asol1.lis outfile=acisf00459_ah6.fits 
evtfile=acisf00459_repro_evt2.fits[ccd_id=6] dtffile=
   
asphist infile=@pcad_asol1.lis outfile=acisf00459_ah7.fits 
evtfile=acisf00459_repro_evt2.fits[ccd_id=7] dtffile=
   
Finished creating aspect histograms for ccd_id= 4 5 6 7 
Will run mkgarf for the same ccd_id list 
   
mkgarf detsubsys=ACIS-S0 order=-3 grating_arm=HEG outfile=acisf00459_S0_HEG_-3.fits 
asphistfile=acisf00459_ah4.fits[ASPHIST] obsfile=acisf00459_repro_evt2.fits 
engrid=grid(rmf.fits[cols ENERG_LO,ENERG_HI]) osipfile=CALDB dafile=CALDB 
pbkfile= maskfile=acisf00459_000N003_msk1.fits
mirror=HRMA sourcepixelx=4122.22509765625 sourcepixely=4071.310546875
mode=hl verb=0
*** ERROR: aspect histogram acisf00459_ah4.fits[ASPHIST] contains no rows
   
mkgarf detsubsys=ACIS-S1 order=-3 grating_arm=HEG outfile=acisf00459_S0_HEG_-3.fits 
asphistfile=acisf00459_ah4.fits[ASPHIST] obsfile=acisf00459_repro_evt2.fits 
engrid=grid(rmf.fits[cols ENERG_LO,ENERG_HI]) osipfile=CALDB dafile=CALDB 
pbkfile= maskfile=acisf00459_000N003_msk1.fits 
mirror=HRMA sourcepixelx=4122.22509765625 sourcepixely=4071.310546875
mode=hl verb=0
  
mkgarf detsubsys=ACIS-S2 order=-3 grating_arm=HEG outfile=acisf00459_S0_HEG_-3.fits 
asphistfile=acisf00459_ah4.fits[ASPHIST] obsfile=acisf00459_repro_evt2.fits 
engrid=grid(rmf.fits[cols ENERG_LO,ENERG_HI]) osipfile=CALDB dafile=CALDB 
pbkfile= maskfile=acisf00459_000N003_msk1.fits 
mirror=HRMA sourcepixelx=4122.22509765625 sourcepixely=4071.310546875
mode=hl verb=0
   
mkgarf detsubsys=ACIS-S3 order=-3 grating_arm=HEG outfile=acisf00459_S0_HEG_-3.fits 
asphistfile=acisf00459_ah4.fits[ASPHIST] obsfile=acisf00459_repro_evt2.fits 
engrid=grid(rmf.fits[cols ENERG_LO,ENERG_HI]) osipfile=CALDB dafile=CALDB 
pbkfile= maskfile=acisf00459_000N003_msk1.fits 
mirror=HRMA sourcepixelx=4122.22509765625 sourcepixely=4071.310546875
mode=hl verb=0
  *** WARNING: The ARF was computed to be zero at all the specified energies.
             This is probably due to an incorrect source position

   
Finished creating grating arfs for ccd_id= 4 5 6 7 
   
dmarfadd @thisfile.istemporary acisf00459HEG_-3_garf.fits
  
fullgarf finished. 


The aspect-related error from mkgarf may be ignored; it is explained in the fullgarf bug page. Read the "ARF was computed to be zero at all energies" section for an explanation of the final warning.

The content of the parameter file may be checked using plist fullgarf.

The script is run in a similar way for the remaining rows.


Fitting

At this point, you should have the spectra, gARFs, and gRMFs necessary for fitting the data. The Fitting Grating Data thread shows how to load the data and responses, define a model, and fit the spectra.

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 fitting the data in Sherpa, read the Grouping a Grating Spectrum thread for more information.


The "ARF was computed to be zero at all energies" Warning

When running mkgarf, a warning of this form may be printed:

*** WARNING: The ARF was computed to be zero at all the specified energies.
             This is probably due to an incorrect source position

There are a few possible situations that are causing this:

  1. An incorrect source position was input to the sourcepixelx and sourcepixely parameters. Confirm that the source position is correct, and re-run the tool if it's not.

  2. You are attempting to create a gARF for an order that does not fall on that plate, e.g. there is only a bit of negative orders on ACIS-S3.

  3. There are some cases where this happens because the mask truncates the order on a chip.

If none of these items resolves the problem, contact the CXC Helpdesk for assistance.



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


       phafile = acisf00459N004_pha2.fits Input PHA file (Type I or II)
        pharow = 1                Row in Type II PHA file (ignored if Type I)
       evtfile = acisf00459N004_evt2.fits Event file 
          asol = @pcad_asol1.lis Aspect offsets file
        engrid = grid(rmf.fits[cols ENERG_LO,ENERG_HI]) Energy grid spec
       dtffile =                  Dead time correction factor; ACIS->evt file; HRC -> dtf file
        badpix = acis_459_new_bpix1.fits Bad pixel file; (filename|NONE|CALDB)
      rootname = acisf00459       Output rootname
      maskfile = acisf00459_000N003_msk1.fits NONE, or name of ACIS window mask file
       (dafile = CALDB)            NONE, CALDB, or name of ACIS dead-area calibration file
     (osipfile = CALDB)           NONE or Name of fits file with order sorting info
      (clobber = no)              Clobber existing output files? This is passed to ALL child processes.
      (verbose = 0)               Control the level of diagnostic output. 0=>least.
         (mode = hl)              Mode flags.  Set to 'ql' to enable querying, 'hl' to suppress.
    

History

23 Dec 2004 updated for CIAO 3.2: canned gRMFs are no longer available in the CALDB, removed "Choosing an RMF" section
06 Dec 2005 updated for CIAO 3.3: the fullgarf script has been updated to version 3.3.1 for the new asphist tool syntax; corresponding changes to screen output
01 Dec 2006 reviewed for CIAO 3.4: no changes
26 Feb 2007 fullgarf v4.0.1: Four new parameters have been added, all of which are used by the mkgarf tool: pbkfile, dafile, osipfile, and maskfile; see "ahelp fullgarf" for details on each new parameter. Added ACIS dead area correction section
11 Jan 2008 updated for CIAO 4.0: fullgarf v4.1.1 (parameter updates for applying ACIS dead area correction, which is turned on by default); ACIS QE contamination link moved to "Related Links" section; removed outdated calibration information ; added "ARF was computed to be zero at all energies" section
30 May 2008 fullgarf v4.1.3 (Unix head and tail commands replaced by pget and dmkeypar); thread images are inline
12 Feb 2009 updated for CIAO 4.1: "ARDLIB warning ... Assuming the first "interesting" extension." no longer printed; input data must have a CTI_APP keyword
19 Feb 2009 added Fitting section
06 May 2009 check the version of the CIAO scripts package instead of the individual script
01 Jun 2009 fullgarf updated in 01 Jun 2009 scripts package: If bad pixel file is not supplied, use the one from the CALDB. Previously, the script would set the bad pixel file to "NONE" in this case.
16 Jun 2009 added About the Chandra Grating Data Archive and Catalog section
12 Jan 2010 updated for CIAO 4.2: ObsID 459 file versions and corresponding minor changes to screen output; calibration update - the ACIS QE contamination model has been upgraded to vN0005.
15 Dec 2010 updated for CIAO 4.3: new ACIS contamination calibration file
01 Mar 2011 CALDB 4.4.2 release: fix to the header of the ACIS QE contamination file. Prior to this release, CIAO would fail when trying to look up the contamination model correction for chips ACIS-8 (S4) and ACIS-9 (S5).
20 Jul 2011 required software updates are listed in Synopsis
10 Jan 2012 reviewed for CIAO 4.4: no changes
12 Mar 2012 it isn't necessary to set the fullgarf dtffile parameter for ACIS data, since the DTCOR value is retrieved from the evtfile in this case.
03 Dec 2012 Review for CIAO 4.5; no changes
24 Apr 2013 Add pointer to new mktgresp tool.
03 Dec 2013 Review for CIAO 4.6. pbkfile has been removed from fullgarf. The data used in this threads is from very early in the mission and must be reprocessed to be used in CIAO 4.6.
22 Dec 2014 Reviewed CIAO 4.7; minor edits only.
31 Jan 2022 Review for CIAO 4.14. Added note about Repro-5 data.