IterFit

class sherpa.fit.IterFit(data: Data | DataSimulFit, model: Model, stat: Stat, method: OptMethod, itermethod_opts: Mapping[str, Any] | None = None)[source] [edit on github]

Bases: object

Support iterative fitting schemes.

This class is highly coupled to Fit.

Changed in version 4.17.0: Several internal fields have been removed as they are now handled by the IterCallback class and the changes to the _get_callback routine.

Methods Summary

fit(statfunc, pars, parmins, parmaxes[, ...])

sigmarej(statfunc, pars, parmins, parmaxes)

Exclude points that are significately far away from the best fit.

Methods Documentation

fit(statfunc: Callable[[Concatenate[Sequence[float] | ndarray, P]], tuple[float, ndarray]], pars: Sequence[float] | ndarray, parmins: Sequence[float] | ndarray, parmaxes: Sequence[float] | ndarray, statargs: Sequence[Any] = (), statkwargs: Mapping[str, Any] | None = None) tuple[bool, ndarray, float, str, dict[str, Any]][source] [edit on github]
sigmarej(statfunc: Callable[[Concatenate[Sequence[float] | ndarray, P]], tuple[float, ndarray]], pars: Sequence[float] | ndarray, parmins: Sequence[float] | ndarray, parmaxes: Sequence[float] | ndarray, statargs: Sequence[Any] = (), statkwargs: Mapping[str, Any] | None = None, cache: bool = True) tuple[bool, ndarray, float, str, dict[str, Any]][source] [edit on github]

Exclude points that are significately far away from the best fit.

The sigmarej scheme is based on the IRAF sfit function [3], where after a fit data points are excluded if the value of (data-model) / error exceeds a threshold, and the data re-fit. This removal of data points continues until the fit has converged or a maximum number of iterations has been reached. The error removal can be asymmetric, since there are separate options for the lower and upper limits.

Raises:

sherpa.utils.err.FitErr – This exception is raised if the statistic is not supported. This method can only be used with Chi-Square statistics with errors.

Notes

The following keys are looked for in the itermethod_opts dictionary:

Key

Type

Description

maxiters

int > 0

The maximum number of iterations.

lrej

number > 0

The number of sigma below the model to reject.

hrej

number > 0

The number of sigma above the model to reject.

grow

int >= 0

If greater than zero, also remove this many data points to either side of the identified element.

References