# get_rate¶

sherpa.astro.ui.get_rate(id=None, filter=False, bkg_id=None)

Return the count rate of a PHA data set.

Return an array of count-rate values for each bin in the data set. The units of the returned values depends on the values set by the set_analysis rountine for the data set.

Parameters: 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. filter (bool, optional) – Should the filter attached to the data set be applied to the return value or not. The default is False. bkg_id (int or str, optional) – Set if the rate should be taken from the background associated with the data set. rate – The rate array. The output matches the grouping of the data set. The units are controlled by the set_analysis setting for this data set; that is, the units used in plot_data, except that the type argument to set_analysis is ignored. The return array will match the grouping scheme applied to the data set. array sherpa.utils.err.ArgumentErr – If the data set does not contain PHA data.

get_dep()
Return the data for a data set.
ignore()
Exclude data from the fit.
notice()
Include data in the fit.
plot_data()
Plot the data values.
set_analysis()
Set the units used when fitting and displaying spectral data.

Examples

Return the count-rate for the default data set. For a PHA data set, where set_analysis has not been called, the return value will be in units of count/second/keV, and a value for each group in the data set is returned.

>>> rate = get_rate()


The return value is grouped to match the data, but is not filtered (with the default filter argument). The data set used here 46 groups in it, but after filtering only has 40 groups, but the call to get_rate returns a 46-element array unless filter is explicitly set to True:

>>> notice()
>>> get_rate().size
46
>>> ignore(None, 0.5)
>>> ignore(7, None)
>>> get_rate().size
46
>>> get_rate(filter=True).size
40


The rate of data set 2 will be in units of count/s/Angstrom and only cover the range 20 to 22 Angstroms:

>>> set_analysis(2, 'wave')
>>> notice_id(2, 20, 22)
>>> r2 = get_rate(2, filter=True)


The returned rate is now in units of count/s (the return value is multiplied by binwidth^factor, where factor is normally 0):

>>> set_analysis(2, 'wave', factor=1)
>>> r2 = get_rate(2, filter=True)


Return the count rate for the second background component of data set “grating”:

>>> get_rate(id="grating", bkg_id=2)