load_grouping

sherpa.astro.ui.load_grouping(id, filename=None, bkg_id=None, *args, **kwargs)

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

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.

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.
  • filename (str) – 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 (int or str, optional) – Set if the grouping scheme should be associated with the background associated with the data set.
  • colkeys (array of str, optional) – An array of the column name to read in. The default is None.
  • sep (str, optional) – The separator character. The default is ' '.
  • comment (str, optional) – The comment character. The default is '#'.

See also

get_grouping()
Return the gouping array for a PHA data set.
group()
Turn on the grouping for a PHA data set.
load_quality()
Load the quality array from a file and add to a PHA data set.
save_grouping()
Save the grouping scheme to a file.
set_grouping()
Apply a set of grouping 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 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.

Examples

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'])