If you wish to construct point source background spectra via the EXTRACT_BACKGROUNDS Stage (§7.13), or if you wish to study diffuse emission (§7.1.2), then you'll want to ``remove'' the point sources from your data by masking regions around each source. Masking is generally performed independently for each observation since the appropriate size of a source's mask depends on the off-axis angle at which it was observed.
All masking operations must be careful to preserve an accurate correspondence between the masked event list and the masked exposure map. One way to do this is to quantize the masking to the pixel grid of the exposure map, i.e. masking is done in quanta of exposure map pixels rather than over regions bounded by smooth geometric curves (e.g. circles).
First construct a mask region file for the entire catalog.
printf "# Region file format: DS9 version 3.0 \nfield()\n" > ../obs1875/mask.reg
grep -h background */1875/extract.reg | awk '{print "-",$1}' >> ../obs1875/mask.reg
Then apply the mask to your exposure map.
dmcopy "../obs1875/obs.emap[sky=region(../obs1875/mask.reg)][opt full,update=no]" \
../obs1875/background.emap
The option update=no above suppresses modification of the output file's ``data subspace'' to reflect the masking regions.
If you have a complex mask (i.e. many sources) and omit this option, then the resulting complex data subspace will cause subsequent CIAO commands run on the background files in EXTRACT_BACKGROUNDS stage to execute very slowly!
When your exposure maps is masked, discard events where the background exposure map is zero.
dmimgpick "../obs1875/spectral.evt[cols time,ccd_id,chip,det,sky,pi,energy]" \
../obs1875/background.emap temp.evt method=closest
dmcopy "temp.evt[#8>1]" ../obs1875/background.evt
Finally, since the event filter actually applied is a pixelized approximation to the circular masks you should review obs1875_background.evt to look for any unmasked source events, particularly on-axis where the mask circles are small.
ds9 -tile ../obs1875/background.emap -regionfile ../obs1875/mask.reg \
../obs1875/background.evt -regionfile ../obs1875/mask.reg &
The goal of this tool is to use large masks for bright sources and small masks for dim sources. The general method is to estimate, at each pixel location in the emap, the number of counts expected from the point sources in the catalog (saved as star_counts.img) and the number of background counts expected (saved as bkg_counts.img). Pixels are masked when
.
There is no statistical theory behind this algorithm; it just seems like a reasonable approach to us.
If you have additional masking you want to do (e.g. readout streaks) you can supply your own region file (in celestial coordinates) via the keyword EXTRA_MASKFILE. The remaining unmasked pixels are sorted by star_counts, and then processed in order of brightness. For each pixel, a local background is estimated (excluding of course any pixels already masked), the
ratio is computed, and the pixel is masked if necessary.
Note that both star_counts and bkg_counts are computed only under the footprints of source PSFs. Outside of those, star_counts is assumed to be zero, and bkg_counts is irrelevant. If the resulting background event list is later used for extraction of diffuse emission, the masked star_counts image provides at least some estimate of the contamination of the diffuse spectra arising from the incomplete masking of known point sources.
We recommend an exposure map pixel size of 1 sky pixel or smaller if ae_better_masking is to be used. Note however that ae_better_masking may require considerable time to execute for exposure maps with many pixels.
EXAMPLE:
idl
tee ae_better_masking_1875.log
ae_better_masking, '1875'
This tool builds models for all the sources in the catalog using single-observation photometry calculated by the MERGE_OBSERVATIONS stage of AE, then constructs a mask for each source.
as described above; the default value is 0.5.