Estimate Source Counts in an Image
![[CXC Logo]](../../imgs/cxc-logo.gif)
CIAO 4.2 Science Threads
Overview
Last Update: 9 Feb 2010 - reviewed for CIAO 4.2: no changes
Synopsis:
A quick means for estimating source counts, which may be useful as a first step in a more detailed analysis procedure. The thread is not intended to provide accurate photometric results, for which careful exposure and PSF corrections are necessary.
Purpose:
To estimate net source counts in user-defined regions of event lists or image files.
Read this thread if:
you would like to find the number of counts in an HRC or ACIS imaging observations; running this thread on LETG and HETG observations is not recommended.
Related Links:
- 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.
Contents
- Getting Started
- Estimating Source Counts
- Parameter files:
- History
- Images
Getting Started
Sample ObsID used: 1838 (ACIS-S, G21.5-09)
File types needed: 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 "acisf01838N002_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. 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(4072.96,4248.00,20) and a background region annulus(4072.96,4248.00,86,114), as displayed in Figure 1.
![[Thumbnail image: The source region (a circle) and background region (an annulus) are overlaid on the data.]](regions.thumb300.png)
[Version: full-size]
![[Print media version: The source region (a circle) and background region (an annulus) are overlaid on the data.]](regions.png)
Figure 1: Source and background regions
The source region is defined as a single circle: circle(4072.96,4248.00,20); the background region is an annulus: annulus(4072.96,4248.00,86,114).
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(4072.96,4248.00,20)]" unix% pset dmextract outfile=1838_simple.fits unix% pset dmextract bkg="acis_1838_evt2.fits[bin sky=annulus(4072.96,4248.00,86,114)]" unix% dmextract Input event file (acis_1838_evt2.fits[bin sky=circle(4072.96,4248.00,20)]): Enter output file name (1838_simple.fits):
The contents of the parameter file may be checked using plist dmextract.
The counts may be found by using dmlist:
unix% dmlist "1838_simple.fits[HISTOGRAM][cols counts]" data -------------------------------------------------------------------------------- Data for Table Block HISTOGRAM -------------------------------------------------------------------------------- ROW COUNTS 1 7733.0
Alternatively, prism may also be used to examine the output:
unix% prism 1838_simple.fits &
as shown in Figure 2.
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(4072.96,4248.00,20) unix% cat background.reg annulus(4072.96,4248.00,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)]"
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(4072.96,4248.00,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]"
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 7733.0 1256.6370849609 5193.0 6283.1855468750 6694.4000201780 89.1107176042 2 84.0 113.0973358154 32.0 2513.2741699219 82.5600000233 9.1686858381
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)]"
dmextract will interpret the list of regions as a single, connected region. Using this syntax with verbose > 0 will print a warning:
# dmextract (CIAO 4.2): 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 7817.0 1369.7343750 5225.0 8796.4589843750 7003.3928289682 89.1273822339
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% dmcopy "acis_1838_evt2.fits[bin x=3696.5:4720.5:1,y=3872.5:4896.5:1]" 1838_s3.fits
Use xygrid=3696.5:4720.5:#1024,3872.5:4896.5:#1024 in the mkexpmap step to create an unnormalized exposure map, s3_expmap.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=s3_expmap.fits bkgexp=s3_expmap.fits 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 = pha1) 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 N002 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 |