Subtract the background estimate from a data set.
subtractfunction 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
id (int or str, optional) – The identifier for the data set to use. If not given then the default identifier is used, as returned by get_default_id.
sherpa.utils.err.ArgumentErr – If the data set does not contain a PHA data set.
Unlike X-Spec 1, 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
BACKSCALheader keyword of the PHA file 2, is the ratio of data extraction area to total detector area.
subtractedfield of a dataset is set to
Truewhen the background is subtracted.
Background subtract the default data set.
>>> subtract() >>> get_data().subtracted True
Remove the background from the data set labelled ‘src’:
>>> subtract('src') >>> get_data('src').subtracted True
Overplot the background-subtracted data on the original data for the default data set:
>>> plot_data() >>> subtract() >>> plot_data(overplot=True)