Fitting source data with multiple backgrounds fails unless all background IDs are assigned models.
When a Chandra grating PHA data set is loaded into Sherpa, and the associated background data is available, it is assigned two separate background IDs, one for each of the 'up' and 'down' background data sets.
sherpa In : load_pha("3c120_heg_-1.pha.gz") WARNING: systematic errors were not found in file '3c120_heg_-1.pha.gz' statistical errors were found in file '3c120_heg_-1.pha.gz' but not used; to use them, re-read with use_errors=True read ARF file 3c120_heg_-1.arf read RMF file 3c120_heg_-1.rmf read background_up into a dataset from file 3c120_heg_-1.pha.gz read background_down into a dataset from file 3c120_heg_-1.pha.gz
Currently, if the source data ID and only one of its two background data IDs have been assigned a model, an a ttempt to fit the source and single background will fail with an error; Sherpa expects to include both backgrounds in the fit. While this safeguards the user against potentially misleading results in the analysis of their data, th e fit should continue on in this case and simply issue a warning that only one of the two associated background data sets will be included in the fit.
sherpa In : set_model("xspowerlaw.p1") sherpa In : set_bkg_model("const1d.c1") sherpa In : fit() ModelErr: background model 2 for data set 1 has not been set
In order to fit only one of multiple background data sets assigned to a single source data set, the get_data() command may be used to remove the unneeded background, as shown below:
sherpa In : print(get_data(1).background_ids) [1, 2] sherpa In : get_data(1).background_ids =  # set background 1 as the only # background to fit. sherpa In : print(get_data(1).background_ids)