Extract source photons

Here is a script based on CIAO dmlist contributed by A. Ptak for extracting a 10"x10" region around each source from a wavdetect run. It reads the wavdetect source list FITS file, runs awk and sed (stream editor) to extract (x,y) coordinates, constructs a shell script with repeated dmcopy commands. It may be desirable to add "#!/bin/csh" and "source ~/.cxcds.csh" to the top of the test.sh output file.

dmlist Region_wav_srclst.fits data | awk 'NR>12 {print $6,","$1}' | sed s/\(// | sed s/\)// | awk -F, '{print "dmcopy \"../../../evt_files/MergeI0-3.fits\[events\]\[x="$1-10":"$1+10",y="$2-10":"$2+10"]\" Region_"$3".evt"}' > test.sh

If you can make an ASCII table containing the X/Y coordinates of sources, the desired extraction radius for each source, and an optional source name, then you can use this Perl script to run a series of dmcopy commands to extract a circular region around each source.  A ds9-compatible region file showing the circular extraction regions is produced.

All the events that do NOT fall within any of the circular extraction regions are optionally saved as an "background" event list which of course looks like the original dataset with a bunch of "holes" in it.  It might be useful to smooth such a background file to look for diffuse structures.
If you increase the values in the "radius" column of your ASCII source table, change the names in the "name" column, and run the script on the background event list, you'll extract a set of background annuli around your sources.  For a crowded field the advantage of this approach over an explicit annular extraction done on the original event list is that the background image has fewer sources that could contaminate the background extractions.  The disadvantage  is that the background image has lots of holes which might intersect your background annuli,  leaking to underestimation of the backgrounds.

The script will also optionally generate ARFs for each source position.  It attempts to handle sources which fall on multiple CCD's by computing an ARF for each CCD, then summing the ARFs.  It attempts to handle the fact that the integration time may vary strongly within the extraction region for sources near chip gaps by computing ARFs at several locations across the extraction region, then averaging the ARFs.

Here is an alternative procedure based on IDL developed by G. Chartas for extracting sources from one or more event files.
  1. First create an ASCII file with the exposure time (in seconds), x and y location of a reference source in the field, and the names of the event file(s) under consideration. Example (e.g. filename "infiles"):
  2. 5809. 4274.1 4116.9 acisf00472_001N001_evt2.fits
    4856. 4272.7 4110.9 acisf00476_001N001_evt2.fits
  3. Second, create an ASCII file with the (x,y) positions of the sources to be extracted, inner and outer radii (in pixels) of extraction circle and lannulus for local background determination. Note that the (x,y) values need to be obtained from the first events file listed in "infiles". Example (e.g. "sources"):
  4. Copy the IDL programs xtract.pro, par_get.pro and the parameter file xtract.par into your directory. Edit the parameter file using a UNIX editor or CIAO tool pedit:
  5. Run the IDL script, which will create XSPEC-compatible files (e.g. "srcname1.pha" and "srcname1.bkg.pha") and place them in the directory specified in xtract.par:
Remember it will be necessary to create appropriate art and rmf files for each source using CIAO tools.
It is advisable to test the stability of the aspect solution by taking the events extracted for a strong on-axis source and examining the distribution of offsets of photons from the source centroid as a function of time. We invite recipes for this task.