set_bkg
- sherpa.astro.ui.set_bkg(id, bkg=None, bkg_id: IdType | None = None) 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, usingsubtract.- 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_dataorunpack_pha.bkg_id (int, str, or None, optional) – The identifier for this background, which is needed if there are multiple background estimates for the source.
See also
get_bkgReturn the background for a PHA data set.
load_bkgLoad the background from a file and add it to a PHA data set.
load_phaLoad a file as a PHA data set.
set_bkg_modelSet the background model expression for a data set.
subtractSubtract the background estimate from a data set.
unpack_phaCreate 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
bkgparameter. If given two un-named arguments, then they are interpreted as theidandbkgparameters, 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)