Filtering Data
[CIAO 3.4 Science Threads]
OverviewLast Update: 1 Dec 2006 - updated for CIAO 3.4: kernel parameter removed from dmgti Synopsis: The CIAO Data Model allows powerful filtering of datafiles. A file may be filtered on any of its columns, e.g. energy, time, position. Any (or none) of the filtering actions described in this thread may need to be performed on your dataset. Related Links:
|
Contents
- Get Started
- Restrict The Energy Range
- Using Exclude Filters
- Applying Time Filters
- Summary
- Parameter files:
- History
- Images
Get Started
Sample ObsID used: 1843 (ACIS-I, G21.5-0.9)
File types needed: evt2
Filtering is not restricted to the level=2 event file; in fact, filters are usually applied to the evt1.fits file when working with grating data.
Restrict The Energy Range
For most ACIS analyses, you will want to include at most the 0.3 kev to 10.0 kev energy range, as explained in the Choosing an Energy Filter why topic.
unix% punlearn dmcopy unix% dmcopy "acisf01843N001_evt2.fits[energy=300:10000]" acis_1843_evt2_0.3-10.fits
This command creates a new event file that only includes the data within the specified energy range.
Using Exclude Filters
It is also possible to create a filter based on what you do not want in the final file by using the exclude syntax:
unix% dmcopy "acisf01843N001_evt2.fits[exclude ccd_id=0:4,6,8:9]" acis_1843_evt2_bi.fits
This filter only keeps the back-illuminated chips (ccd_id=5,7).
Care must be taken when combining filters; this syntax WILL NOT WORK:
unix% dmcopy "acisf01843N001_evt2.fits[exclude sky=region(reg.fits)][energy=300:10000]" \ acis_1843_evt2_out.fits Failed to open virtual file acisf01843N001_evt2.fits[exclude sky=region(reg.fits)][energy=300:10000] DM Parse error: cannot mix EXCLUDE and FILTER
The second filter (on energy) must be rewritten in terms of an exclude for dmcopy to produce the desired output:
unix% dmcopy "acisf01843N001_evt2.fits[exclude sky=region(reg.fits),energy=:299,10000:]" \ acis_1843_evt2_out.fits
Applying Time Filters
For simple time filters, e.g. selecting a particular interval, the basic DM syntax may be used:
unix% dmcopy "acisf01843N001_evt2.fits[time=60413209:60414209]" acis_1843_evt2_1000s.fits
For more involved filters, use the CIAO tool dmgti. This tool allows the user to set constraints on the other (i.e. non-TIME) columns in the file and extract the set of times for which those constraints are true. A general outline of this process is given first, followed by a common filtering scenario in detail (Eliminate High Background Times).
Time Filtering in General
Applying time filters to an event file involves four primary steps:
-
Define the filter
Determine a filtering criterion that can be expressed as a valid dmgti userlimit parameter.
-
Create a Good Time Interval
A good time interval (GTI) indicates which data are "good", based on the chosen filter definition. The tool dmgti is used to create a GTI table:
unix% punlearn dmgti unix% pset dmgti infile=filename_mtl2.fits unix% pset dmgti outfile=myfilter_gti.fits unix% pset dmgti userlimit="<filtering criterion>" unix% dmgti
-
Apply the GTI table
Apply the GTI table to the event fits file with dmcopy:
unix% punlearn dmcopy unix% dmcopy "filename_evt2.fits[@myfilter_gti.fits]" filename_evt2_flt.fits
-
Verify filtering
Looking at the EXPO keyword is one way to see the results of filtering; this will show the amount of time that was eliminated in creating the filtered event file:
unix% dmlist event_filename.fits header | grep EXPO unix% dmlist event_filename_flt.fits header | grep EXPO
The tool dmkeypar may also be used to examine specific header keywords:
unix% dmkeypar event_filename.fits EXPOSUR7 echo+
Eliminate High Background Times
The Chandra Calibration team notes the following in its study of the ACIS background available from the Calibration page: "A phenomenon not anticipated prior to launch that can seriously affect the scientific value of an observation is background flares, when the count rate can increase by a factor of up to 100. Such flares have been observed anywhere in the orbit, including near the apogee." Therefore, eliminating high-background periods is another type of filtering that might be required for your data:
Here is one example of how to eliminate periods of high background. The ACIS background and Filtering lightcurves threads also discuss ways of filtering out flares.
-
View the image
An event file may be viewed directly by ds9:
unix% ds9 acis_1843_evt2_0.3-10.fits &
A log scale (Scale -> log) and some adjustment to the color table show the object and the background. It may also be necessary to adjust the blocking factor to view the whole image at once; try "Bin -> block 8" for a reasonable view.
-
Select the background area
From this image, regions may be created to define the background area. Select "Region -> Ellipse" from the ds9 toolbar, then hold down the left mouse button at the center of the field, and drag until the ellipse covers the desired area. Clicking on the resulting shape will select the region, allowing you to reposition or resize it; this FAQ shows how to rotate regions in ds9. This region is used for the example.
The defined region is saved using the following steps:
- Region -> File Format-> CIAO
- Region -> File Coordinate System -> Physical
- Region -> Save Regions... -> Save As "obj.reg"
The imaging (ds9) window may be closed by choosing "File -> Exit".
The resulting obj.reg file will look something like this:
unix% more obj.reg # Region file format: CIAO version 1.0 ellipse(1628,4116,100,140,0) # blue
-
Extract a background-only lightcurve
Now it is possible to create a background lightcurve by using the "virtual file" syntax. We do this by specifying the whole field, minus the source object(s). In this case, the ellipse that is defined in obj.reg is omitted; note that we could have also used the exclude syntax to ignore the source (i.e. "exclude sky=region(obj.reg)" in the infile parameter:
unix% punlearn dmextract unix% pset dmextract \ infile="acis_1843_evt2_0.3-10.fits[sky=field()-ellipse(1628,4116,100,140,0)][bin time=::3.24104]" unix% pset dmextract outfile=background_lc.fits unix% pset dmextract opt=ltc1 unix% dmextract Input event file (acis_1843_evt2_0.3-10.fits[sky=field()-ellipse(1628,4116,100,140,0)][bin time=::3.24104]): Enter output file name (background_lc.fits):
You can check the resulting parameter file with plist dmextract. Here the shorthand "sky" was used to specify x,y coordinates. Since "sky" is an alias of "(x,y)", both work in this context.
-
Examine the lightcurve and define a filter
The lightcurve that was just created can be plotted and examined in ChIPS:
unix% chips Welcome to ChIPS, version CIAO 3.4 Copyright (C) 1999-2003, Smithsonian Astrophysical Observatory chips> curve "background_lc.fits[cols time,count_rate]" chips> xlabel Time chips> ylabel "Background Count Rate"
Which produces Figure 2 . We can see that there is a spike in the lightcurve. The coordinates can be found with the ChIPS pickpoints command:
chips> pickpoints Click LMB or tap spacebar to pick point. Click RMB or type 'q' to quit picking points. Point picked: (84274280.000000, 84.512329) Point picked: (84274280.000000, 126.068245) chips> quit
Here we have marked the "top" and "bottom" of the spike.
To remove this feature from the dataset, we need to define a filter that excludes rates greater than ~85.0 counts/sec.
-
Create a Good Time Interval table
As mentioned before, the Good Time Interval (GTI) table contains the times during which the data are good, based on the filter definition. For this example, it will be the times when the count rate is below 85.0 counts/sec, as determined in the previous step:
unix% punlearn dmgti unix% pset dmgti infile=background_lc.fits unix% pset dmgti outfile=bkg_gti.fits unix% pset dmgti userlimit="count_rate <=85.0" unix% dmgti Input MTL file (background_lc.fits): Output GTI file (bkg_gti.fits): User defined limit string (count_rate <=85.0):
A more complex filter could be applied instead, such as "count_rate >= 5.5 && count_rate <=85.0"; see ahelp dmfiltering for other examples of filtering syntax.
You can check the resulting parameter file with plist dmgti.
-
Apply the GTI table
To apply the GTI table to the dataset, dmcopy is run:
unix% dmcopy "acis_1843_evt2_0.3-10.fits[@bkg_gti.fits]" acis_1843_evt2_0.3-10_bkgflt.fits
-
Verify filtering
Examination of the EXPO keywords shows the amount of filtering that was done in the creation of the new event file:
unix% dmlist acis_1843_evt2_0.3-10.fits header | grep EXPO 0082 EXPOSUR0 7857.6259545448 [s] Real8 [s] Total exposure time, with all 0085 EXPOSUR1 7857.6259545448 [s] Real8 [s] Total exposure time, with all 0088 EXPOSUR2 7857.6259545448 [s] Real8 [s] Total exposure time, with all 0091 EXPOSUR3 7854.4664748687 [s] Real8 [s] Total exposure time, with all 0094 EXPOSUR6 7857.6259545448 [s] Real8 [s] Total exposure time, with all 0097 EXPOSUR7 7857.6259545448 [s] Real8 [s] Total exposure time, with all 0100 EXPOSURE 7857.6259545448 [s] Real8 [s] Total exposure time, with all unix% dmlist acis_1843_evt2_0.3-10_bkgflt.fits header | grep EXPO 0081 EXPOSUR0 7825.6259545417 [s] Real8 [s] Total exposure time, with all 0084 EXPOSUR1 7825.6259545417 [s] Real8 [s] Total exposure time, with all 0087 EXPOSUR2 7825.6259545417 [s] Real8 [s] Total exposure time, with all 0090 EXPOSUR3 7822.4664748655 [s] Real8 [s] Total exposure time, with all 0093 EXPOSUR6 7825.6259545417 [s] Real8 [s] Total exposure time, with all 0096 EXPOSUR7 7825.6259545417 [s] Real8 [s] Total exposure time, with all 0099 EXPOSURE 7825.6259545417 [s] Real8 [s] Total exposure time, with all
Summary
The result of this thread is the level=2 event file acis_1843_evt2_0.3-10_bkgflt.fits, which is filtered for high background and restricted to a specific energy range.
Parameters for /home/username/cxcds_param/dmextract.par #-------------------------------------------------------------------- # # DMEXTRACT -- extract columns or counts from an event list # #-------------------------------------------------------------------- infile = acis_1843_evt2_0.3-10.fits[sky=field()-ellipse(1628,4116,100,140,0)][bin time=::3.24104] Input event file outfile = background_lc.fits Enter output file name (bkg = ) Background region file or fixed background (counts/pixel/s) subtraction (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 = ltc1) 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) |
Parameters for /home/username/cxcds_param/dmgti.par infile = background_lc.fits Input MTL file outfile = bkg_gti.fits Output GTI file userlimit = count_rate <=85.0 User defined limit string (mtlfile = none) Optional output smoothed/filtered MTL file (lkupfile = none) Lookup table defining which MTL columns to check against (NONE|none|<filename>) (smooth = yes) Smooth the input MTL data? (clobber = no) Clobber output file if it exists? (verbose = 0) Debug level (mode = ql) |
History
14 Dec 2004 | reviewed for CIAO 3.2: no changes |
01 Dec 2005 | updated for CIAO 3.3: default value of dmextract error and bkgerror parameters is "gaussian", update to screen output in "Verify filtering" step of the Eliminate High Background Times section |
01 Dec 2006 | updated for CIAO 3.4: kernel parameter removed from dmgti |