Chandra X-Ray Observatory
Skip to the navigation links
Last modified: 28 September 2015


Bugs: set_full_model


Simultaneous fitting of filtered/grouped source and background results in filter "shape mismatch" error

If a background data set and associated responses are indirectly loaded into a Sherpa session via the load_pha function for loading source data - and the set_full_model and set_bkg_full_model functions are being used to manually define the source and background model expressions, and the data have been filtered or grouped - - then a "Shape Mismatch" error will result when the source and background data are simultaneously fit. This can be resolved by explicitly defining background responses using load_bkg_arf and load_bkg_rmf, e.g.:

sherpa> load_bkg_arf(1, 'obs1.arf')
sherpa> load_bkg_arf(2, 'obs2.arf')
sherpa> load_bkg_arf(3, 'obs3.arf')
sherpa> load_bkg_arf(4, 'obs4.arf')

sherpa> load_bkg_rmf(1, 'obs1.rmf')
sherpa> load_bkg_rmf(2, 'obs2.rmf')
sherpa> load_bkg_rmf(3, 'obs3.rmf')
sherpa> load_bkg_rmf(4, 'obs4.rmf')

The issue is that the source and background data sets in this scenario should *not* share response references when filters and grouping schemes are used, because Sherpa does not know how to adjust the response according to a filter for each folded model component in the expression as the model is evaluated. So, for example, if the ignore command is used to set up a filter on both the source and the background data sets, and then the source data is grouped by counts, Sherpa clears that filter from the source, but not the background; this results in a filter mismatch between the source and background.

Additional issues show up when the background response has to be used in both source and background model expressions in the simultaneous fitting. In such cases, the separate background response files have to be set separately for the source and the background model expressions. This can be accomplished with the following sets of commands:

sherpa> rsp = get_response()

sherpa> bkg_arf_in_src = unpack_arf('obs1.arf')
sherpa> bkg_rmf_in_src = unpack_rmf('obs1.rmf')

sherpa> bkg_arf_in_bkg = unpack_arf('obs1.arf')
sherpa> bkg_rmf_in_bkg = unpack_rmf('obs1.rmf')

sherpa> set_full_model(1,rsp(xsphabs.abs1*powlaw1d.pow1) + bkg_scale*bkg_arf_in_src(bkg_rmf_in_src(bkg_model)))

sherpa> set_bkg_full_model(1, bkg_arf_in_bkg(bkg_rmf_in_bkg(bkg_model)))

Finally, note that when an ARF is not included in the instrument response used in a manually defined source or background model expression, multiplication by the exposure time is not done automatically and implicitly, as in the case when the ARF is included. This means that when defining manual source or background model expressions with set_full_model/set_bkg_full_model using an RMF-only response, the exposure time must be entered explicitly in the model definition, as shown below.

sherpa> bkg_rmf_in_src = unpack_rmf('obs1.rmf')
sherpa> bkg_rmf_in_bkg = unpack_rmf('obs1.rmf')

sherpa> set_full_model(1,rsp(xsphabs.abs1*powlaw1d.pow1) + bkg_scale*bkg_rmf_in_src(get_exposure(bkg_id=1)*bkg_model))
sherpa> set_bkg_full_model(1, bkg_rmf_in_bkg(get_exposure(bkg_id=1)*bkg_model))

The user is advised to always check manually defined source and background model expressions using the show_model command, to ensure that all necessary components are included.

Last modified: 28 September 2015
Smithsonian Institute Smithsonian Institute

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email: Smithsonian Institution, Copyright © 1998-2017. All rights reserved.