ungroup¶
-
sherpa.astro.ui.ungroup(id=None, bkg_id=None)¶ Turn off the grouping for a PHA data set.
A PHA data set can be grouped either because it contains grouping information [1], which is automatically applied when the data is read in with load_pha or load_data, or because the
group_xxxset of routines has been used to dynamically re-group the data. The ungroup function removes this grouping (however it was created).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.
- bkg_id (int or str, optional) – Set to ungroup the background associated with the data set.
Raises: sherpa.utils.err.ArgumentErr– If the data set does not contain a PHA data set.sherpa.utils.err.DataErr– If the data set is not grouped.
Notes
PHA data is often grouped to improve the signal to noise of the data, by decreasing the number of bins, so that a chi-square statistic can be used when fitting the data. After calling ungroup, anything that uses the data set - such as a plot, fit, or error analysis - will use the original data values. Models should be re-fit if ungroup is called; this may require a change of statistic depending on the counts per channel in the spectrum.
The grouping is implemented by separate arrays to the main data - the information is stored in the
groupingandqualityarrays of the PHA data set - so that a data set can be grouped and ungrouped many times, without losing information.The
groupedfield of a PHA data set is set toFalsewhen the data is not grouped.If subtracting the background estimate from a data set, the grouping applied to the source data set is used for both source and background data sets.
References
[1] Arnaud., K. & George, I., “The OGIP Spectral File Format”, http://heasarc.gsfc.nasa.gov/docs/heasarc/ofwg/docs/spectra/ogip_92_007/ogip_92_007.html Examples
Ungroup the data in the default data set:
>>> ungroup() >>> get_data().grouped False
Ungroup the first background component of the ‘core’ data set:
>>> ungroup('core', bkg_id=1) >>> get_bkg('core', bkg_id=1).grouped False