Synopsis
Sum up the data values over a pass band.
Syntax
calc_data_sum(lo=None, hi=None, id=None, bkg_id=None)
Description
This function is for one-dimensional data sets: use `calc_data_sum2d` for two-dimensional data sets.
Examples
Example 1
Sum up the data values (the dependent axis) for all points or bins in the default data set:
>>> dsum = calc_data_sum()
Example 2
Calculate the number of counts over the ranges 0.5 to 2 and 0.5 to 7 keV for the default data set, 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(0.5, 2) 745.0 >>> calc_data_sum(0.5, 7) 60.0 >>> subtract() >>> calc_data_sum(0.5, 2) 730.9179738207356
Example 3
Calculate the data value in the bin containing 0.5 keV for the source "core":
>>> calc_data_sum(0.5, id="core") 0.0
Example 4
Calculate the sum of the second background component for data set 3 over the independent axis range 12 to 45:
>>> calc_data_sum(12, 45, id=3, bkg_id=2)
PARAMETERS
The parameters for this function are:
Parameter | Type information | Definition |
---|---|---|
lo | number, optional | If both are None or both are set then sum up the data over the given band. If only one is set then return the data count in the given bin. |
hi | number, optional | If both are None or both are set then sum up the data over the given band. If only one is set then return the data count in the given bin. |
id | int, str, or None, optional | Use the source expression associated with this data set. If not given then the default identifier is used, as returned by `get_default_id` . |
bkg_id | int, str, or None, optional | If set, use the model associated with the given background component rather than the source model. |
Return value
The return value from this function is:
dsum -- If a background estimate has been subtracted from the data set then the calculation will use the background-subtracted values.
Notes
The units of lo and hi are determined by the analysis setting for the data set (e.g. `get_analysis` ). The summation occurs over those points in the data set that lie within this range, not the range itself.
Any existing filter on the data set - e.g. as created by `ignore` or `notice` - 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.
Bugs
See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.
See Also
- data
- copy_data, dataspace1d, dataspace2d, datastack, delete_data, fake, get_axes, get_bkg_chisqr_plot, get_bkg_delchi_plot, get_bkg_fit_plot, get_bkg_model_plot, get_bkg_plot, get_bkg_ratio_plot, get_bkg_resid_plot, get_bkg_source_plot, get_counts, get_data, get_data_contour, get_data_contour_prefs, get_data_image, get_data_plot, get_data_plot_prefs, get_dep, get_dims, get_error, get_quality, get_specresp, get_staterror, get_syserror, group, group_adapt, group_adapt_snr, group_bins, group_counts, group_snr, group_width, load_ascii, load_data, load_grouping, load_quality, set_data, set_quality, ungroup, unpack_ascii, unpack_data
- filtering
- get_filter, load_filter, set_filter
- info
- get_default_id, list_data_ids, list_response_ids
- modeling
- clean
- plotting
- plot_data, set_xlinear, set_xlog, set_ylinear, set_ylog
- saving
- save_error, save_filter, save_grouping, save_quality, save_staterror, save_syserror
- utilities
- calc_data_sum2d, calc_energy_flux, calc_ftest, calc_kcorr, calc_mlr, calc_model_sum, calc_model_sum2d, calc_photon_flux, calc_source_sum, calc_source_sum2d, get_rate
- visualization
- contour, contour_data, contour_ratio, histogram1d, histogram2d, image_data, rebin