Last modified: December 2024

URL: https://cxc.cfa.harvard.edu/sherpa/ahelp/group_sherpa.html
AHELP for CIAO 4.17 Sherpa

group

Context: data

Synopsis

Turn on the grouping for a PHA data set.

Syntax

group(id=None, bkg_id=None)

Description

A PHA data set can be grouped either because it contains grouping information, which is automatically applied when the data is read in with `load_pha` or `load_data` , or because the `group` set of routines has been used to dynamically re-group the data. The `ungroup` function removes this grouping (however it was created). The `group` function re-applies this grouping. The grouping scheme can be changed dynamically, using the group_xxx series of routines.


Examples

Example 1

Group the data in the default data set:

>>> group()
>>> get_data().grouped
True

Example 2

Group the first background component of the 'core' data set:

>>> group('core', bkg_id=1)
>>> get_bkg('core', bkg_id=1).grouped
True

Example 3

The data is fit using the ungrouped data, and then plots of the data and best-fit, and the residuals, are created. The first plot uses the ungrouped data, and the second plot uses the grouped data.

>>> ungroup()
>>> fit()
>>> plot_fit_resid()
>>> group()
>>> plot_fit_resid()

PARAMETERS

The parameters for this function are:

Parameter Type information Definition
id int, str, or None, 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, str, or None, optional Set to group the background associated with the data set.

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 `group` , anything that uses the data set - such as a plot, fit, or error analysis - will use the grouped data values. Models should be re-fit if `group` is called; the increase in the signal of the bins may mean that a chi-square statistic can now be used.

The grouping is implemented by separate arrays to the main data - the information is stored in the grouping and quality arrays of the PHA data set - so that a data set can be grouped and ungrouped many times, without losing information. The `group` command does not create this information; this is either created by modifying the PHA file before it is read in, or by using the group_xxx routines once the data has been loaded.

The grouped field of a PHA data set is set to True when the data is grouped.

References

Changes in CIAO

Changed in CIAO 4.16

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


Bugs

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

See Also

data
copy_data, dataspace1d, dataspace2d, datastack, delete_data, fake, get_axes, get_bkg_chisqr_plot, get_bkg_delchi_plot, get_bkg_fit_plot, get_bkg_model_plot, get_bkg_plot, get_bkg_ratio_plot, get_bkg_resid_plot, get_bkg_source_plot, get_counts, get_data, get_data_contour, get_data_contour_prefs, get_data_image, get_data_plot, get_data_plot_prefs, get_dep, get_dims, get_error, get_grouping, get_quality, get_specresp, get_staterror, get_syserror, group_adapt, group_adapt_snr, group_bins, group_counts, group_snr, group_width, load_ascii, load_data, load_grouping, load_quality, set_data, set_grouping, set_quality, ungroup, unpack_ascii, unpack_data
filtering
get_filter, ignore, ignore2d, ignore2d_id, ignore_bad, ignore_id, load_filter, notice, notice2d, notice2d_id, notice_id, set_filter, show_filter
info
get_default_id, list_data_ids, list_response_ids
modeling
clean
plotting
plot_data, set_xlinear, set_xlog, set_ylinear, set_ylog
saving
save_error, save_filter, save_grouping, save_quality, save_staterror, save_syserror
utilities
calc_data_sum, calc_data_sum2d, calc_ftest, calc_kcorr, calc_mlr, calc_model_sum2d, calc_source_sum2d, get_rate
visualization
contour, contour_data, contour_ratio, histogram1d, histogram2d, image_data, rebin