Synopsis
Sum up the data values of a 2D data set.
Syntax
calc_data_sum2d(reg=None, id=None)
Description
This function is for two-dimensional data sets: use `calc_model_sum` for one-dimensional data sets.
Examples
Example 1
The following examples use the data in the default data set created with the following calls, which sets the y (data) values to be 0 to 11 in a 3 row by 4 column image:
>>> ivals = np.arange(12) >>> y, x = np.mgrid[10:13, 20:24] >>> y = y.flatten() >>> x = x.flatten() >>> load_arrays(1, x, y, ivals, (3, 4), DataIMG)
with no argument, the full data set is used:
>>> calc_data_sum2d() 66 >>> ivals.sum() 66
and a spatial filter can be used to restrict the region used for the summation:
>>> calc_data_sum2d('circle(22,12,1)') 36 >>> calc_data_sum2d('field()-circle(2,2,1)') 30
Example 2
Apply the spatial filter to the data set labelled "a2142":
>>> calc_data_sum2d('rotbox(4232.3,3876,300,200,43)', 'a2142')
PARAMETERS
The parameters for this function are:
Parameter | Type information | Definition |
---|---|---|
reg | str, optional | The spatial filter to use. The default, none , is to use the whole data set. |
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` . |
Return value
The return value from this function is:
dsum -- The sum of the data values that lie within the given region.
Notes
The coordinate system of the region filter is determined by the coordinate setting for the data set (e.g. `get_coord` ).
Any existing filter on the data set - e.g. as created by `ignore2d` or `notice2d` - is ignored by this function.
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_sum, calc_ftest, calc_kcorr, calc_mlr, calc_model_sum2d, calc_source_sum2d, get_rate
- visualization
- contour, contour_data, contour_ratio, histogram1d, histogram2d, image_data, rebin