eqwidth

sherpa.astro.ui.eqwidth(src, combo, id=None, lo=None, hi=None, bkg_id=None)

Calculate the equivalent width of an emission or absorption line.

Parameters:
  • src – The continuum model (this may contain multiple components).
  • combo – The continuum plus line (absorption or emission) model.
  • lo (optional) – The lower limit for the calculation (the units are set by set_analysis for the data set). The default value (None) means that the lower range of the data set is used.
  • hi (optional) – The upper limit for the calculation (the units are set by set_analysis for the data set). The default value (None) means that the upper range of the data set is used.
  • id (int or string, optional) – The identifier of the data set to use. The default value (None) means that the default identifier, as returned by get_default_id, is used.
  • bkg_id (int or string, optional) – The identifier of the background component to use. This should only be set when the line to be measured is in the background model.
Returns:

width – The equivalent width [1] in the appropriate units (as given by set_analysis).

Return type:

number

See also

calc_model_sum()
Sum up the fitted model over a pass band.
calc_source_sum()
Calculate the un-convolved model signal.
get_default_id()
Return the default data set identifier.
set_model()
Set the source model expression.

References

[1]http://en.wikipedia.org/wiki/Equivalent_width

Examples

Set a source model (a powerlaw for the continuum and a gaussian for the line), fit it, and then evaluate the equivalent width of the line. The example assumes that this is a PHA data set, with an associated response, so that the analysis can be done in wavelength units.

>>> set_source(powlaw1d.cont + gauss1d.line)
>>> set_analysis('wavelength')
>>> fit()
>>> eqwidth(cont, cont+line)
2.1001988282497308

The calculation is restricted to the range 20 to 20 Angstroms.

>>> eqwidth(cont, cont+line, lo=20, hi=24)
1.9882824973082310

The calculation is done for the background model of data set 2, over the range 0.5 to 2 (the units of this are whatever the analysis setting for this data set id).

>>> set_bkg_source(2, const1d.flat + gauss1d.bline)
>>> eqwidth(flat, flat+bline, id=2, bkg_id=1, lo=0.5, hi=2)
0.45494599793003426