About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: December 2006

URL: http://cxc.harvard.edu/ciao3.4/grpbinwidth.html
Hardcopy (PDF): A4 | Letter
AHELP for CIAO 3.4 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, Array_Type
tabStops )

Returns: ( Array_Type grouping, Array_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.

Example 1

chips> (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

chips> x = [0.5:6.0:0.05]
chips> y = 3 + 30 * exp( - (x-2.0)^2 / 0.1 )
chips> (g,q) = grpBinWidth( length(y), 10 )
chips> ysum = grpGetGroupSum( y, g )
chips> nchan = grpGetChansPerGroup( g )
chips> i = where( g == 1 )
chips> yavg = ysum[i] / nchan[i]
chips> curve( x, y )
chips> simpleline
chips> curve( x[i], yavg )
chips> symbol square
chips> symbol red

Here we take the function

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

and group it so that each group contains 10 elements. The plot shows the original data (the solid line and the crosses) and the grouped data (as the red squares); the latter has been normalised by the width of each group and is displayed at the left-edge of each group.

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().

Bugs

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

Hardcopy (PDF): A4 | Letter
Last modified: December 2006



The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory.
60 Garden Street, Cambridge, MA 02138 USA.    Email: cxcweb@head.cfa.harvard.edu
Smithsonian Institution, Copyright © 1998-2004. All rights reserved.