link
- sherpa.astro.ui.link(par, val)
Link a parameter to a value.
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.
Changed in version 4.16.1: Source models no longer have to contain the linked parameter.
- Parameters:
See also
Notes
The
linkattribute of the parameter is set to match the mathematical expression used forval.In the following, the fit will vary the
posparameter even though thesrc2component is not part of the source expression (this behavior changed in the 4.16.1 release):>>> set_source(1, gauss1d.src1) >>> gauss1d.src2 >>> link(src1.pos, src2.pos) >>> fit(1)
The
lparsattribute of a source model will include these “extra” parameters:>>> get_source(1).lpars (<Parameter 'pos' of model 'src2'>,)
Examples
The
fwhmparameter of theg2model is set to be the same as thefwhmparameter of theg1model.>>> link(g2.fwhm, g1.fwhm)
Fix the
posparameter ofg2to be 2.3 more than theposparameter of theg1model.>>> 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