    Link a parameter to a value.

link(par, val)
par - str or Parameter

A parameter can be linked to another parameter value, or function of that value, rather than be an independent value. As the linked-to values change, the parameter value will change.

The fwhm parameter of the g2 model is set to be the same as the fwhm parameter of the g1 model.

>>> link(g2.fwhm, g1.fwhm)

Fix the pos parameter of g2 to be 2.3 more than the

pos parameter of the g1 model.

>>> gauss1d.g1 >>> gauss1d.g2 >>> g1.pos = 12.2 >>> link(g2.pos, g1.pos + 2.3) >>> g2.pos.val 14.5 >>> g1.pos = 12.1 >>> g2.pos.val 14.399999999999999

PARAMETERS

The parameters for this function are:

Parameter
Definition
par
The parameter to link.
val
The value - which can be a numeric value or a function of other model parameters, to set `par` to.

Notes

The link attribute of the parameter is set to match the mathematical expression used for `val` .

For a parameter value to be varied during a fit, it must be part of one of the source expressions involved in the fit. So, in the following, the src1.xpos parameter will not be varied because the src2 model - from which it takes its value - is not included in the source expression of any of the data sets being fit.

>>> set_source(1, gauss1d.src1) >>> gauss1d.src2 >>> link(src1.xpos, src2.xpos) >>> fit(1)

One way to work around this is to include the model but with zero signal: for example

>>> set_source(1, gauss1d.src1 + 0 * gauss1d.src2)

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

December 2023