    Set the background for a PHA data set.

set_bkg(id, bkg=None, bkg_id=None)
id - int or str, optional
bkg_id - int or str, optional

The background can either be fit with a model - using

`set_bkg_model` - or removed from the data before fitting, using `subtract` .

Copy the background from the default data set to data set 2:

>>> bkg1 = get_bkg() >>> set_bkg(2, bkg1)

Read in the PHA data from the file 'bkg.pi' and set it as the second background component of data set "core":

>>> bkg = unpack_pha('bkg.pi') >>> set_bkg('core', bkg, bkg_id=2)

PARAMETERS

The parameters for this function are:

Parameter
Definition
id
The data set to use. If not given then the default identifier is used, as returned by `get_default_id` .
bkg
A PHA data set, such as returned by `get_data` or

`unpack_pha` .
bkg_id
The identifier for this background, which is needed if there are multiple background estimates for the source.

Notes

The function does not follow the normal Python standards for parameter use, since it is designed for easy interactive use. When called with a single un-named argument, it is taken to be the `bkg` parameter. If given two un-named arguments, then they are interpreted as the `id` and `bkg` parameters, respectively. The remaining parameters are expected to be given as named arguments.

If the background has no grouping of quality arrays then they are copied from the source region. If the background has no response information (ARF or RMF) then the response is copied from the source region.

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

December 2023