Chandra X-Ray Observatory
Skip to the navigation links
Last modified: December 2013

Jump to: Description · Examples · Bugs · See Also

AHELP for CIAO 4.9


Context: group


Group an array into a set of equal-width groups (by number of groups).


grpNumBins( Integer_Type numChans, Integer_Type numGroups )
grpNumBins( Integer_Type numChans, Integer_Type numGroups, PyArray_Type
tabStops )

Returns: ( PyArray_Type grouping, PyArray_Type quality )


This function returns the grouping and quality arrays that represent an array of numChans elements grouped into numGroups groups. The optional parameter tabStops is an array which lists those elements that should be ignored.

This function provides the same functionality as the NUM_BINS option of dmgroup. The grpBinWidth() function allows you to fix the width of the group rather than the number of groups.

The group module is not available by default; to use it in a Python program, it must be loaded using the Python import function:

  from group import *, or import group

In addition, in order to create arrays, the Python module numpy must be loaded using the Python import function:

  import numpy

Example 1

>>> (g,q) = grpNumBins( 10, 2 )

This example calculates the grouping and quality arrays that represent an array of 10 elements grouped into 2 groups.

Example 2

>>> x = numpy.arange(0.5, 6.0, 0.05)
>>> y = 3 + 30 * numpy.exp( - (x-2.0)**2 / 0.1 )
>>> (g,q) = grpNumBins( y.size, 10 )
>>> ysum = grpGetGroupSum( y, g )
>>> nchan = grpGetChansPerGroup( g )
>>> i = numpy.where( g == 1 )
>>> yavg = ysum[i] / nchan[i]

Here we take the function

y = 3 + 30 * numpy.exp( - (x-2.0)**2 / 0.1 )

and group it so that there are 10 groups.

Example 3

To see more examples of optional parameters and keywords in the parameter list, please see ahelp grpadaptive


See the bugs page for the group library on the CIAO website for an up-to-date listing of known bugs.

Refer to the CIAO bug pages for an up-to-date listing of known issues.

See Also

group, grpadaptive, grpadaptivesnr, grpbin, grpbinfile, grpbinwidth, grpgetchanspergroup, grpgetgroupsum, grpgetgrpnum, grpmaxslope, grpminslope, grpnumbins, grpnumcounts, grpsnr

Last modified: December 2013
Smithsonian Institute Smithsonian Institute

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email: Smithsonian Institution, Copyright © 1998-2017. All rights reserved.