    Apply a set of quality flags to a PHA data set.

set_quality(id, val=None, bkg_id=None)
id - int or str, optional
val - array of int
bkg_id - int or str, optional

A quality value of 0 indicates a good channel, otherwise (values >=1) the channel is considered bad and can be excluded using the `ignore_bad` function, as discussed in the OGIP standard.

Copy the quality array from data set 2 into the default data set, and then ensure that any 'bad' channels are ignored:

>>> qual = get_data(2).quality >>> set_quality(qual) >>> ignore_bad()

Copy the quality array from data set "src1" to the source and background data sets of "src2":

>>> qual = get_data("src1").quality >>> set_quality("src2", qual) >>> set_quality("src2", qual, bkg_id=1)

PARAMETERS

The parameters for this function are:

Parameter
Definition
id
The identifier for the data set to use. If not given then the default identifier is used, as returned by

`get_default_id` .
val
This must be an array of quality values of the same length as the data array.
bkg_id
Set if the quality values should be associated with the background associated with the data set.

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 `val` parameter. If given two un-named arguments, then they are interpreted as the `id` and `val` parameters, respectively.

The meaning of the quality column is taken from the OGIP standard, which says that 0 indicates a "good" channel, 1 and 2 are for channels that are identified as "bad" or "dubious" (respectively) by software, 5 indicates a "bad" channel set by the user, and values of 3 or 4 are not used.

References

K. A. Arnaud, I. M. George & A. F. Tennant, "The OGIP Spectral File Format"

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

December 2023