Estimate Source Counts in an Event File
CIAO 4.16 Science Threads
Overview
Synopsis:
This quick method for estimating source counts may be useful as the first step in a more detailed analysis procedure. The thread is not intended to provide accurate photometric results; for that analysis, careful exposure and PSF corrections are necessary.
Purpose:
To estimate net source counts in user-defined regions of event lists or image files for HRC or ACIS imaging observations. Running this thread on LETG and HETG observations is not recommended.
Related Links:
-
The srcflux script automates the creation of regions, estimating source counts (with confidence intervals) and fluxes.
- Analysis Guide: HRC Imaging
-
Using CIAO Region Files thread: how to create and display region files on an event list.
- Creating Source and Background Files: this method could be used to create the source and background region files as well.
Last Update: 8 Feb 2022 - Review for CIAO 4.14. Updated for Repro-5 and CALDB 4.9.6.
Contents
- Getting Started
- Estimating Source Counts
- Parameter files:
- History
- Images
Getting Started
Download the sample data: 1838 (ACIS-S, G21.5-09)
unix% download_chandra_obsid 1838 evt2
There are essentially two steps required to estimate net counts:
-
Define source and background regions. The ds9 display tool is recommended for interactively creating these regions. Alternatively, a source list (e.g. the output of one of the detect tools or a list of objects from an astronomical catalog) may be used.
-
Use the CIAO tool dmextract to determine counts and number of pixels for each region and to compute net counts for the source regions that have associated background regions.
In the following examples, we restrict the energy range of the events:
unix% dmcopy "acisf01843N004_evt2.fits[energy=300:8000]" acis_1838_evt2.fits
Estimating Source Counts
dmextract can be used to bin on vector columns, such as sky. This allows it to perform spatial extractions in regions in order to extract counts. Optional background files and background regions may also be input, in which case dmextract will compute net counts as well. Errors can be computed using either Gaussian or Poisson statistics or input via a variance map. For more details on all of these options, refer to ahelp dmextract.
A Simple Example
Display the file:
unix% ds9 acis_1838_evt2.fits &
and create regions by left-clicking on the image. To designated the annulus as a Background region double click on it and select Property → Background; it will then be drawn with a dashed line. Then use the the Get Info... option in the Region menu to find out the dimensions of the regions. More information on creating and modifying regions is given in the Using CIAO Region Files thread.
This example uses a single source region circle(4060.8724,4239.33,20) and a background region annulus(4060.8724,4239.33,86,114), as displayed in Figure 1.
[Version: full-size]
Figure 1: Source and background regions
To extract counts in the source region and compute net counts:
unix% punlearn dmextract unix% pset dmextract infile="acis_1838_evt2.fits[bin sky=circle(4060.8724,4239.33,20)]" unix% pset dmextract outfile=1838_simple.fits unix% pset dmextract bkg="acis_1838_evt2.fits[bin sky=annulus(4060.8724,4239.33,86,114)]" unix% pset dmextract opt=generic unix% dmextract Input event file (acis_1838_evt2.fits[bin sky=circle(4060.8724,4239.33,20)]): Enter output file name (1838_simple.fits):
The contents of the parameter file may be checked using plist dmextract.
The counts and net_counts may be found by using dmlist:
unix% dmlist "1838_simple.fits[HISTOGRAM][cols counts,net_counts]" data -------------------------------------------------------------------------------- Data for Table Block HISTOGRAM -------------------------------------------------------------------------------- ROW COUNTS NET_COUNTS 1 7792.0 7746.2857142857
CIAO Analysis menu in ds9
The net counts can also be obtained directly in ds9 using the CIAO analysis menu in ds9, aka dax.
From ds9 select the top-level Analysis menu and then CIAO. This is the top level menu of all the CIAO tasks that are available in ds9.
To get the net counts, simply go to Statistics and then Net Counts.
ds9 will then run dmextract with the data that are loaded and with the regions displayed. The results are displayed in a new text-window as shown in Figure 2.
Figure 2: dax Net Counts
It is important that the background annulus be designated as background so that the tools can compute the proper net counts.
Regions vs. Stacks of Regions
Region descriptors may also be input via files, rather than typed on the command line:
unix% cat source.reg circle(4060.8724,4239.33,20) unix% cat background.reg annulus(4060.8724,4239.33,86,114) unix% dmextract infile="acis_1838_evt2.fits[bin sky=region(source.reg)]" outfile=1838_simple_2.fits \ bkg="acis_1838_evt2.fits[bin sky=region(background.reg)]" opt=generic
However, if you want to extract counts from a number of source regions contained in a single file, then you must input the region file as a stack. If you have two region files:
unix% more stack.reg circle(4060.8724,4239.33,20) circle(4244,4094,6) unix% more stackbgd.reg annulus(4072.96,4248.00,40,60) annulus(4244,4094,10,30)
then to compute net counts in each region separately:
unix% dmextract infile="acis_1838_evt2.fits[bin sky=@stack.reg]" outfile=1838_stack.fits \ bkg="acis_1838_evt2.fits[bin sky=@stackbgd.reg]" opt=generic
Examine the output with dmlist, as before:
unix% dmlist "1838_stack.fits[cols counts,area,bg_counts,bg_area,net_counts,net_err]" data -------------------------------------------------------------------------------- Data for Table Block HISTOGRAM -------------------------------------------------------------------------------- ROW COUNTS AREA BG_COUNTS BG_AREA NET_COUNTS NET_ERR 1 7792.0 1256.6370614359 5057.0 6283.1853071796 6780.60 89.4107376102 2 3.0 113.0973355292 119.0 2513.2741228718 -2.3550 1.8002708130
If you use the sky=region(stack.reg) syntax:
unix% dmextract infile="acis_1838_evt2.fits[bin sky=region(stack.reg)]" outfile=1838_region.fits \ bkg="acis_1838_evt2.fits[bin sky=region(stackbgd.reg)]" opt=generic
dmextract will interpret the list of regions as a single, connected region. Using this syntax with verbose > 0 will print a warning:
# dmextract (CIAO): dsDMEXTRACTREGCOMPWERR -- WARNING:Region #1 contains more than 1 component. Only the first component will be described in the region columns of the output file.
This returns a single row with the sum of the counts in all the individual regions:
unix% dmlist "1838_region.fits[cols counts,area,bg_counts,bg_area,net_counts,net_err]" data -------------------------------------------------------------------------------- Data for Table Block HISTOGRAM -------------------------------------------------------------------------------- ROW COUNTS AREA BG_COUNTS BG_AREA NET_COUNTS NET_ERR 1 7795.0 1369.7343969651 5176.0 8796.4594300514 6989.0228571429 88.9972030746
Exposure Corrections
Exposure maps may be applied to both source and background regions. In this case, in the calculation of the net counts from the source, the background counts are normalized not only by the ratio of the areas of the source and background regions, but also by the ratio of the mean exposures in the source and background regions (be sure to read the caveat at the end of this section). The following threads give complete instructions on generating exposure maps:
- ACIS Exposure Map for a Single Chip
- ACIS Exposure Map for Multiple Chips
- HRC-I Exposure Map
- HRC-S Exposure Map
Both normalized [cm2*counts/photon] and unnormalized [cm2*sec*counts/photon] exposure maps may be used as input to dmextract. Bin the data to a FITS image and generate exposure maps that are congruent to that image. To isolate the S3 chip in this dataset:
unix% get_sky_limits flux_2.3_bin1.expmap verb=0 unix% pget get_sky_limits dmfilter X=3638.5:4748.5:#1110,Y=3844.5:4953.5:#1109 unix% dmcopy "acis_1838_evt2.fits[bin x=3638.5:4748.5:#1110,y=3844.5:4953.5:#1109]" 1838_s3.fits
Then run dmextract and examine the results:
unix% dmextract infile="1838_s3.fits[bin sky=@stack.reg]" outfile=1838_stackexp.fits \ bkg="1838_s3.fits[bin sky=@stackbgd.reg]" exp=flux_2.3_bin1.expmap bkgexp=flux_2.3_bin1.expmap opt=generic unix% dmlist "1838_stackexp.fits[cols counts,area,exposure,bg_counts,bg_area,net_counts]" data -------------------------------------------------------------------------------- Data for Table Block HISTOGRAM -------------------------------------------------------------------------------- ROW COUNTS AREA EXPOSURE BG_COUNTS BG_AREA NET_COUNTS 1 7739.0 1252.0 7851.3069951925 5201.0 6272.0 6700.7901785714 2 86.0 113.0 7851.3069951925 33.0 2516.0 84.5178855326
The NET_COUNTS are calculated as the counts in the source region [COUNTS] minus the counts in the background region [BG_COUNTS] (appropriately normalized by the areas [AREA/BG_AREA] and the mean exposure maps in source and background regions) and divided by the mean exposure map in the source regions.
Caveat on Exposure Corrections
Normalizing counts by mean exposure in regions may lead to errors if there are large exposure variations in the region which are not accompanied by similar variations in counts. Consider a bright point source at the center of a large region whose exposure varies strongly near the boundaries. That loss of exposure is not reflected in the counts, which are concentrated near the point source, but would strongly affect the mean exposure. In cases such as this, it is better to flat field the image by the exposure map and than extract flat-fielded counts in the region. A variance map should also be computed and used to calculate errors in the region.
Parameters for /home/username/cxcds_param/dmextract.par #-------------------------------------------------------------------- # # DMEXTRACT -- extract columns or counts from an event list # #-------------------------------------------------------------------- infile = acis_1838_evt2.fits[bin sky=circle(4072.96,4248.00,20)] Input event file outfile = 1838_simple.fits Enter output file name (bkg = acis_1838_evt2.fits[bin sky=annulus(4072.96,4248.00,86,114)]) Background region file or fixed background (error = gaussian) Method for error determination(poisson|gaussian|<variance file>) (bkgerror = gaussian) Method for background error determination(poisson|gaussian|<variance file>) (bkgnorm = 1.0) Background normalization (exp = ) Exposure map image file (bkgexp = ) Background exposure map image file (sys_err = 0) Fixed systematic error value for SYS_ERR keyword (opt = generic) Output file type: pha1 (defaults = ${ASCDS_CALIB}/cxo.mdb -> /soft/ciao/data/cxo.mdb) Instrument defaults file (wmap = ) WMAP filter/binning (e.g. det=8 or default) (clobber = no) OK to overwrite existing output file(s)? (verbose = 0) Verbosity level (mode = ql)
History
23 Dec 2004 | reviewed for CIAO 3.2: no changes |
19 Dec 2005 | updated for CIAO 3.3: default value of dmextract error and bkgerror parameters is "gaussian" |
01 Dec 2006 | updated for CIAO 3.4: CIAO version in warning |
16 Jan 2008 | updated for CIAO 4.0: ds9 now automatically looks for the "[SRCLIST]" extension in the region file, so it doesn't have to be specified; filename and screen output updated for reprocessed data (version N003 event file); replaced "Defining Source and Background Regions" section with a link to the Using CIAO Region Files thread |
25 Jun 2008 | updated image display to place figures inline with text |
06 Feb 2009 | updated for CIAO 4.1: made Caveat on Exposure Corrections a separate section |
09 Feb 2010 | reviewed for CIAO 4.2: no changes |
13 Jan 2011 | updated for CIAO 4.3: add opt=generic to dmextract command to avoid a warning message |
25 Jan 2012 | reviewed for CIAO 4.4: no changes |
03 Dec 2012 | Review for CIAO 4.5; no changes |
11 Dec 2013 | Review for CIAO 4.6; added link to new srcflux script |
22 Dec 2014 | Review for CIAO 4.7; no changes. |
18 Jul 2017 | Updated screen shot. Added section for getting counts directly in ds9. |
15 Nov 2021 | Removed prism for CIAO 4.14. |
08 Feb 2022 | Review for CIAO 4.14. Updated for Repro-5 and CALDB 4.9.6. |