ModelDomainRegridder1D

class sherpa.models.regrid.ModelDomainRegridder1D(evaluation_space=None, name='regrid1d')[source]

Bases: object

Allow 1D models to be evaluated on a different grid.

This class is not used directly in a model expression; instead it creates an instance that is used to evaluate the model.

method

The function that interpolates the data from the internal grid onto the requested grid. The default is sherpa.utils.neville. This is only used for point grids, as integrated grids use a simple rebinning scheme.

Examples

The “internal” model (gaussian plus constant) will be evaluated on the grid 0 to 10 (spacing of 0.5), and then linearly-interpolated onto the desired grid (1 to 8, spacing of 0.7). In this example there is no benefit to this approach - it is easier just to evaluate internal_mdl on the grid x - but it illustrates the approach.

>>> from sherpa.models import Gauss1D, Const1D
>>> internal_mdl = Gauss1D() + Const1D()
>>> eval_space = EvaluationSpace1D(np.arange(0, 10, 0.5))
>>> rmdl = ModelDomainRegridder1D(eval_space)
>>> mdl = rmdl.apply_to(internal_mdl)
>>> x = np.arange(1, 8, 0.7)
>>> y = mdl(x)

Attributes Summary

grid

Methods Summary

apply_to(model) Evaluate a model on a different grid.
calc(pars, modelfunc, *args, **kwargs) Evaluate and regrid a model

Attributes Documentation

grid

Methods Documentation

apply_to(model)[source]

Evaluate a model on a different grid.

calc(pars, modelfunc, *args, **kwargs)[source]

Evaluate and regrid a model

Evaluate the model on the internal grid and then interpolate onto the desired grid.

Parameters:
  • pars (sequence of numbers) – The parameter values of the model.
  • modelfunc – The model to evaluate (the calc attribute of the model)
  • args – The grid to interpolate the model onto. This must match the format of the grid attribute of the model - i.e. non-integrate (single array) or integrated (a pair of equal-sized arrays).
  • kwargs – Keyword arguments for the model.

Notes

If the requested grid (i.e. that defined by args) does not overlap the stored grid (the grid attribute) then all values are set to 0. However, if the grids partially overlap then there will be extrapolation (depending on the method).

It is not clear yet whether the restriction on grid type (i.e. must match between the requested grid and the intenal grid whether it is integrated or non-integrated) is too restrictive.