Last modified: December 2013

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


AHELP for CIAO 4.15

grpBinWidth

Context: group

Synopsis

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

Syntax

grpBinWidth( Integer_Type numChans, Integer_Type grpWidth )
grpBinWidth( Integer_Type numChans, Integer_Type grpWidth, PyArray_Type
tabStops )

Returns: ( PyArray_Type grouping, PyArray_Type quality )

Description

This function returns the grouping and quality arrays that represent an array of numChans elements in which the groups are each grpWidth elements wide. The optional parameter tabStops is an array which lists those elements that should be ignored.

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

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

Examples

Example 1

>>> (g,q) = grpBinwidth( 10, 2 );

This example calculates the grouping and quality arrays that represent an array of 10 elements in which each group has a width of 2 elements.

Example 2

>>> x = numpy.arange(0.5, 6.0, 0.05)
>>> y = 3 + 30 * numpy.exp( - (x-2.0)**2 / 0.1 )
>>> (g,q) = grpBinWidth( 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 * exp( -(x-2)^2 / 0.1 )

and group it so that each group contains 10 elements.

If we had filtered the data array to only contain elements with a quality value - as returned by grpBinWidth() - of 0, then we could have avoided the call to grpGetChansPerGroup() since this is set to 10 by grpBinWidth().

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