ModelDomainRegridder2D¶
-
class
sherpa.models.regrid.
ModelDomainRegridder2D
(evaluation_space=None, name='regrid2d')[source] [edit on github]¶ Bases:
object
Allow 2D 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.
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 gridx, y
- but it illustrates the approach.>>> from sherpa.models import Gauss2D, Const2D >>> internal_mdl = Gauss2D() + Const2D() >>> eval_space = EvaluationSpace2D(np.arange(0, 10, 0.5), np.arange(0, 10, 0.5)) >>> rmdl = ModelDomainRegridder2D(eval_space) >>> mdl = rmdl.apply_to(internal_mdl) >>> x = np.arange(1, 8, 0.7) >>> y = np.arange(1, 8, 0.7) >>> x, y = reshape_2d_arrays(x, y) >>> z = mdl(x, y)
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] [edit on github]¶ Evaluate a model on a different grid.
-
calc
(pars, modelfunc, *args, **kwargs)[source] [edit on github]¶ 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 (x, y arrays) or integrated (xlo, ylo, xhi, yhi).
- 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.
-