get_counts

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

Return the dependent axis of a 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 values returned should be from the given background component, instead of the source data set.
Returns:

axis – The dependent axis values. The model estimate is compared to these values during fitting. For PHA data sets, the return array will match the grouping scheme applied to the data set.

Return type:

array

Raises:

sherpa.utils.err.IdentifierErr – If the data set does not exist.

See also

get_error()
Return the errors on the dependent axis of a data set.
get_indep()
Return the independent axis of a data set.
get_rate()
Return the count rate of a PHA data set.
list_data_ids()
List the identifiers for the loaded data sets.

Examples

>>> load_arrays(1, [10,15,19], [4,5,9], Data1D)
>>> get_dep()
array([10, 15, 19])
>>> load_arrays(2, [10,15,12,19], [12,14,10,17], [4,5,9,-2], Data2D)
>>> get_dep(2)
array([4, 5, 9, -2])

If the filter flag is set then the return will be limited to the data that is used in the fit:

>>> notice_id('spec', 0.5, 7)
>>> yall = get_dep('spec')
>>> yfilt = get_dep('spec', filter=True)
>>> yall.size
1024
>>> yfilt.size
446

For images, the data is returned as a one-dimensional array:

>>> load_image('img', 'image.fits')
>>> ivals = get_dep('img')
>>> ivals.shape
(65536,)