Last modified: December 2023

URL: https://cxc.cfa.harvard.edu/sherpa/ahelp/calc_model_sum2d.html
Jump to: Description · Examples · PARAMETERS · Notes · Bugs · See Also


AHELP for CIAO 4.16 Sherpa

calc_model_sum2d

Context: utilities

Synopsis

Sum up the convolved model for a 2D data set.

Syntax

calc_model_sum2d(reg=None, id=None)

reg - str, optional
id - int or str, optional

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)
>>> set_source(const2d.bgnd)
>>> bgnd.c0 = 2

with no argument, the full data set is used. Since the model evaluates to 2 per pixel, and there are 12 pixels in the data set, the result is 24:

>>> calc_model_sum2d()
24.0

and a spatial filter can be used to restrict the region used for the summation:

>>> calc_model_sum2d('circle(22,12,1)')
8.0
>>> calc_model_sum2d('field()-circle(22,12,1)')
16.0

Example 2

Apply the spatial filter to the model for the data set labelled "a2142":

>>> calc_model_sum2d('rotbox(4232.3,3876,300,200,43)', 'a2142')

PARAMETERS

The parameters for this function are:

Parameter Definition
reg The spatial filter to use. The default, none , is to use the whole data set.
id 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:

msum -- The sum of the model values, as fitted to the data, that lie within the given region. This includes any PSF included by `set_psf` .

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_data_sum2d, calc_ftest, calc_kcorr, calc_mlr, calc_source_sum2d, get_rate
visualization
contour, contour_data, contour_ratio, histogram1d, histogram2d, image_data, rebin