    Create a user-defined model class.

add_model(modelclass, args=(), kwargs={})

Create a model from a class. The name of the class can then be used to create model components - e.g. with `set_model` or

`create_model_component` - as with any existing Sherpa model.

The following example creates a model type called "mygauss1d" which will behave excatly the same as the existing "gauss1d" model. Normally the class used with `add_model` would add new functionality.

>>> from sherpa.models import Gauss1D >>> class MyGauss1D(Gauss1D): ... pass ... >>> add_model(MyGauss1D) >>> set_source(mygauss1d.g1 + mygauss1d.g2)

PARAMETERS

The parameters for this function are:

Parameter
Definition
modelclass
A class derived from `ArithmeticModel` . This class defines the functional form and the parameters of the model.
args
Arguments for the class constructor.
kwargs
Keyword arguments for the class constructor.

Notes

The `load_user_model` function is designed to make it easy to add a model, but the interface is not the same as the existing models (such as having to call both `load_user_model` and

`add_user_pars` for each new instance). The `add_model`

function is used to add a model as a Python class, which is more work to set up, but then acts the same way as the existing models.

See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.

December 2023