sherpa.astro.ui.set_analysis(id, quantity=None, type='rate', factor=0)

Set the units used when fitting and displaying spectral data.

The set_analysis command sets the units for spectral analysis. Note that in order to change the units of a data set from ‘channel’ to ‘energy’ or ‘wavelength’, the appropriate ARF and RMF instrument response files must be loaded for that data set. The type and factor arguments control how the data is plotted.

  • id (int or str) – If only one argument is given then this is taken to be the quantity argument (in which case, the change is made to all data sets). If multiple arguments are given then this is the identifier for the data set to change.

  • quantity ({ 'channel', 'chan', 'bin', 'energy', 'ener', 'wavelength', 'wave' }) – The units to use for the analysis.

  • type ({ 'rate', 'counts' }, optional) – The units to use on the Y axis of plots. The default is ‘rate’.

  • factor (int, optional) – The Y axis of plots is multiplied by Energy^factor or Wavelength^factor before display. The default is 0.


sherpa.utils.err.IdentifierErr – If the id argument is not recognized.

See also


Return the analysis setting for a data set.


The function does not follow the normal Python standards for parameter use, since it is designed for easy interactive use. When called with a single un-named argument, it is taken to be the quantity parameter. If given two un-named arguments, then they are interpreted as the id and quantity parameters, respectively.


Set all loaded data sets to use wavelength for any future fitting or display.

>>> set_analysis('wave')

Set the data set with an identifier of 2 to use energy units.

>>> set_analysis(2, 'energy')

Set data set 1 to use channel units. Plots will use a Y axis of count/bin rather than the default count/s/bin.

>>> set_analysis(1, 'bin', 'counts')

Set data set 1 to use energy units. Plots of this data set will display keV on the X axis and counts keV (i.e. counts/keV * keV^2) in the Y axis.

>>> set_analysis(1, 'energy', 'counts', 2)