Chandra X-Ray Observatory
Skip to the navigation links
Last modified: December 2010

Jump to: Description · Examples · Bugs · See Also

AHELP for CIAO 4.3 Sherpa v1


Context: methods


Return the value of the specified option for the current iterative fitting method




The get_iter_method_opt command prints the value of the named option for the current iterative fitting method; if no argument is given, it lists all options and their associated values. The name of the current iterative fitting method can be printed with the get_iter_method_name command (default is "none"), and the iterative fitting method can be set to "none", "primini", or "sigmarej" with the set_iter_method command (see "ahelp get_iter_method_name" and "ahelp set_iter_method"). All available iterative fitting methods are returned by the list_iter_methods command. The essence of an iterative fitting method is that the chosen fit optimization method can be called several times, until some criterion is met. The fit statistic and optimization methods are selected independently of the iterative fitting method.

  • option - the name of the iterative fitting option whose value should be returned

If the iterative fitting method is "none", then no iterative fitting is done when "fit()" is called; the optimization method is called once, and Sherpa otherwise operates as expected.

Primini's method is used for re-calculating statistical errors using the best-fit model parameters from the *previous* fit, until the fit can no longer be improved.

The options which may be edited for Primini's method are:

  • maxiters - maximum number of iterations to perform, even if the fit statistic has not converged
  • name - name of the current iterative fitting method
  • tol - the iterative fitting is stopped when the statistic varies by less than the tolerance value between iterations.

The sigma-rejection method is based on the IRAF SFIT function. In successive fits, data points for which ((data - model) / error) exceeds some threshold are added to the filter, and automatically excluded from the next fit. Iterations cease when there is no change in the filter from one iteration to the next, or when the fit has iterated a user-specified maximum number of times.

The options which may be edited for Sigma-rejection are:

  • lrej - data point rejection criterion in units of sigma, for data points below the model
  • maxiters - maximum number of iterations to perform in the fit (if 0, the fit will run to convergence, i.e., until there is no change in the filter)
  • grow - rejection growing radius (when a given data point is to be filtered out, this parameter sets the number of pixels adjacent to that pixel which are also to be filtered out; i.e., if 0, only the data point itself is filtered out; if 1, the data point and its two immediate neighbors are filtered out, and so on)
  • name - name of the current iterative fitting method
  • hrej - data point rejection criterion in units of sigma, for data points above the model

Primini's method and sigma-rejection can only be called when the fit statistic is a chi-squared statistic; it cannot be used with least-squares, Cash or C-statistic.

Example 1

sherpa> set_stat("chi2datavar")
sherpa> set_method("neldermead")
sherpa> print(get_iter_method_name())
sherpa> print(get_iter_method_opt())
{'maxiters': 10, 'name': 'primini', 'tol': 0.001}
sherpa> fit()

Print all of the options and associated values of Primini's iterative fitting method before fitting data set 1 (where the Nelder-Mead optimization method will be called until the fit can no longer be improved).

Example 2

sherpa> set_stat("chi2xspecvar")
sherpa> set_method("levmar")
sherpa> print(get_iter_method_name())
sherpa> print(get_iter_method_opt())
{'name': 'none'}

No iterative fitting method has been set (default is 'none'), therefore no iterative fitting is done when data set 2 is fit; the Levenberg-Marquardt optimization method is called once. In this case, only the name of the current iterative fitting method is printed when get_iter_method_opt() is called (which is 'none').

Example 3

sherpa> set_stat("chi2gehrels")
sherpa> set_method("simplex")
sherpa> set_iter_method("sigmarej")
sherpa> print(get_iter_method_opt())
{'lrej': 3, 'maxiters': 5, 'grow': 0, 'name': 'sigmarej', 'hrej': 3}
sherpa> set_iter_method_opt("maxiters", 10)
sherpa> print(get_iter_method_opt()["maxiters"])
sherpa> fit(2,3)

The sigma-rejection iterative fitting method is used in the simultaneous fitting of data sets 2 and 3. The full list of available options and associated values for this method are returned with get_iter_method_opt(); the maximum number of iterations for this method is set to 10 with set_iter_method_opt; and the changed value of 'maxiters' is checked with 'get_iter_method_opt()["maxiters"]'.


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

See Also

get_conf, get_covar, get_int_proj, get_int_unc, get_proj, get_reg_proj, get_reg_unc
get_areascal, get_arf, get_arf_plot, get_axes, get_backscal, get_bkg, get_bkg_plot, get_bkg_scale, get_coord, get_counts, get_data, get_data_plot, get_dep, get_dims, get_error, get_exposure, get_grouping, get_indep, get_quality, get_rmf, get_specresp, get_staterror, get_syserror
calc_stat_info, fit, get_fit, get_stat_info
get_default_id, list_stats
get_iter_method_name, get_method, list_iter_methods, set_iter_method, set_iter_method_opt
get_model, get_model_component, get_model_component_image, get_model_component_plot, get_model_plot, get_num_par, get_order_plot, get_par, get_pileup_model, get_response, get_source, get_source_component_image, get_source_component_plot, image_source
get_split_plot, plot_fit
get_kernel, get_psf
get_chisqr_plot, get_delchi_plot, get_stat
calc_chisqr, calc_stat, get_analysis, get_rate
contour_resid, get_ratio, get_resid, image_fit, image_getregion

Last modified: December 2010
Smithsonian Institute Smithsonian Institute

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email: Smithsonian Institution, Copyright © 1998-2019. All rights reserved.