Skip to the navigation links
Last modified: December 2009

URL: http://cxc-newtest.cfa.harvard.edu/ciao4.2/grpgetgrpnum.html
AHELP for CIAO 4.2

grpGetGrpNum

Context: group

Synopsis

Calculate the group number for each element in the array.

Syntax

Integer_Type grpnum = grpGetGrpNum( Array_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,

grpGetGrpNum( [1,-1,1,-1,1,1] )

will return the 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 S-Lang program, it must be loaded using the S-Lang require() function:

  require("group");

Example 1

slsh> igrp = grpGetGrpNum( 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

slsh> x = [0.5:6.0:0.05];
slsh> y = 3 + 30 * exp( - (x-2.0)^2 / 0.1 );
slsh> ( grp, qual ) = grpNumCounts( y, 15 );
slsh> yavg = grpGetGroupSum( y, grp ) / grpGetChansPerGroup( grp );
slsh> igrp = grpGetGrpNum( grp );
slsh> i = where( grp == 1 and qual == 0 );

Here we take the function

y = 3 + 30 * exp( -(x-2)^2 / 0.1 )

and group it by 15 counts per group.

Bugs

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

See Also

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

Last modified: December 2009