group_adapt
- sherpa.astro.ui.group_adapt(id, min=None, bkg_id=None, maxLength=None, tabStops=None)
Adaptively group to a minimum number of counts.
Combine the data so that each bin contains
min
or more counts. The difference togroup_counts
is that this algorithm starts with the bins with the largest signal, in order to avoid over-grouping bright features, rather than at the first channel of the data. The adaptive nature means that low-count regions between bright features may not end up in groups with the minimum number of counts. The binning scheme is applied to all the channels, but any existing filter - created by theignore
ornotice
set of functions - is re-applied after the data has been grouped.Changed in version 4.15.1: The filter is now reported, noting any changes the new grouping scheme has made.
- 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
.min (int) – The number of channels to combine into a group.
bkg_id (int or str, optional) – Set to group the background associated with the data set. When
bkg_id
isNone
(which is the default), the grouping is applied to all the associated background data sets as well as the source data set.maxLength (int, optional) – The maximum number of channels that can be combined into a single group.
tabStops (array of int or bool, optional) – If set, indicate one or more ranges of channels that should not be included in the grouped output. The array should match the number of channels in the data set and non-zero or
True
means that the channel should be ignored from the grouping (use 0 orFalse
otherwise).
- Raises:
sherpa.utils.err.ArgumentErr – If the data set does not contain a PHA data set.
See also
group_adapt_snr
Adaptively group to a minimum signal-to-noise ratio.
group_bins
Group into a fixed number of bins.
group_counts
Group into a minimum number of counts per bin.
group_snr
Group into a minimum signal-to-noise ratio.
group_width
Group into a fixed bin width.
set_grouping
Apply a set of grouping flags to a PHA data set.
set_quality
Apply a set of quality flags to a PHA data set.
Notes
The function does not follow the normal Python standards for parameter use, since it is designed for easy interactive use. When called with a single un-named argument, it is taken to be the
min
parameter. If given two un-named arguments, then they are interpreted as theid
andmin
parameters, respectively. The remaining parameters are expected to be given as named arguments.Unlike
group
, it is possible to callgroup_adapt
multiple times on the same data set without needing to callungroup
.If channels can not be placed into a “valid” group, then a warning message will be displayed to the screen and the quality value for these channels will be set to 2. This information can be found with the
get_quality
command.Examples
Group the default data set so that each bin contains at least 20 counts:
>>> group_adapt(20)
Plot two versions of the ‘jet’ data set: the first uses an adaptive scheme of 20 counts per bin, the second the
group_counts
method:>>> group_adapt('jet', 20) >>> plot_data('jet') >>> group_counts('jet', 20) >>> plot_data('jet', overplot=True)