Evaluating a modelΒΆ
Normally Sherpa will handle model evaluation automatically, such as
during a fit or displaying the model results. However, the
models can be evalutated directly by passing in the
grid
(the independent axis)
directly. If mdl
is an instance of a Sherpa model - that
is it is derived from the
Model
class - then there are two standard ways to perform this
evaluation:
Call the model with the grid directly - e.g. for a one-dimensional grid use one of:
mdl(x) mdl(xlo, xhi)
Use the
calc()
method, which requires a sequence of parameter values and then the grid; for the one-dimensional case this would be:mdl.calc(pars, x) mdl.calc(pars, xlo, xhi)
In this case the parameter values do not need to match the values stored in the model itself. This can be useful when a model is to be embedded within another one, as shown in the two-dimensional user model example.
It is also possible to pass a model to a data object
and evaluate the model on a grid appropriate for the data,
using the
eval_model()
and
eval_model_to_fit()
methods.
This can be useful when working in an environment where the mapping
between the “native” grids used to represent data and models is
not a simple one-to-one relation, such as when analyzing
astronomical X-ray spectral data with an associated response
(i.e. a RMF file).