sherpa.astro.ui.get_quality(id=None, bkg_id=None)

Return the quality flags for a PHA data set.

The function returns the quality value for each channel in the PHA data set.

  • id (int or str, optional) – The identifier for the data set to use. If not given then the default identifier is used, as returned by get_default_id.

  • bkg_id (int or str, optional) – Set if the quality flags should be taken from a background associated with the data set.


qual – The quality value for each channel in the PHA data set. This array is not grouped or filtered - that is, there is one element for each channel in the PHA data set. Changes to the elements of this array will change the values in the dataset (is is a reference to the values used to define the quality, not a copy).

Return type:

ndarray or None


sherpa.utils.err.ArgumentErr – If the data set does not contain a PHA data set.

See also


Fit one or more data sets.


Return the grouping array for a PHA data set.


Return the independent axes of a data set.


Exclude channels marked as bad in a PHA data set.


Load the quality array from a file and add to a PHA data set.


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


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.


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


Copy the quality array from the default data set to data set 2:

>>> qual1 = get_quality()
>>> set_quality(2, qual1)

Return the quality array of the background component labelled 2 for the ‘histate’ data set:

>>> qual = get_quality('histate', bkg_id=2)

Change the quality setting for all channels below 30 in the default data set to 5 (considered bad by the user):

>>> chans, = get_indep()
>>> qual = get_quality()
>>> qual[chans < 30] = 5