set_bkg

sherpa.astro.ui.set_bkg(id, bkg=None, bkg_id=None)

Set the background for a PHA data set.

The background can either be fit with a model - using set_bkg_model - or removed from the data before fitting, using subtract.

Parameters
  • id (int or str, optional) – 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 (int or str, optional) – The identifier for this background, which is needed if there are multiple background estimates for the source.

See also

get_bkg

Return the background for a PHA data set.

load_bkg

Load the background from a file and add it to a PHA data set.

load_pha

Load a file as a PHA data set.

set_bkg_model

Set the background model expression for a data set.

subtract

Subtract the background estimate from a data set.

unpack_pha

Create a PHA data structure.

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.

Examples

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)