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 2008

URL: http://cxc.harvard.edu/sherpa4.1/calc_data_sum.py.html
AHELP for Sherpa 4.1

calc_data_sum

Context: py.sherpa

Synopsis

Calculate the sum of observed data counts

Syntax

calc_data_sum( [lo,hi,id,bkg_id] )

Description

The calc_data_sum function calculates the sum of observed data counts in all or a portion of a source or background data set by data ID or background ID. A subset of the data can be specified by entering the low and high ends of the desired data interval in units of keV for energy data or angstroms for wavelength data. Calc_data_sum accepts binned, unbinned, background-subtracted and unsubtracted data.

  • lo - low limit; default=None
  • hi - high limit; default=None
  • id - data ID; if not given, uses the default sherpa id (id=1 by default, see "ahelp get_default_id")
  • bkg_id - background data ID

The calc_data_sum function can be called with no arguments, in which case the observed counts will be summed over the entire data range of the default data set. The counts in any background data set can be summed by supplying the background ID as the argument. It is possible to supply background-subtracted source data to calc_data_sum; the raw counts sum can be found by calling "unsubtract()" before "calc_data_sum()".

For 1-D data, if

o) a single energy, wavelength, or bin number is given (as opposed to a [lo, hi] interval), then the sum of data counts in the bin associated with that value is returned.

o) an energy or wavelength range is given with the 'lo' and 'hi' arguments, then the total summed data counts for the given range is returned.

o) no value or range is specified, then the total summed data counts for the full range of the data set is returned.

For 2-D data, the summation is carried out over the entire input image.

Example 1

sherpa> calc_data_sum()

When supplied with no arguments, calc_data_sum will sum the observed data counts over the entire data range of the default data set.

Example 2

sherpa> calc_data_sum(id=3)

Here, data set "3" is specified, so the total summed counts of the entire data range of data set 3 will be returned.

Example 3

sherpa> calc_data_sum(10.0, id=4)

The total observed counts in the bin(s) corresponding to 10.0 keV in data set 4 are summed.

Example 4

sherpa> calc_data_sum(bkg_id=1)

When supplied with a background ID, the total observed background counts in the entire data range of the specified background data set will be summed. In this example, the first background data set automatically located by Sherpa is used.

Example 5

sherpa> calc_data_sum(lo=0.1, hi=7.0, "bkg")

The total observed background counts between 0.1 and 7.0 keV are summed for the background data set with user-assigned ID "bkg". (Note that a user-defined string ID cannot be supplied to the "bkg_id" argument)

Example 6

sherpa> calc_data_sum(1.0, 15.0,id=1, bkg_id=2)

The total observed background counts between 1 and 15 angstroms are summed in the second background data set automatically loaded by Sherpa with source data set 1.

Bugs

See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.

Last modified: December 2008



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.