    Group into a fixed bin width.

group_width(id, num=None, bkg_id=None, tabStops=None)
id - int or str, optional
num - int
bkg_id - int or str, optional
tabStops - array of int or bool, optional

Combine the data so that each bin contains `num` channels. The binning scheme is, by default, applied to only the noticed data range. It is suggested that filtering is done before calling group_width.

Group the default data set so that each bin contains 5 channels:

>>> group_width(5)

Plot two versions of the 'jet' data set: the first uses 2 channels per group and the second is 5 channels per group:

>>> group_width('jet', 2) >>> plot_data('jet') >>> group_width('jet', 5) >>> plot_data('jet', overplot=True)

The grouping is applied to only the data within the 0.5 to 8 keV range (this behaviour is new in 4.16):

>>> set_analysis('energy') >>> notice() >>> notice(0.5, 8) >>> group_width(7) >>> plot_data()

Group the full channel range and then apply the existing filter (0.5 to 8 keV) so that the noticed range may be larger (this was the default behaviour before 4.16):

>>> group_width(5, tabStops="nofilter")

The grouping is not applied to channels 101 to 149, inclusive:

>>> notice() >>> channels = get_data().channel >>> ign = (channels > 100) & (channels < 150) >>> group_width(4, tabStops=ign) >>> plot_data()

PARAMETERS

The parameters for this function are:

Parameter
Definition
id
The identifier for the data set to use. If not given then the default identifier is used, as returned by

`get_default_id` .
num
The number of channels to combine into a group.
bkg_id
Set to group the background associated with the data set. When bkg_id is None (which is the default), the grouping is applied to all the associated background data sets as well as the source data set.
tabStops
If not set then it will be based on the filtering of the data set, so that the grouping only uses the filtered data. If set it can be the string "nofilter", which means that no filter is applied (and matches the behavior prior to the 4.16 release), or an array of booleans where True indicates that the channel should not be used in the grouping (this array must match the number of channels in the 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 `num` parameter. If given two un-named arguments, then they are interpreted as the `id` and `num` parameters, respectively. The remaining parameters are expected to be given as named arguments.

Unlike `group` , it is possible to call `group_width` multiple times on the same data set without needing to call `ungroup` .

Unless the requested bin width is a factor of the number of channels (and no tabstops parameter is given), then some channels will be "left over". If this happens, 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.

Changes in CIAO

Grouping now defaults to only using the noticed channel range. The tabStops argument can be set to "nofilter" to use the previous behaviour.

The filter is now reported, noting any changes the new grouping scheme has made.

See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.

December 2023