Back to eSASS task descriptions

eSASS task: APETOOL

eROSITA/apetool-1.23.1


Scope:

This document provides a description of parameters and instructions for the usage of the APETOOL task, which is part of eSASS (the eROSITA Science Analysis Software System).

Description:

The APETOOL has three main functionalities:

PSF maps:

The PSF of the eROSITA is modelled using shapelet functions and their corresponding coefficients. The shapelet model, stored in an appropriate calibration file, describes how the shape of the PSF changes as function of energy and position on the eROSITA field of view. The APETOOL combines this information with the attitude file of a given observation (event file) to generate a model of the exposure-time average PSF shape. This is then used to measure the size of the PSF in pixels at different encircled energy fractions (EEF). The EEFs at which the PSF size is measured correspond to the following EEF values:

EEF = (/0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95/)

The APETOOL estimates the PSF size in a regular grid of positions on the eROSITA field-of-view. The density of the grid is a tradeoff between speed, size of the final PSFMap and an adequate description of the variations of the PSF size across the field of view. The parameter that controls the density of the grid is PSFMAPSAMPLING, however in the current version of APETOOL this is not a user-defined parameter. Instead the PSF is estimated in a regular grid of 21x21 positions along the X and Y direction. This will be changed in future version of this task.

Aperture Photometry:

In the case of aperture photometry there are two options, either extract counts at source positions defined by an ERMLDET source catalogue or at arbitrary user-defined positions. The difference between the two options is the format of the input source list. In the first case, the ERMLDET source catalogue is supplemented with aperture photometry products (see below). The resulting source catalogue can then be combined with the APETOOL sensitivity maps. The case of aperture photometry at user-defined arbitrary source positions corresponds to science applications related to e.g. X-ray stacking analysis or searches for faint X-ray emission (i.e. below the formal X-ray detection threshold) associated with counterparts selected at other wavelengths or external (non-eROSITA) X-ray catalogues. The radii of the apertures, within which counts are extracted, are expessed in EEF units, i.e. the radius that corresponds to a user-defined encircled energy fraction (for example 0.7). For arbitrary source positions it is also possible to provide extraction radii in units of arcseconds. The logical flag APEXFLAG is set to True for aperture photometry at ERMLDET source catalogue positions. The flag STACKFLAG is set to True for aperture photometry at arbitrary user-define postions.

The aperture photometry requires the estimation of the expected background level within the extraction region. The background estimation should account for the extended PSF wings of nearby sources, i.e. confusion. The approach adopted by APETOOL to address this issue is to use the SourceMap products generated by ERMLDET. These are images of the model background plus a model of the detected sources, i.e. a model of the real observations. If the user-defined aperture lies close to a bright source then the SourceMap describes (at least to the first approximiation) the elevated local background because of the presence of the bright source. There are situations in which the input position of interest lies on an ERMLDET detected source. This is the case for example of ERMLDET source positions, when one is insterested in the sources' aperture photometry. In this case using the SourceMap to measure the local background is problematic because it contains the source of interest as "background". For that reason APETOOL has the functionality to remove model sources from the SourceMap. If an input position is closer than a user-defined radius (RR) to an ERMLDET source, then APETOOL generates a model of the ERMLDET source profile and subtracts it from the SourceMap leaving behind the "background" level only. Other ERMLDET sources with angular distance from the input position larger than the user-define radius RR are left intact on the SourceMap. Both the count extraction radius and the size of the region within which sources are subtracted from the SourceMap are defined in units of the Encircled Energy Fraction of the local PSF. Defining apertures in this way has the advantage that the extracted counts will correspond to a known EEF and therefore they can be corrected to the "total" source counts, i.e. those outside the aperture. The EEF accross the eROSITA field-of-vew is stoted into the PSFMap product of APETOOL.

If STACKFLAG is True then the file containing the input source positions is provided by the parameter APELIST. This should be a fits binary table with columns "RA" (degrees, Double Precision Real Number), "DEC" (degrees, Double), "RE" (Double) and "RR" (Double). The RA, DEC columns are the J2000 sky positions of the input sources in degree units. The RE column is the radius within which counts will be extracted from the input images and SourceMaps. The RR column corresponds to the radius within which sources in the input ERMLDET sourcelist (parameter MLLIST) near the input position are removed from the corresponding SourceMap before extracting background counts. Setting RR to zero means that no ERMLDET sources will be removed from the SourceMap prior to the background extraction. Both the RE and RR can be expressed in PSF Encircled Energy Fraction, i.e. they are less than unity (i.e. fraction). Alternatively if RE, RR are larger than unity they are interpreted as radii in units of arcseconds. The binary table of input positions should be stored into the second extension of the APELIST fits file. If STACKFLAG is true the aperture photometry results are stored in a fits file with filename controlled by the parameter APELISTOUT.

If the logical flag APEXFLAG is set to True then APETOOL updates the relevant columns (see below) of the input ERMLDET source list (given by parameter MLLIST). In this case the RE and RR have the same value controled by the parameter EEFEXTRACT (see parameter list below).

For both APEXFLAG=True and STACKFLAG=True, APETOOL updates/generates the following columns of the MLLIST/APELISTOUT file:

Sensitivity maps:

The sensitivity map provides an estimate of the minimum (integer) number of counts (source and background) within the extraction radius (expressed in Encircled Energy Fraction units) at a given position on the detector, so that the Poisson false detection probability is lower than a user-defined value defined by the parameter PTHRESH. The Poisson false detection probability is defined as the probability of the background fluctuating in a random fahsion to produce counts within an aperture above a given value. This probability is given by the survival function of the Poisson probability disribution and is described by the gamma funtions. The resulting sensitivity maps are consistent with the aperture photometry of ERMLDET sources. The extraction radius (in EEF units) can be viewed as a detection cell, within which sources are detected above a fixed Poisson false detection probability. A detailed description can be found in Georgakakis et al. 2008. The sensitivity map fits file includes three image extensions, (i) the sensitivity map itself, i.e. the minimum number of counts as described above at different detector positions, (ii) the expected background within the extraction radius, i.e. the integral of the ERMLDETECT SourceMap within the extraction aperture and (iii) the corresponding average exposure time (mean of the exposure map) within the extraction radius. With these three components it is possible to estimate the detection probability of a source with a given count-rate or flux. For full details see Georgakakis et al. 2008 and Ruiz et al. 2022. The resulting area or sensitivity curve is stored in the fourth (table) extension of the sensitivity map fits files. It inlcudes count rate and the corresponding area in deg2 within which a source of this count-rate can be detected. This calculation makes no assumptions about the X-ray spectral shape of the source.

Input Parameters:

Input files:

SEE ABOVE

Output files:

Examples of usage

Example 1

Generate sensitivity maps based on aperture photometry. Apertures are defined in units of Encircled Energy Fraction (EEF). The first product that needs to be generated is, therefore, a PSF map that provides a measure of the PSF size (in pixels) for different EEFs across the field of view. The creation of the PSF Map requires as input event lists. Information about the energy interval of interest to generate the correct PSF model is read from the event list header. The flag that controls the generation of PSF Maps is PSFMAPFLAG:
apetool images="events_image.fits" psfmaps="psf_map.fits" psfmapflag=yes"
In the case of multiple energy bands:
 
apetool images="events_image_01.fits events_image_02.fits events_image_03.fits" 
  psfmaps="psf_map_01.fits psf_map_02.fits psf_map_03.fits" psfmapflag=yes"
Caution: The parameter PSFMAPSAMPLING is currently not used. The PSF sizes are estimated in a grid of 21x21 positions along the X and Y axes (to be changed in future versions). The final product is a cube that contains PSF sizes in the grid above for the EEF values: 0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95. The next step is to generate a sensitivity map by setting the APESENSEFLAG to yes. The example below assumes that the sensitivity map will use an EEF of 0.65 and a Poisson False Detection Threshold of 4e-6.
apetool images="events_image.fits" \
  expimages="output_expmap.fits" bkgimages="bkg_map.fits" \
  psfmaps="psf_map.fits" srcimages="source_image.fits"\
  detmasks="detmask.fits" apesenseimages="sensitivity_map.fits" \
  apesenseflag="yes" pthresh=4e-6  eefextract=0.65

Example 2

Determine aperture photometry for sources detected by the ERMLDET by setting the flag APEXFLAG to True. Given the Maximum Likelihood catalogue produced by ERMLDET (MLLIST parameter), APETOOL extracts the counts, background and exposure time at the sources' positions within apertures with radii defined in units of EEF (EEFEXTRACT parameter). The SourceMap (SRCIMAGE parameter) is used to determine the local background of a given source **after** subtracting from the SourceMap the model of the source in question. For APETOOL to reproduce accurately the ERMLDET source model and subtract it from the SourceMap it needs to use the same CUTRAD parameter as the ERMLDET run that produced the SourceMap and catalogue. It is up to the user to ensure that this parameter matches the ERMLDET run input. Using the SourceMap to determine the local background means that the aperture photometry accounts for the contamination of extracted counts from photons associated with the PSF wings of nearby sources (source confusion). The aperture photometry is stored in the filename defined by the parameter APELISTOUT. It is a copy of all the information listed in mllist with the additional aperture photometry information. The parameter APELISTOUT can be the same as the MLLIST, in which case the mllist file will be overwritten. The relevant APETOOL call:
apetool mllist="mllist.fits" apelistout="mllist_ape.fits"\
  images="events_image.fits" expimages="output_expmap.fits"\
  bkgimages="bkg_map.fits" psfmaps="psf_map.fits" \
  srcimages="source_image.fits" detmasks="detmask.fits"\
  psfmapflag=no apexflag=yes emin="200" emax="600"\
  eefextract=0.65 cutrad=15 eindex="1"
The example above determines aperture photometry in a single band. If the corresponding ERMLDET source catalogue contains more bands, then APETOOL needs to know which rows of the ERMLDET source catalogue should update. The parameter EINDEX provides this information. In the example above it informs the APEtOOL that the aperture photometry corresponds to the first band in the ERMLDET catalolgue. It is of course possible to run all the bands simultaneously in which case the eindex parameter is not needed:
apetool mllist="mllist.fits" apelistout="mllist_ape.fits" \
  images="events_image_01.fits events_image_02.fits events_image_03.fits"\
  expimages="output_expmap_01.fits output_expmap_02.fits output_expmap_03.fits"\
  bkgimages="bkg_map_01.fits bkg_map_02.fits bkg_map_03.fits" \
  psfmaps="psf_map_01.fits psf_map_02.fits psf_map_03.fits" \
  srcimages="source_image_01.fits source_image_02.fits source_image_03.fits"\
  detmasks="detmask.fits" \
  psfmapflag=no apexflag=yes \
  emin="200 600 2300" \
  emax="600 2300 5000"\
  eefextract=0.65 cutrad=15

Example 3

Carry out aperture photometry at arbitrary positions by setting the STACKFLAG paramter to yes. The input file is given by the parameter APELIST and should be a fits binary table with columns RA (source's right ascension in degrees; expects double precision number), DEC (source's declication in units of degrees; expects double precision number), RE (extraction radius in EEF units; double precision), RR (source removal radius in units of EEF; double precision). The code uses the RA, DEC positions to extract counts, estimate the background and determine the mean exposure time within an aperture of radius RE. The background estimation is using the SourceMap of ERMLDET. Before estimating the background at a given input position, any detected sources (read from MLLIST) within a radius RR from the input position will be removed from the source map. The photoemetry is stored to the filename defined by the parameter APELISTOUT:
apetool mllist="mllist.fits" apelist="mllist_ape_in.fits"\
  apelistout="mllist_ape_out.fits" images="events_image.fits"\
  expimages="output_expmap.fits" bkgimages="bkg_map.fits"\
  psfmaps="psf_map.fits" srcimages="source_image.fits"\
  detmasks="detmask.fits" stackflag=yes emin="200" emax="600"\
  eefextract=0.65 cutrad=15 eindex="1"
The case of two bands (not yet fully tested):
apetool mllist="mllist.fits" apelist="mllist_ape_in.fits" apelistout="mllist_ape_out.fits"\
  images="events_image_01.fits events_image_02.fits events_image_03.fits"\
  expimages="output_expmap_01.fits output_expmap_02.fits output_expmap_03.fits"\
  bkgimages="bkg_map_01.fits bkg_map_02.fits bkg_map_03.fits"\
  psfmaps="psf_map_01.fits psf_map_02.fits psf_map_03.fits"\
  srcimages="source_image_01.fits source_image_02.fits source_image_03.fits"\
  detmasks="detmask.fits" stackflag=yes emin="200 600" emax="600 2300"\
  eefextract=0.65 cutrad=15 eindex="1 2"