get_counts

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

Return the dependent axis of a data set.

This function returns the data values (the dependent axis) for each point or pixel in 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 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. This array is one-dimensional, even for two dimensional (e.g. image) data.

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([4, 5, 9])
>>> x0 = [10, 15, 12, 19]
>>> x1 = [12, 14, 10, 17]
>>> y = [4, 5, 9, -2]
>>> load_arrays(2, x0, x1, y, 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:

>>> load_arrays(1, [10, 15, 19], [4, 5, 9])
>>> ignore_id(1, 17, None)
>>> get_dep()
array([4, 5, 9])
>>> get_dep(filter=True)
array([4, 5])

An example with a PHA data set named ‘spec’:

>>> 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,)