AHELP for CIAO 4.9

# grpSnr

Context: group

## Synopsis

Group an array by signal to noise.

## Syntax

```grpSnr( PyArray_Type countsArray, Double_Type snr )
grpSnr( PyArray_Type countsArray, Double_Type snr, Integer_Type
maxLength )
grpSnr( PyArray_Type countsArray, Double_Type snr, Integer_Type
maxLength, PyArray_Type tabStops )
grpSnr( PyArray_Type countsArray, Double_Type snr, Integer_Type
maxLength, PyArray_Type tabStops, PyArray_Type errorCol )

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 grouped so that the signal to noise of each group is at least equal to the snr parameter. The optional parameters maxLength and tabStops represent the maximum number of elements that can be combined into a group and an array representing those elements that should be ignored respectively. The errorCol array gives the error for each element of the original array: if it is not supplied then the error is taken to be the square root of the element value.

This function provides the same functionality as the SNR 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`

## Example 1

`>>> (g,q) = grpSnr( y, 5 )`

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 have a signal to noise of at least 5 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) = grpSnr( y, 5 )
>>> 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 so that the signal-to-noise of the group is at least 5.

## 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.