The HRC-I Background Spectra Files
CIAO 4.10 Science Threads
The HRC calibration team has released a set of background spectra from the HRC-I. These spectra describe the particle background of the detector and vary slowly with time which means that they can be used to improve the signal-to-noise of HRC-I imaging data. This can significantly improve signal-to-noise for extended sources and may be useful for point source analysis (e.g. fields with many point sources).
The intent of this thread is to apply a PI (instrumental energy channel) filter to an HRC-I imaging event file to increase the signal-to-noise of the resulting images by removing channel ranges in which the particle background dominates. Calculating the cumulative source and background PI distributions allow us to estimate the fraction of source and background counts removed by a given PI filter.
To create an HRC-I background event file tailored to a specific observation for imaging or spatial analyses, follow the HRC-I Background Event Files thread instead.
- About the Instrument: HRC
The HRC Temporally Variable Background section of the Proposers' Observatory Guide, especially Figures 7.17, 7.19, 7.20, & 7.21
Pages 11-15 of the Imaging and Spectral Performance of the HRC by V. Kashyap and J. Posson-Brown
Last Update: 18 Dec 2014 - Reviewed for CIAO 4.7; no changes.
- Get Started
- Obtain the Response Files: ARF and RMF
- Choosing the Correct Background Spectrum File
- Compute the cumulative background distribution
- Compute the cumulative distributions for model spectrum
- Calculate the PI range
- Calculating the background reduction
- Apply the PI Filter
- Scripting It
Download the sample data: 9700 (HRC-I, Cas A)
unix% download_chandra_obsid 9700 evt2,asol,bpix,dtf
The HRC background spectra files are included in the main CALDB download file. In contrast to the background event files, there is no additional tarfile to download.
Obtain the Response Files: ARF and RMF
For the HRC-I, a single RMF file distributed in the CALDB is used (rather than an observation specific one as for ACIS). We make a soft link to the file for easier access:
unix% ln -s $CALDB/data/chandra/hrc/rmf/hrciD1999-07-22samprmfN0001.fits rmf.fits
Next we need to generate an observation-specific ARF file. To do this, we first create an asphist histogram, which is a binned representation of aspect motion during the observation. In some rare cases, there will be more than one aspect solution file (pcad_asol1.fits) for an observation. All the files must be input to the infile parameter, either as a list or as a stack. Here we use:
unix% cat pcad_asol1.lis pcadf322753908N003_asol1.fits unix% punlearn asphist unix% asphist infile=@pcad_asol1.lis outfile=9700_asphist.fits \ evtfile=hrcf09700N003_evt2.fits dtffile=hrcf09700_000N003_dtf1.fits
The aspect histogram is used as input to mkarf, which creates the ARF file. The source location is given as (16384.5,16384.5), the aimpoint of the HRC-I detector.
unix% pset ardlib AXAF_HRC-I_BADPIX_FILE=hrcf09700_bpix1.fits unix% punlearn mkarf unix% mkarf "9700_asphist.fits[ASPHIST]" 9700_arf.fits \ sourcepixelx=16384.5 sourcepixely=16384.5 \ engrid="grid(rmf.fits[cols ENERG_LO,ENERG_HI])" \ obsfile=hrcf09700N003_evt2.fits detsubsys=HRC-I mode=h
The resulting ARF file is named 9700_arf.fits.
Choosing the Correct Background Spectrum File
The HRC background spectral datasets are stored in the CALDB at $CALDB/data/chandra/hrc/pibgspec/. They are indexed by time and aimpoint:
unix% ls -1 $CALDB/data/chandra/hrc/pibgspec/ hrciD1999-10-04pibgspecN0001.fits hrciD2000-12-12pibgspecN0001.fits hrciD2002-01-26pibgspecN0001.fits hrciD2003-02-22pibgspecN0001.fits hrciD2004-11-25pibgspecN0001.fits hrciD2005-10-17pibgspecN0001.fits hrciD2006-09-20pibgspecN0001.fits hrciD2007-09-17pibgspecN0001.fits hrciD2008-09-07pibgspecN0001.fits hrciD2009-09-24pibgspecN0001.fits hrciD2010-09-25pibgspecN0001.fits hrciD2011-09-19pibgspecN0001.fits hrciD2012-09-27pibgspecN0001.fits hrciD2013-09-16pibgspecN0001.fits
The naming scheme is hrciD<date>pibgspecN<version>.fits.
The hrc_bkgrnd_lookup script makes it easy to find an HRC-I background file that matches your data. The script takes an input event file and the desired background filetype - event or spectrum (in this thread, always the latter) - and returns the background file:
unix% hrc_bkgrnd_lookup hrcf09700N003_evt2.fits spectrum /soft/ciao/CALDB/data/chandra/hrc/pibgspec/hrciD2007-09-17pibgspecN0001.fits
In addition to being printed to the screen, the background filename is also stored in the outfile parameter:
unix% pget hrc_bkgrnd_lookup outfile /soft/ciao/CALDB/data/chandra/hrc/pibgspec/hrciD2007-09-17pibgspecN0001.fits
The background file won't be edited, so we can simply link it from the working directory for easier access:
unix% ln -s $CALDB/data/chandra/hrc/pibgspec/hrciD2007-09-17pibgspecN0001.fits .
Compute the cumulative background distribution
The background spectrum is used to estimate the reduction in the background signal that the PI filtering will achieve.
unix% sherpa ----------------------------------------------------- Welcome to Sherpa: CXC's Modeling and Fitting Package ----------------------------------------------------- CIAO 4.4 Sherpa version 1 Friday, December 2, 2011 sherpa> load_data("hrciD2007-09-17pibgspecN0001.fits") sherpa> d = get_data() sherpa> pi = d.channel-1.0 sherpa> bgcumul = np.cumsum(d.counts) sherpa> bgcdf = bgcumul * 1.0 / bgcumul[-1] sherpa> add_curve(pi, bgcdf, ["symbol.style", "none"]) sherpa> set_plot_xlabel("PI") sherpa> set_plot_ylabel(r"\Sigma (counts \leq PI) / \Sigma counts") sherpa> set_plot_title(d.name.split("/")[-1])
Figure 1: Cumulative background distribution
Note that the calculation for bgcdf assumes that d.counts is >= 0, which should be safe here.
Compute the cumulative distributions for model spectrum
We assume that the source spectrum is unknown, so in order to select the PI range we use a soft and a hard spectrum to determine suitable lower and upper limits. For this thread we use an absorbed power law in both cases, varying the absorption and slope to maximize the relative flux at low or high energies, although other approaches are possible (in particular using a model similar to that of the source).
Set up an ARF and RMF
We use the background model which we have already loaded to define the channel grid, and add an ARF and RMF to it.
sherpa> load_arf("9700_arf.fits") sherpa> load_rmf("rmf.fits") sherpa> set_analysis("channel")
The set_analysis call is to ensure that the following modeling is done in PI channels rather than energy or wavelength units.
Set up the "soft" model
sherpa> set_source(xswabs.abs1*powlaw1d.pl) sherpa> abs1.NH = 0.001 sherpa> pl.gamma = 2.5 sherpa> add_window() sherpa> plot_model(overplot=False)
Figure 2: Plot of the soft model
Calculate the cumulative distribution
sherpa> scumul = np.cumsum(get_model_plot().y) sherpa> scdf = scumul / max(scumul) sherpa> current_window("win1") sherpa> add_curve(pi, scdf, ["symbol.style", "none", "line.color", "red"])
Figure 3: Cumulative distribution with the soft model
Here we add the cumulative distribution for the soft model to the original plot, so that it can be compared to that of the background spectrum.
Set up the "hard" model
sherpa> abs1.nh = 10 sherpa> pl.gamma = 1 sherpa> current_window("win2") sherpa> plot_model(overplot=True) sherpa> set_histogram(["line.color", "blue"])
Figure 4: Plot of the hard model
Calculate the cumulative distribution
sherpa> hcumul = np.cumsum(get_model_plot().y) sherpa> hcdf = hcumul / max(hcumul) sherpa> current_window("win1") sherpa> add_curve(pi, hcdf, ["symbol.style", "none", "line.color", "blue"])
Figure 5: Cumulative distribution with the hard model
Calculate the PI range
Various strategies could be employed to optimize the PI range. Ideally, we seek to maximize background reduction while minimizing loss of source events. In practice, the trade-off requires testing many different PI ranges and adopting one that suits best. One strategy is to require a certain amount of reduction in background, compute the appropriate PI range, and then estimate the magnitude of source event loss for a specific source model. Alternately, one could set forth an acceptable amount of source loss (sensible ranges are 1 to 10 per cent), compute the appropriate PI range, and then check how much of an improvement results in the background.
This thread follows the latter strategy. We will use a conservative strategy, and look to lose only 5% of source events, split equally over the low and high PI ranges. If xfrac is the fraction of events to exclude and is set to 5%, then we have
sherpa> xfrac = 0.05 sherpa> pimin = np.interp(xfrac/2, scdf, pi) sherpa> pimax = np.interp(1-xfrac/2, hcdf, pi) sherpa> lo = int(pimin) sherpa> hi = int(pimax) + 1 sherpa> print ("PI range: %d to %d" % (lo,hi)) PI range: 47 to 293
Here we chose to round the minimum limit down and the maximum limit up; routines in the Python math module, such as floor and ceil can be used to implement different rounding strategies.
The lo to hi range can then be used to filter the level=2 event file when creating images.
Calculating the background reduction
The PI range can be viewed by saying:
sherpa> current_window("win1") sherpa> add_vline(lo, ["line.color", "green"]) sherpa> add_vline(hi, ["line.color", "green"])
Figure 6: PI range overlaid on the models
and the fraction of the background that is excluded by these limits is calculated by:
sherpa> blo = np.interp(lo, pi, bgcdf) sherpa> bhi = 1.0 - np.interp(hi, pi, bgcdf) sherpa> bfrac = bhi + blo sherpa> print("Fraction of background excluded is %g" % bfrac) Fraction of background excluded is 0.242981
Filtering on the range PI=48:293 will reduce the background by ~25% while only losing ~5% of x-ray events.
Apply the PI Filter
The PI range 48:293 is applied to the file in a Data Model filter:
unix% punlearn dmcopy unix% dmcopy "hrcf09700N003_evt2.fits[pi=48:293]" hrcf09700_evt2_pi_flt.fits
A background annulus is defined around the source to check the number of "good" events in the filtered and unfiltered files:
unix% cat bkg.reg # Region file format: CIAO version 1.0 annulus(16368.483,16336.472,2731.4111,4097.1167) unix% dmstat "hrcf09700N003_evt2.fits[sky=region(bkg.reg)][cols pi]" ver=0 unix% pget dmstat out_good 54713 unix% dmstat "hrcf09700_evt2_pi_flt.fits[sky=region(bkg.reg)][cols pi]" ver=0 unix% pget dmstat out_good 42567
The percent change between the files is ~22% [(54713-42567)/54713 = 22], which is close to the 24% reduction we expected.
The file hrci.shp performs the Sherpa commands used in this thread. One could loop over different values of xfrac to find the optimal S/N improvement.
|10 Jun 2010||new for CIAO 4.2/CALDB 4.3.0|
|11 Jan 2011||reviewed for CIAO 4.3: no changes|
|04 Apr 2011||updated for 04 Apr scripts package release: hrc_bkgrnd_lookup script prints the version at verbose > 0.|
|20 Jul 2011||required software updates are listed in Synopsis|
|11 Jan 2012||reviewed for CIAO 4.4 and CALDB 4.4.7: the 2010 HRC-I background PI spectrum file was remade with the new gain map (hrciD2010-09-25pibgspecN0001.fits), and the 2011 file has been added (hrciD2011-09-19pibgspecN0001.fits); added Scripting It section|
|03 Dec 2012||Review for CIAO 4.5; file version name changes|
|03 Dec 2013||Review for CIAO 4.6; no changes.|
|14 Apr 2014||Minor edits to text to clarify when/how to use this thread. Updated list of CALDB files.|
|18 Dec 2014||Reviewed for CIAO 4.7; no changes.|