get_rate
- sherpa.astro.ui.get_rate(id: IdType | None = None, filter=False, bkg_id: IdType | None = 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_analysisroutine for the data set.- Parameters:
id (int, str, or None, 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, str, or None, optional) – Set if the rate should be taken from the background associated with the data set.
- Returns:
rate – The rate array. The output matches the grouping of the data set. The units are controlled by the
set_analysissetting for this data set; that is, the units used inplot_data, except that thetypeargument toset_analysisis ignored. The return array will match the grouping scheme applied to the data set.- Return type:
array
- Raises:
sherpa.utils.err.ArgumentErr – If the data set does not contain PHA data.
See also
get_depReturn the data for a data set.
ignoreExclude data from the fit.
noticeInclude data in the fit.
plot_dataPlot the data values.
set_analysisSet 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_analysishas 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
filterargument). The data set used here 46 groups in it, but after filtering only has 40 groups, but the call toget_ratereturns a 46-element array unlessfilteris explicitly set toTrue:>>> 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, wherefactoris 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)