Chandra X-Ray Observatory
Skip to the navigation links
Last modified: November 2016

Jump to: Description · Examples · Bugs · See Also

AHELP for CIAO 4.9 Sherpa v1


Context: data


Perform background subtraction




The subtract command performs a channel-by-channel background subtraction on the data. In Sherpa, the subtract command must be issued to perfom background subtraction; it is not done automatically as it is in XSPEC.

  • id - the id of the dataset to subtract; if not given, uses the default dataset id (id=1 by default, see "ahelp get_default_id")

Background subtraction can only be performed when data and background are of the same length. If the data and background are ungrouped, both must have same number of channels. If they are grouped, data and background can start with different numbers of channels, but must have the same number of groups after grouping.

The equation for the subtraction is:

src_counts - bg_counts * (src_exposure * src_backscal)
                          (bg_exposure * bg_backscal)

where src_exposure and bg_exposure are the source and background exposure times, and src_backscal and bg_backscal are the source and background backscales. The backscale, read from the BACKSCAL header keyword, is the ratio of data extraction area to total detector area.

The "subtracted" field of the source dataset is updated to indicate that the data are background-subtracted, as shown in the examples.

To undo background subtraction, use the unsubtract command ("ahelp unsubtract").

Example 1

sherpa> subtract()

Subtract the background of the default dataset.

Example 2

sherpa> subtract("src")
sherpa> get_data("src").subtracted

Subtract background counts for dataset "src". The "subtracted" field of the source data object is updated to show that the dataset has been background-subtracted.


See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.

See Also

get_bkg, set_bkg, unsubtract
list_bkg_ids, show_bkg_model, show_bkg_source

Last modified: November 2016
Smithsonian Institute Smithsonian Institute

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email: Smithsonian Institution, Copyright © 1998-2017. All rights reserved.