get_model_component

sherpa.astro.ui.get_model_component(name)

Returns a model component given its name.

Parameters:

name (str) – The name of the model component.

Returns:

component – The model component object.

Return type:

a sherpa.models.model.Model instance

Raises:

sherpa.utils.err.IdentifierErr – If there is no model component with the given name.

See also

create_model_component

Create a model component.

get_model

Return the model expression for a data set.

get_source

Return the source model expression for a data set.

list_model_components

List the names of all the model components.

set_model

Set the source model expression for a data set.

Notes

The model instances are named as modeltype.username, and it is the username component that is used here to access the instance.

Examples

When a model component is created, a variable is created that contains the model instance. The instance can also be returned with get_model_component, which can then be queried or used to change the model settings:

>>> create_model_component('gauss1d', 'gline')
>>> gmodel = get_model_component('gline')
>>> gmodel.name
'gauss1d.gline'
>>> print([p.name for p in gmodel.pars])
['fwhm', 'pos', 'ampl']
>>> gmodel.fwhm.val = 12.2
>>> gmodel.fwhm.freeze()