NAME

xtdflagpix - Flag pixel STATUS for XRISM Xtend event data

USAGE

xtdflagpix infile outfile outbadimg hotpixfile flickpixfile

DESCRIPTION

The task xtdflagpix flags Xtend events that may be unsuitable to use in data analysis, such as those that fall on defective or non-sensitive pixels, those that might have missing or compromised telemetry, and those for which processing has encountered certain errors. The STATUS column in the input events file is updated, encoding the flagging condition for each event. This tool does not actually filter or remove events. However, the STATUS column can be used for later filtering. An image in DET coordinates showing the location of unsuitable pixels is also output for later use in constructing an ARF or flat field image.

The tool uses several input files to assign STATUS: a list of bad or dead pixels or columns that don't change ('badpixfile'); a list of hot pixels, which can change on short timescales and are observation-specific ('hotpixfile'); a list of flickering pixels, which can be produced by the task searchflickpix ('flickpixfile'); and a mask file that encodes the location of CCD boundaries, segments, calibration source regions, and other regions that don't change ('maskfile'). The locations of the charge injection rows are read from the input event list header, as are settings for window mode and area discrimination (non-active areas of the CCD).

In addition to an output event list with updated STATUS column, the xtdflagpix task optionally outputs a bad pixel list (specified by the parameter 'outbadpix') containing the events that have any STATUS flag set by the task. Also output is an image (specified by the parameter 'outbadimg') in Xtend DET coordinates containing a value for each pixel corresponding to its STATUS. The values in these files are, in order of increasing precedence:

   0: a good pixel
   1: a pixel inside the calibration source region
   2: a bad pixel set by the parameter 'bad_status'
  -1: a pixel out of the CCD, window, or area discrimination region

For example, a pixel inside the calibration region but flagged as bad has value 2 in the output image. Flickering pixels are not included in this map because they can depend on time. Note that the output bad pixel list contains only those pixels for which events are found in the input file, while the output image contains all pixels, including those without events, since the image is used to determine the good area of the Xtend field of view.

Below is a table mapping flag position in the STATUS column to particular flagging conditions. If a STATUS flag is set to 1, the condition associated with that is considered to be flagged. Unless otherwise noted, the STATUS values apply to the central pixel of an event. Tools other than xtdflagpix that set STATUS values are noted in parentheses. CI indicates charge injection.

===========================================================================
STATUS Description
flag
===========================================================================
1      Any of the flags specified in 'bad_status' are set; a bad event
2      Inside the calibration source region
---------------------------------------------------------------------------
3      Out of CCD                                             (Out of area)
4      Out of window
5      Out of area discrimination
---------------------------------------------------------------------------
6      CI row                                                      (Pixels)
7      Bad pixel from CalDB
8      Bad column from CalDB
9      Hot pixel from pre-pipeline
10     Flickering pixel
---------------------------------------------------------------------------
11     CCD boundary                                            (Boundaries)
12     Window boundary
13     Segment boundary
14     Area discrimination boundary
15     At least one 3x3 surrounding pixel has a bad status
---------------------------------------------------------------------------
16     CI trailing row in rows specified by 'citrailnbr'        (Neighbors)
17     CI preceding row in rows specified by 'ciprenbr'
18     Preceding/following pixel in a partial bad column
19     Neighbors of bad/hot pixel and bad column
20     Neighbors of flickering pixel
21     Neighbors preceding/following a bad column
22     Neighbors of CCD/window boundary
23     Neighbors of segment boundary
---------------------------------------------------------------------------
24     (xtdphas) 3x3 info is present, but 5x5 is absent             (Others)
25     (xtdphas) 3x3 is absent
26     (xtdpi - general) PHAS[0] < event threshold
27     (xtdpi - vtevnodd) Video temperature is out of range
28     (xtdpi - vtevnodd) Lack of video temp HK at time close to the event
29     (xtdpi - chtrail/CTI) Correction value is negative
30     (xtdpi - general) Null value by correction process
---------------------------------------------------------------------------
31     1st trailing row of the CI rows                        (Diagnostics)
32     1st preceding row of the CI rows
33     2nd trailing row of the CI rows
34     2nd preceding row of the CI rows
35     3rd trailing row of the CI rows
36     3rd preceding row of the CI rows
---------------------------------------------------------------------------
37     Cosmic ray echo pixel                                  (Cosmic Rays)
---------------------------------------------------------------------------
38-48  Reserved
===========================================================================

The special STATUS flag 1 is set to 1 for an event that has any STATUS flag set out of the list given by the 'bad_status' parameter. This is an OR'd list, so any flag listed in 'bad_status' that is set will cause STATUS flag 1 to be set as well. Such events are considered bad, and this facilitates easy filtering later in the processing, allowing good events to be extracted with a single filter expression like "STATUS[1]==b0".

Several STATUS conditions apply to events where neighboring pixels are flagged. Because an event is composed of a 3x3 pixel island, the quality of the region immediately surrounding the event center must be taken into account. For example, a bad pixel in the outer ring of a 3x3 island does not produce a valid pulse height, and this could result in an event with an otherwise unacceptable grade being accepted as a good event. The parameters 'npixnbr' and 'nboundnbr' can be used to set the maximum distance away from a bad pixel or boundary to flag further pixels and events. In addition, for more flexibility, xtdflagpix writes a new column, PHAS_MASK, to the output event list. This is a 9-element mask of the PHAS column with each element indicating whether the corresponding pixel i in PHAS is good (PHAS_MASK[i]=0) or bad (PHAS_MASK[i]=1). PHAS_MASK can be used later in the xtdpi task to determine how to grade the event and calculate the summed PHA using the xtdpi 'badpixopt' parameter. Since xtdpi can overwrite the PHAS column, the ability to reset it to the original telemetry values is provided here with the 'copyphas' parameter. Similarly, 'resetflags' can be used to reset all the xtdflagpix STATUS flags and the elements of PHAS_MASK to zero. Using 'resetflags=yes' does not change the flags shown above that are set by xtdpi or xtdphas.

Some pixels are affected by cosmic ray echo, in which a cosmic ray detected during an Xtend dark frame can cause an echo in a different readout segment. This echo then causes those pixels to have a pulse height above the split threshold for the duration of the observation, leading to incorrect grades for events centered in neighboring pixels. This can be corrected for by flagging such events using the 'echoflag' parameter, which is a comma-separated list of values specifying which CCD segments to search for such pixels, with "1" turning on the flagging, and "0" turning it off. If at least a fraction ('echofrac') of the events containing a given pixel have a pulse height greater than or equal to 'echospth' in that pixel, then the pixel is considered a cosmic ray echo pixel. Any events centered 'echonbr' pixels from such pixels have STATUS flag 37 set, and if flag 37 is specified in 'bad_status', any pixels within 'echonbr' of that pixel will be marked as bad in 'outbadimg'. For Xtend, 'echonbr=2' is the recommended value, which will flag a 5x5 area of pixels around any cosmic ray echo pixel. Only pixels that have data from at least 'echomin' events are considered. An image of the echo fraction can be written out as an extension to 'outbadimg' if this flagging is performed for any segment. This image can be used for diagnostic purposes.

Charge trailed or leaked from charge injection rows can produce spurious events in several rows immediately surrounding the injected rows, manifesting as noise at low energies. The parameters 'citrailnbr' and 'ciprenbr' can be used to tune a compromise between lower noise and higher efficiency, since flagging additional rows reduces the effective area. These will set flags 16 and 17 for affected pixels. Flags 31 to 36 can be used to flag specific CI trailing and preceding rows rather than a range, and are for diagnostic purposes only.

Some examples of how to use the STATUS flags in filtering and extracting events are shown below (see examples section). See the help file for calc_express for proper filtering syntax.

PARAMETERS

infile [filename]
Name of input Xtend FITS event list.

outfile [filename]
Name of output Xtend FITS event list.

(outbadpix = NONE) [filename NONE|file name]
Name of output list of events with bad pixels. If set to NONE, the task does not output this file.

outbadimg [filename NONE|file name]
Name of output image containing the bad pixel status. If set to NONE, the task does not output this file. If 'echoflag!=0,0,0,0,0,0,0,0' and 'echomap=yes', then this output file also contains a map of the fraction of cosmic ray echo pixels in the first image extension. Note, 'outbadimg' is used as input to xaexpmap ('badimgfile') in order to create an exposure map for Xtend.

(badpixfile = CALDB) [filename CALDB|NONE|file name]
Name of input bad pixel list. If set to CALDB, the file is read from the calibration database. If set to NONE, the task does not use this calibration information.

hotpixfile [filename NONE|file name]
Name of observation-specific input hot pixel list. If set to NONE, the task does not use this information.

flickpixfile [filename NONE|file name]
Name of observation-specific input flickering pixel list. If set to NONE, the task does not use this information.

(maskfile = CALDB) [filename CALDB|file name]
Name of input mask file for the calibration sources and boundary regions. If set to CALDB, the file is read from the calibration database.

(npixnbr = 1) [integer]
Distance in pixels from a hot pixel, bad pixel, or bad column to flag a neighbor pixel.

(nboundnbr = 1) [integer]
Distance in pixels from a boundary to flag a neighbor pixel.

(citrailnbr = 2) [integer]
Distance in pixels trailing a charge injection (CI) row to flag a neighbor pixel.

(ciprenbr = 1) [integer]
Distance in pixels preceding a CI row to flag a neighbor pixel.

(echoflag = "0,0,0,0,0,0,0,0") [string]
Switches to turn cosmic ray echo flagging on for each CCD segment. The order corresponds to CCD_ID-SEGMENT = 0-0, 0-1, 1-0, 1-1, 2-0, 2-1, 3-0, 3-1. If a switch is set to 1, cosmic ray echo pixels are flagged in that segment, otherwise they are not.

(echonbr = 2) [integer]
Distance in pixels from a cosmic ray echo pixel to flag a neighbor pixel. If 'echoflag=0,0,0,0,0,0,0,0', this parameter is ignored.

(echomin = 6) [integer]
Minimum number of events for the cosmic ray echo fraction calculation. If 'echoflag=0,0,0,0,0,0,0,0', this parameter is ignored.

(echospth = 15) [integer]
Split threshold for cosmic ray echo fraction calculation. If 'echoflag=0,0,0,0,0,0,0,0', this parameter is ignored.

(echofrac = 0.7) [double]
Minimum fraction of hits defining a cosmic ray echo pixel. For any pixel contained in at least 'echomin' events, if at least a fraction 'echofrac' of those events have a pulse height above 'echospth', then the pixel is considered a cosmic ray echo pixel. If 'echoflag=0,0,0,0,0,0,0,0', this parameter is ignored.

(echomap = no) [boolean yes|no]
If set to yes, the cosmic ray echo pixel fraction map is output. This is an image in DET coordinates that shows the fraction of pixels with pulse height above 'echospth' and can be used for diagnostic purposes. The image is saved as the first extension in 'outbadimg'. If 'outbadimg=NONE' or 'echoflag=0,0,0,0,0,0,0,0', this parameter is ignored.

(gtifile = NONE) [filename NONE|file name]
Name of user-generated input GTI file for cosmic ray echo fraction calculation. If a file is specified, the first extension labeled 'GTI' will be read, and only events within this GTI are used to determine which pixels are affected by cosmic ray echo. If set to NONE, all events in 'infile' are used.

(bad_status = 3:9,11:12,16:19,25:28,30,37) [string]
List of STATUS flags which are considered bad. If any of these flags are set to 1 for an event, then STATUS flag 1 will also be set to 1 for that event. Colons can be used to specify a range (e.g., 3:5,7 = 3,4,5,7).

(copyphas = yes) [boolean yes|no]
If set to yes, the task copies the original PHAS column before processing. This overwrites the PHAS column with the contents of PHAS_INNER3X3, which is the original telemetered pixel pulse heights of the 3x3 event island.

(resetflags = yes) [boolean yes|no]
If set to yes, the task resets all xtdflagpix STATUS flags (i.e. only flags 1-23 and 31-48 are reset to 0).

(buffer = -1) [integer -1|0|N]
Rows to buffer (-1=auto, 0=none, N>0=number of rows).

(clobber = no) [boolean yes|no]
Overwrites the existing output file if set to yes

(chatter = 1) [integer 0|1|2|3]
Chatter level for output. Set to 0 to suppress output, or to 1, 2, or 3 for increasing the chatter of the output.

(logfile = !DEFAULT) [string]
Log file name. If set to DEFAULT, uses the name of the task and, if preceded by "!", overwrites the file if it exists. If set to NONE, no log file is created.

(debug = no) [boolean yes|no]
Diagnostic output is printed to the screen if set to yes.

(history = yes) [boolean yes|no]
Records task parameters in HISTORY.

EXAMPLES

  1. Run xtdflagpix with default parameters and using input files from a representative OBSID 100050020.
    xtdflagpix infile=xa100050020xtd_p0100004b0_uf.evt outfile=output.evt outbadimg=outbadimg.fits \
         hotpixfile=xa100050020xtd_a0100004b0.hpix flickpixfile=xa100050020xtd_a0100004b0.fpix
    
  2. Run xtdflagpix without bad pixel and flickering pixel files. Input files are representative of a XRISM observation with OBSID 100050020.
    xtdflagpix infile=xa100050020xtd_p0100004b0_uf.evt outfile=output.evt outbadimg=outbadimg.fits \
         hotpixfile=xa100050020xtd_a0100004b0.hpix flickpixfile=NONE badpixfile=NONE
    
  3. Run xtdflagpix with more restrictive flagging of rows neighboring the charge injection rows. Input files are representative of a XRISM observation with OBSID 100050020.
    xtdflagpix infile=xa100050020xtd_p0100004b0_uf.evt outfile=output.evt outbadimg=outbadimg.fits \
         hotpixfile=xa100050020xtd_a0100004b0.hpix flickpixfile=xa100050020xtd_a0100004b0.fpix \
         citrailnbr=4 ciprenbr=2
    
  4. Run xtdflagpix with non-default bad_status setting. Input files are representative of a XRISM observation with OBSID 100050020.
    xtdflagpix infile=xa100050020xtd_p0100004b0_uf.evt outfile=output.evt outbadimg=outbadimg.fits \
         hotpixfile=xa100050020xtd_a0100004b0.hpix flickpixfile=xa100050020xtd_a0100004b0.fpix \
         bad_status=3:9,11:12,16
    
  5. After running xtdflagpix, extract only those events from the output, which are "good", i.e. which have STATUS flag 1 set to 0. Note the use of a vector element, which in this case is STATUS[1] to get flag 1. Also note the bit mask, b0.
    ftcopy output.evt[events][STATUS[1]==b0] output_filtered.evt
    
  6. After running xtdflagpix, extract good events (STATUS flag 1 = 0) only in the calibration source regions (STATUS flag 2 = 1).
    ftcopy output.evt[events][STATUS[1]==b0 && STATUS[2]==b1] output_filtered.evt
    
    Another way to do the same filtering is to use the bxxx bit mask notation, which is explained fully under the help for calc_express:
    ftcopy \
         output.evt[events][STATUS==b01xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] \
         output_filtered.evt
    
    The wild card "x" indicates any value is allowed.

SEE ALSO

searchflickpix, xtdphas, xtdpi, calc_express, xaexpmap

LAST MODIFIED

February 12, 2024