Last modified: December 2023

AHELP for CIAO 4.16 Sherpa


Context: utilities


Set the units used when fitting and displaying spectral data.


set_analysis(id, quantity=None, type='rate', factor=0)

id - int or str
quantity - { 'channel', 'chan', 'bin', 'energy', 'ener', 'wavelength',
'wave' }
type - { 'rate', 'counts' }, optional
factor - int, optional


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.


Example 1

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

>>> set_analysis('wave')

Example 2

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

>>> set_analysis(2, 'energy')

Example 3

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')

Example 4

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)


The parameters for this function are:

Parameter Definition
id 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 The units to use for the analysis.
type The units to use on the Y axis of plots. The default is 'rate'.
factor The Y axis of plots is multiplied by Energy^factor or Wavelength^factor before display. The default is 0.


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.

Changes in CIAO

Changed in CIAO 4.16

The filter is now reported after the call for each dataset that is processed.


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

See Also

set_conf_opt, set_covar_opt, set_proj_opt
set_areascal, set_arf, set_backscal, set_bkg, set_coord, set_counts, set_data, set_dep, set_exposure, set_grouping, set_quality, set_rmf, set_staterror, set_syserror
set_iter_method, set_iter_method_opt, set_method, set_method_opt
get_par, get_xsabund, get_xscosmo, get_xsxsect, get_xsxset, set_bkg_model, set_bkg_source, set_full_model, set_model, set_par, set_pileup_model, set_source, set_xsabund, set_xscosmo, set_xsxsect, set_xsxset
set_prior, set_sampler, set_sampler_opt, set_stat
get_analysis, set_default_id