group_width¶
- sherpa.astro.ui.group_width(id, num=None, bkg_id=None, tabStops=None)¶
Group into a fixed bin width.
Combine the data so that each bin contains
numchannels. The binning scheme is applied to all the channels, but any existing filter - created by theignoreornoticeset of functions - is re-applied after the data has been grouped.- 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.num (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_idis None (which is the default), the grouping is applied to all the associated background data sets as well as the source data set.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
Truemeans that the channel should be ignored from the grouping (use 0 orFalseotherwise).
- Raises
sherpa.utils.err.ArgumentErr – If the data set does not contain a PHA data set.
See also
group_adaptAdaptively group to a minimum number of counts.
group_adapt_snrAdaptively group to a minimum signal-to-noise ratio.
group_binsGroup into a fixed number of bins.
group_countsGroup into a minimum number of counts per bin.
group_snrGroup into a minimum signal-to-noise ratio.
set_groupingApply a set of grouping flags to a PHA data set.
set_qualityApply 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
numparameter. If given two un-named arguments, then they are interpreted as theidandnumparameters, respectively. The remaining parameters are expected to be given as named arguments.Unlike
group, it is possible to callgroup_widthmultiple times on the same data set without needing to callungroup.Unless the requested bin width is a factor of the number of channels (and no
tabStopsparameter 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 theget_qualitycommand.Examples
Group the default data set so that each bin contains 20 channels:
>>> group_width(20)
Plot two versions of the ‘jet’ data set: the first uses 20 channels per group and the second is 50 channels per group:
>>> group_width('jet', 20) >>> plot_data('jet') >>> group_width('jet', 50) >>> plot_data('jet', overplot=True)
The grouping is applied to the full data set, and then the filter - in this case defined over the range 0.5 to 8 keV - will be applied.
>>> set_analysis('energy') >>> notice(0.5, 8) >>> group_width(50) >>> plot_data()
The grouping is not applied to channels 101 to 149, inclusive:
>>> notice() >>> channels = get_data().channel >>> ign = (channels > 100) & (channels < 150) >>> group_width(40, tabStops=ign) >>> plot_data()