AHELP for CIAO 4.12

Context: group

Synopsis

Group an array by the number of counts per group using an adaptive scheme.

Syntax

grpAdaptive( PyArray_Type countsArray, Integer_Type numCounts )
Integer_Type maxLength )
Integer_Type maxLength, PyArray_Type tabStops )

Returns: ( PyArray_Type grouping, PyArray_Type quality )

Description

This function returns the grouping and quality arrays that represent the input data (countsArray) after it has been adaptively grouped so that each group contains at least numCounts counts. The optional parameters maxLength and tabStops represent the maximum number of elements that can be combined and an array representing those elements that should be ignored respectively.

This function provides the same functionality as the ADAPTIVE option of dmgroup.

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

>>> (g,q) = grpAdaptive( y, 20 )

This example calculates the grouping and quality arrays that represent the input data (here the contents of the y array) after it has been adaptively grouped to at least 20 counts per group.

Example 2

>>> x = numpy.arange(0.5, 6.0, 0.05)
>>> y = 3 + 30 * numpy.exp( - (x-2.0)**2 / 0.1 )
>>> (g,q) = grpAdaptive( y, 15 );
>>> 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 adaptively group it by 15 counts per group.

Unlike the simple grouping done by grpNumCounts() - where only the end element(s) may have non-zero quality values - the adaptive grouping scheme can create groups with non-zero quality anywhere in the array.

Example 3

>>> cA = numpy.array([ 66, 103, 146, 219, 579, 819, 457, 228, 131, 15,
0])
>>> minC = 700
>>> maxL = 3
>>> tab = numpy.array([0,0,0,0,0,0,0,0,0,0,0])
>>> (g,q) = grpAdaptive(countsArray=cA, minCounts=minC, maxLength=maxL,
tabStops=tab)
>>> (g,q) = grpAdaptive(minCounts=minC, countsArray=cA, tabStops=tab,
maxLength=maxL)

In order to take advantage of the optional parameters, Python allows for keywords. This example demonstrates the use of the keywords for the grpAdaptive function. If all the parameters are used with keywords, the order in which they appear in the parameter list does not matter. However, if not using keywords for all parameters, the order does matter. See next example for syntax.

Example 4

>>> cA = numpy.array([ 66, 103, 146, 219, 579, 819, 457, 228, 131, 15,
0])
>>> minC = 700
>>> (g,q) = grpAdaptive(cA, minC, maxLength=3)

This example demonstrates the use of the keywords for one optional parameter. Here the order of the parameters does matter since all of the parameters do not have keywords.

Example 5

>>> cA = numpy.array([ 66, 103, 146, 219, 579, 819, 457, 228, 131, 15,
0])
>>> minC = 700
>>> tab = numpy.array([0,0,0,0,0,0,0,0,0,0,0])
>>> (g,q) = grpAdaptive(cA, minC, tabStops=tab)

This example demonstrates the use of the keywords for one optional parameter. Here the order of the parameters does matter since all of the parameters do not have keywords.

Example 6

>>> cA = numpy.array([ 66, 103, 146, 219, 579, 819, 457, 228, 131, 15,
0])
>>> minC = 700
>>> maxL = 3
>>> tab = numpy.array([0,0,0,0,0,0,0,0,0,0,0])
>>> (g,q) = grpAdaptive(cA, minC, tabStops=tab, maxLength=maxL)
>>> (g,q) = grpAdaptive(cA, minC, maxLength=maxL, tabStops=tab)

This example demonstrates the use of the keywords for one optional parameter. Here the order of the parameters without keywords matters but the order of the optional parameters with keywords does not.

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.