Synopsis
Subtract the background estimate from a data set.
Syntax
subtract(id=None) id - int or str, optional
Description
The subtract function performs a channel-by-channel subtraction of the background estimate from the data. After this command, anything that uses the data set - such as a plot, fit, or error analysis - will use the subtracted data. Models should be re-fit if subtract is called.
Examples
Example 1
Background subtract the default data set.
>>> subtract() >>> get_data().subtracted True
Example 2
Remove the background from the data set labelled 'src':
>>> subtract('src') >>> get_data('src').subtracted True
Example 3
Overplot the background-subtracted data on the original data for the default data set:
>>> plot_data() >>> subtract() >>> plot_data(overplot=True)
PARAMETERS
The parameter for this function is:
Parameter | Definition |
---|---|
id | The identifier for the data set to use. If not given then the default identifier is used, as returned by `get_default_id` . |
Notes
Unlike X-Spec, Sherpa does not automatically subtract the background estimate from the data.
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 of the PHA file, is the ratio of data extraction area to total detector area.
The subtracted field of a dataset is set to True when the background is subtracted.
Bugs
See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.
See Also
- data
- get_bkg, get_bkg_arf, get_bkg_model, get_bkg_rmf, get_bkg_source, set_bkg, unsubtract
- info
- list_bkg_ids, show_bkg_model, show_bkg_source
- modeling
- delete_bkg_model
- plotting
- plot_bkg, plot_bkg_chisqr, plot_bkg_delchi, plot_bkg_fit, plot_bkg_fit_delchi, plot_bkg_fit_resid, plot_bkg_model, plot_bkg_ratio, plot_bkg_resid, plot_bkg_source