calc_data_sum
- sherpa.astro.utils.calc_data_sum(data, lo=None, hi=None)[source] [edit on github]
Sum up the data values over a pass band.
- Parameters:
data – The data object to use.
lo (number, optional) – If both are None or both are set then use the full dataset. If only one is set then use the data count for that bin. The units for
loandhiare given by the current analysis setting of thedataparameter.hi (number, optional) – If both are None or both are set then use the full dataset. If only one is set then use the data count for that bin. The units for
loandhiare given by the current analysis setting of thedataparameter.
- Returns:
dsum – The sum of the data values that lie within the given limits. If a background estimate has been subtracted from the data set then the calculation will use the background-subtracted values.
- Return type:
number
See also
calc_data_sum2dSum up the data values of a 2D data set.
calc_model_sumSum up the fitted model over a pass band.
calc_energy_fluxIntegrate the source model over a pass band.
calc_photon_fluxIntegrate the source model over a pass band.
calc_source_sumSum up the source model over a pass band.
set_modelSet the source model expression for a data set.
Notes
The units of
loandhiare determined by the analysis setting for the data set (e.g.data.get_analysis).Any existing filter on the data set - e.g. as created by
ignoreornotice- is ignored by this function.If a grouping scheme has been applied to the data set that it will be used. This can change the results, since the first and last bins of the selected range may extend outside the requested range.
Examples
Calculate the number of counts over the ranges 0.5 to 2 and 0.5 to 7 keV, first using the observed signal and then, for the 0.5 to 2 keV band - the background-subtraced estimate:
>>> set_analysis('energy') >>> calc_data_sum(data, 0.5, 2) 745.0 >>> calc_data_sum(data, 0.5, 7) 60.0 >>> data.subtract() >>> calc_data_sum(data, 0.5, 2) 730.9179738207356