| AHELP for CIAO 4.5 Sherpa v1 | subtract |
Context: data |
Synopsis
Perform background subtraction
Syntax
subtract( id )
Description
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
TrueSubtract background counts for dataset "src". The "subtracted" field of the source data object is updated to show that the dataset has been background-subtracted.
Bugs
See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.
See Also
- data
- get_bkg, set_bkg, unsubtract
- info
- list_bkg_ids, show_bkg_model, show_bkg_source
- modeling
- delete_bkg_model
- plotting
- plot_bkg

![[Sherpa Logo]](../imgs/sherpa_logo_navbar.gif)