Estimate Source Counts in an Image
[CIAO 3.4 Science Threads]
OverviewLast Update: 1 Dec 2006 - updated for CIAO 3.4: CIAO version in warning 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:
|
Contents
- Getting Started
- Estimating Source Counts
- Defining Source and Background Regions
- 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 "acisf01838N001_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
For another simple method of finding source counts, see the Using Analysis Scripts section of the SAOImage ds9 thread.
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 below. Consider a single source region circle(4072.96,4248.00,20) and background region annulus(4072.96,4248.00,86,114) as displayed in Figure 1 .
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 output may be examined using dmlist:
unix% dmlist "1838_simple.fits[HISTOGRAM]" cols,data -------------------------------------------------------------------------------- Columns for Table Block HISTOGRAM -------------------------------------------------------------------------------- ColNo Name Unit Type Range 1 sky(X,Y) pixel Real8 -Inf:+Inf Position 2 EQPOS(RA,Dec) deg Real8 -360.0: 360.0 Position 3 SHAPE String[16] Region shape type 4 R[2] pixel Real8(2) -Inf:+Inf Radius 5 ROTANG[2] pixel Real8(2) -Inf:+Inf Angle 6 COMPONENT Int2 - Component number 7 AREA pixel**2 Real4 -Inf:+Inf Area of extraction 8 EXPOSURE s Real8 -Inf:+Inf Exposure time of source file 9 COUNTS count Real8 -Inf:+Inf Counts 10 ERR_COUNTS count Real8 -Inf:+Inf Error on counts 11 COUNT_RATE count/s Real8 -Inf:+Inf Rate 12 COUNT_RATE_ERR count/s Real8 -Inf:+Inf Rate Error 13 BG_AREA pixel**2 Real8 -Inf:+Inf Background Area of Extraction 14 BG_EXPOSURE s Real8 -Inf:+Inf Exposure time of background file 15 BG_ERR count Real8 -Inf:+Inf Error on Background counts 16 BG_COUNTS count Real8 -Inf:+Inf Background Counts 17 BG_RATE count/s Real8 -Inf:+Inf Background Rate 18 BG_SUR_BRI count/pixel**2 Real8 -Inf:+Inf Background Counts per square pixel 19 BG_SUR_BRI_ERR count/pixel**2 Real8 -Inf:+Inf Error on background counts per square pixel 20 NET_COUNTS count Real8 -Inf:+Inf Net Counts 21 NET_ERR count Real8 -Inf:+Inf Error on Net Counts 22 NET_RATE count/s Real8 -Inf:+Inf Net Count Rate 23 ERR_RATE count/s Real8 -Inf:+Inf Error Rate 24 SUR_BRI count/pixel**2 Real8 -Inf:+Inf Net Counts per square pixel 25 SUR_BRI_ERR count/pixel**2 Real8 -Inf:+Inf Error on net counts per square pixel -------------------------------------------------------------------------------- World Coord Transforms for Columns in Table Block HISTOGRAM -------------------------------------------------------------------------------- ColNo Name 7: CEL_AREA = +0 [arcsec**2] +0.2421 * (AREA -0) 18: BG_CEL_BRI = +0 [count/arcsec**2] +4.1311 * (BG_SUR_BRI -0) 19: BG_CEL_BRI_ERR = +0 [count/arcsec**2] +4.1311 * (BG_SUR_BRI_ERR -0) 24: CEL_BRI = +0 [count/arcsec**2] +4.1311 * (SUR_BRI -0) 25: CEL_BRI_ERR = +0 [count/arcsec**2] +4.1311 * (SUR_BRI_ERR -0) -------------------------------------------------------------------------------- Data for Table Block HISTOGRAM -------------------------------------------------------------------------------- ROW sky(X,Y) EQPOS(RA,Dec) SHAPE R[2] ROTANG[2] COMPONENT AREA EXPOSURE COUNTS ERR_COUNTS COUNT_RATE COUNT_RATE_ERR BG_AREA BG_EXPOSURE BG_ERR BG_COUNTS BG_RATE BG_SUR_BRI BG_SUR_BRI_ERR NET_COUNTS NET_ERR NET_RATE ERR_RATE SUR_BRI SUR_BRI_ERR 1 ( 4072.960, 4248.0) ( 278.3893176799, -10.5692082869) Circle [ 20.0 0] [ 0 0] 1 1256.6370849609 7854.4664748687 7523.0 86.7352292901 0.95779898279160 0 17592.917968750 7854.4664748687 24.9198715888 621.0 0.07906329500380 0.03529829452414 0.00141647176625 7478.6428551599 86.7534919622 0.95215160432459 0.01104511582547 5.9513147787 0.06903623408891
The counts information is given in the last section of the output.
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% 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)]"
where
unix% cat source.reg circle(4072.96,4248.00,20) unix% cat background.reg annulus(4072.96,4248.00,86,114)
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 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 7523.0 1256.6370849609 5072.0 6283.1855468750 6508.5999848843 87.8969851932 2 94.0 113.0973358154 32.0 2513.2741699219 92.5600000620 9.6987009437
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 3.4): 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 7617.0 1369.7343750 5104.0 8796.4589843750 6822.2342722416 87.9815684090
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:
- Create an ACIS Exposure Map for a Single Chip
- Create an ACIS Exposure Map for Multiple Chips
- Create an HRC 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 7522.0 1252.0 7854.4664748687 5059.0 6272.0 6512.1358710676 2 93.0 113.0 7854.4664748687 31.0 2516.0 91.6077107005
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.
Defining Source and Background Regions
Source and background regions can easily be defined interactively for small numbers of regions. If the number of sources is large, however, it may be preferable to create a source list.
Interactive Definition
The event file may be viewed directly with ds9:
unix% ds9 acis_1838_evt2.fits &
To create a region, left-click once on the image. The default region shape is circle; to select a different shape, use the "Region -> Shape" menus in ds9. The shape must be set before creating the region. Click again to make the region "active;" in Figure 3 , the circular region is active, but the rectangular one is not.
To change the size of the region, click and drag on the anchor points which appear when the image is active.
To save the region:
- Create the region(s) to save.
- Region -> File Format-> Ciao
- Region -> File Coordinate System -> Physical
- Region -> Save Regions... -> Save As "source.reg"
Using a Source List
The source lists output by the detect tools can also be used to define regions for estimating source counts. These regions can be read into ds9 using the "Load Regions..." option (if given a FITS file, ds9 automatically looks for a block named REGION.) The source regions are saved in the SRCLIST block in the DETECT tools output. Note that the source list must end in .fits to be recognized by ds9.
To display the region, either rename the block to REGION:
unix% dmcopy "s3_img_src.fits[srclist][region]" sources.fits
or specify the block name when reading it into ds9:
Region -> Load Regions... -> s3_img.fits[srclist]
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 |