- sherpa.astro.ui.group_bins(id, num=None, bkg_id=None, tabStops=None)
Group into a fixed number of bins.
Combine the data so that there
numequal-width bins (or groups). The binning scheme is applied to all the channels, but any existing filter - created by the
noticeset of functions - is re-applied after the data has been grouped.
num (int) – The number of bins in the grouped data set. Each bin will contain the same number of channels.
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 or
sherpa.utils.err.ArgumentErr – If the data set does not contain a PHA data set.
Adaptively group to a minimum number of counts.
Adaptively group to a minimum signal-to-noise ratio.
Group into a minimum number of counts per bin.
Group into a minimum signal-to-noise ratio.
Group into a fixed bin width.
Apply a set of grouping flags to a PHA data set.
Apply a set of quality flags to a PHA data set.
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 the
numparameters, respectively. The remaining parameters are expected to be given as named arguments.
Since the bin width is an integer number of channels, it is likely that some channels will be “left over”. This is even more likely when the
tabStopsparameter is set. 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
Group the default data set so that there are 50 bins.
Group the ‘jet’ data set to 50 bins and plot the result, then re-bin to 100 bins and overplot the data:
>>> group_bins('jet', 50) >>> plot_data('jet') >>> group_bins('jet', 100) >>> 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. This means that the noticed data range will likely contain less than 50 bins.
>>> set_analysis('energy') >>> notice(0.5, 8) >>> group_bins(50) >>> plot_data()
Do not group any channels numbered less than 20 or 800 or more. Since there are 780 channels to be grouped, the width of each bin will be 20 channels and there are no “left over” channels:
>>> notice() >>> channels = get_data().channel >>> ign = (channels <= 20) | (channels >= 800) >>> group_bins(39, tabStops=ign) >>> plot_data()