6.3.4. Optimization functions¶
6.3.4.1. Fitting spectra¶
- class pyspex.optimize.Fit[source]¶
This is the parent class of all fit related commands.
- Variables:
stat (basestring) – Fit statistics.
cstat (float) – C-statistics value.
chisq (float) – Chi-squared value.
wstat (float) – W-statistics value (not recommended).
nfree (int) – Degrees of freedom.
cstatexp (float) – Expected C-statistics value (C-stat only).
cstatrms (float) – RMS uncertainty on expected C-stat value.
ann_rt (float) – Simulated annealing: rt
ann_eps (float) – Simulated annealing: eps
ann_t (float) – Simulated annealing: t
ann_vm (float) – Simulated annealing: vm
ann_ns (int) – Simulated annealing: ns
ann_max (int) – Simulated annealing: max evaluations
ann_print (int) – Simulated annealing: print flag
- fit(niter=100)[source]¶
Execute the SPEX fit command. The maximum number of iterations (niter) can be optionally set.
- Parameters:
niter (int) – Number of fit iterations.
- get_method()[source]¶
Get the current type of statistics being used in the fit, for example chi2, cstat or wstat.
- get_statistic()[source]¶
Get the current type of statistics being used in the fit, for example chi2, cstat or wstat.
- print(status)[source]¶
Print each fit iteration to the console (default is True). The status variable can be either True or False, which means printing is on or off, respectively.
- Parameters:
status (bool) – Set fit to high verbosity (True is yes, False is no).
- set_method(meth)[source]¶
Set the desired fit statistics.
- Parameters:
stat (str) – Abbreviation for the fit statistics to be used. For example: ‘csta’, ‘chi2’, ‘wsta’.
- set_statistic(stat)[source]¶
Set the desired fit statistics.
- Parameters:
stat (str) – Abbreviation for the fit statistics to be used. For example: ‘csta’, ‘chi2’, ‘wsta’.
6.3.4.2. Error calculation¶
- class pyspex.optimize.Error[source]¶
Class to calculate errors for free fit parameters.
- Variables:
sector (int) – Sector number of parameter
component (int) – Component number of parameter
parameter (str) – Parameter name
value (float) – Parameter value
lerr (float) – Lower error boundary
uerr (float) – Upper error boundary
lc (bool) – Is there a lower C-stat or chi**2 value found?
cmin (float) – Lowest C-stat or chi**2 value
pmin (float) – Parameter value for which a better C-stat or Chi**2 was found
dchi (float) – Delta C-stat or chi**2 to optimize for
calculated (bool) – Is the error calculated?