Last modified: December 2013

URL: https://cxc.cfa.harvard.edu/ciao/ahelp/grpgetgrpnum.html
Jump to: Description · Examples · Bugs · See Also


AHELP for CIAO 4.17

grpGetGrpNum

Context: group

Synopsis

Calculate the group number for each element in the array.

Syntax

Integer_Type grpnum = grpGetGrpNum( PyArray_Type grouping )

Description

This function calculates which group each element in the input array belongs to, where the groups are numbered from 1. The return value is an array whose length equals that of the input data (the grouping argument) and each element within a group contains the same value. As an example,

grpGetGroupNum( numpy.array([1,-1,1,-1,1,1]) )

will return the array

array([1,1,2,2,3,4])

since the groups consist of the first two elements, then the next two elements, with the last two elements being un-grouped.

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

Examples

Example 1

>>> igrp = grpGetGroupNum( grp )

The igrp array will contain the group number for each element of the input array, for the grouping scheme stored in the grp array, and has the same size as the grp array.

Example 2

>>> x = numpy.arange(0.5, 6.0, 0.05)
>>> y = 3 + 30 * numpy.exp( - (x-2.0)**2 / 0.1 )
>>> ( grp, qual ) = grpNumCounts( y, 15 )
>>> yavg = grpGetGroupSum( y, grp ) / grpGetChansPerGroup( grp )
>>> igrp = grpGetGroupNum( grp )
>>> i = numpy.where( grp == 1, qual, grp )
>>> j = numpy.where(i == 0)

Here we take the function

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

and group it by 15 counts per group.

Example 3

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


Bugs

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
group, grpadaptive, grpadaptivesnr, grpbin, grpbinfile, grpbinwidth, grpgetchanspergroup, grpgetgroupsum, grpgetgrpnum, grpmaxslope, grpminslope, grpnumbins, grpnumcounts, grpsnr