do_group

sherpa.astro.utils.do_group()

Group the array using OGIP standards.

Parameters:
  • data (array_like) – The data to group.

  • group (array_like) – The OGIP grouping data: 1 indicates the start of a group and -1 continues the group.

  • name ({'sum', '_sum_sq', '_max', '_min', '_middle', '_make_groups'}) – The grouping scheme to combine values within a group.

Returns:

grouped – The grouped data. It will be smaller than data unless group only contains 1’s.

Return type:

array

Examples

Group the array [1, 2, 3, 4, 5, 6] into groups of length 2, 1, and 3, using different grouping schemes:

>>> data = [1, 2, 3, 4, 5, 6]
>>> group = [1, -1, 1, 1, -1, -1]
>>> do_group(data, group, '_make_groups')
[1, 2, 3]
>>> do_group(data, group, 'sum')
[3, 3, 15]
>>> do_group(data, group, '_min')
[1, 3, 4]
>>> do_group(data, group, '_max')
[2, 3, 6]
>>> do_group(data, group, '_middle')
[1.5, 3. , 5. ]