    Load the grouping scheme from a file and add to a PHA data set.

load_grouping(id, filename=None, bkg_id=None, *args, **kwargs)
id - int or str, optional
filename - str
bkg_id - int or str, optional
colkeys - array of str, optional
sep - str, optional
comment - str, optional

This function sets the grouping column but does not automatically group the data, since the quality array may also need updating. The `group` function will apply the grouping information.

When using Crates as the I/O library, select the grouping column from the file 'src.pi', and use it to set the values in the default data set:

>>> load_grouping('src.pi[cols grouping]')

Use the colkeys option to define the column in the input file:

>>> load_grouping('src.pi', colkeys=['grouping'])

Load the first column in 'grp.dat' and use it to populate the grouping array of the data set called 'core'.

>>> load_grouping('core', 'grp.dat')

Use `group_counts` to calculate a grouping scheme for the data set labelled 'src1', save this scheme to the file 'grp.dat', and then load this scheme in for data set 'src2'.

>>> group_counts('src1', 10) >>> save_grouping('src1', 'grp.dat') >>> load_grouping('src2', 'grp.dat', colkeys=['groups'])

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` .
filename
The name of the file that contains the grouping information. This file can be a FITS table or an ASCII file. Selection of the relevant column depends on the I/O library in use (Crates or AstroPy).
bkg_id
Set if the grouping scheme should be associated with the background associated with the data set.
colkeys
An array of the column name to read in. The default is

none .
sep
The separator character. The default is ' ' .
comment
The comment character. The default is '#' .

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 `filename` parameter. If given two un-named arguments, then they are interpreted as the `id` and `filename` parameters, respectively. The remaining parameters are expected to be given as named arguments.

There is no check made to see if the grouping array contains valid data.

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

December 2023