Group an array by the number of counts per group.
grpNumCounts( PyArray_Type countsArray, Double_Type numCounts ) grpNumCounts( PyArray_Type countsArray, Double_Type numCounts, Integer_Type maxLength ) grpNumCounts( PyArray_Type countsArray, Double_Type numCounts, Integer_Type maxLength, PyArray_Type tabStops ) Returns: ( PyArray_Type grouping, PyArray_Type quality )
This function returns the grouping and quality arrays that represent the input data (countsArray) after it has been 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 NUM_CTS 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:
>>> (g,q) = grpNumCounts( 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 grouped to at least 20 counts per group.
>>> x = numpy.arange(0.5, 6.0, 0.05) >>> y = 3 + 30 * numpy.exp( - (x-2.0)**2 / 0.1 ) >>> (g,q) = grpNumCounts( 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 group it by 15 counts per group.
In this example we have ignored the quality array; the last group (corresponding to the last 3 elements of the x and y arrays) has a quality value of 2, indicating that the total number of counts for the group (9) is less than 15.
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.