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/set_weights.html
Hardcopy (PDF): A4 | Letter
AHELP for CIAO 3.4 set_weights Context: sherpa

Synopsis

Module functions for assigning source and background statistical weights.

Syntax

Integer_Type set_weights([Integer_Type,]Array_Type)
Integer_Type set_bweights([Integer_Type,]Array_Type)

Success/Error Return Values: 1/0

Arguments:

(1) Dataset number (default 1)

(2) An array of source/background statistical weight settings

Note that if only one argument is provided, it is assumed to be an
array, and the dataset is assumed to be dataset 1.

Description

The set_weights and set_bweights functions allow the user to assign new source and background statistical weight values to Sherpa datasets. The default value of a statistical weight is 1, meaning the all data bins have equal influence in the calculation of a statistic. A weight less than 1 decreases a bin's contribution to the total statistic value; a weight greater than 1 increases the contribution.

Note that:

  • the input array length must match the number of bins in the filtered dataset; consequently, if one's goal is to use these functions in data manipulation, it is important not to change the filter in Sherpa between any call to, e.g., get_weight and set_weight!
  • the input array is typecast to match the type of its associated dataspace (see, e.g., set_axes for a definition of dataspaces). For instance, if dataset 3 is of Double_Type, then when set_weight(3,<array>) is run, the array is typecast to Double_Type if necessary.

See the related Sherpa command READ WEIGHTS for more information.

Example

Change the statistical weights of the lowest-value bins in a dataset to reduce the influence of these bins in a statistic calculation:

sherpa> DATA spec.dat
sherpa> SOURCE = CONST[cs]
sherpa> FIT
 LVMQT: V2.0
 LVMQT: initial statistic value = 82.2297
 LVMQT: final statistic value = 63.9111 at iteration 3
            cs.c0  57.7977     

sherpa> d = get_data(1)
sherpa> d[*] = 1
sherpa> d[[0:5]] = 0.5
sherpa> printarr(d,10)
0.5
0.5
0.5
0.5
0.5
0.5
1
1
...
sherpa> set_weights(1,d)
1
sherpa> FIT
 LVMQT: V2.0
 LVMQT: initial statistic value = 61.7966
 LVMQT: final statistic value = 61.7912 at iteration 2
            cs.c0  57.8627     

In this example, data are read into Sherpa and the counts amplitude array is retrived using get_data. Every element of this array is reset to 1, then the first six elements are reset to 0.5. The array is then sent to Sherpa, where it overwrites the old weight array; the subsequent fit shows a slight change.

Bugs

See the Sherpa bug pages online 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.