solarwindpy.fitfunctions.tex_infoο
Classes
|
- class TeXinfo(popt, psigma, TeX_function, chisq_dof, rsq, initial_guess_info=None, npts=None)[source]
Bases:
object- __init__(popt, psigma, TeX_function, chisq_dof, rsq, initial_guess_info=None, npts=None)[source]
A container for printing
FitFunctioninfo on a figure.- Parameters:
popt (dict) β Optimized fit parameters and their uncertainties.
psigma (dict) β Optimized fit parameters and their uncertainties.
TeX_function (str) β TeX-formatted function for printing
chisq_dof (scalar, None) β If not None, chisq per degree of freedom for the fit.
rsq (scalar, None) β If not None, \(R^2\) coefficient of determination for the fit.
initial_guess_info (dict, None) β If not None, a dict with keys corresponding to function arg names and values that are (p0, fit_bounds) for that fit parameter.
npts (scalar, None) β If not None, the number of data points in the fit. If not None, cast to int.
- property info
- property initial_guess_info
- property chisq_dof
- property npts
- property popt
- property psigma
- property rsq
\(R^2\) coefficient of determination.
- property TeX_argnames
- property TeX_function
- property TeX_popt
Create a dictionary with
(k, v)pairs corresponding to parameter values.(self.argnames, :math:`p_{\mathrm{opt}} \pm \sigma_p`)with the appropriate uncertainty.See
set_TeX_trans_argnamesto translate the argnames for TeX.
- property TeX_relative_error
Create a dictionary with (k, v) pairs corresponding to relative errors.
(self.argnames, psigma/popt).
- annotate_info(ax, **kwargs)[source]
Add the TeX_info annotation to ax.
- Parameters:
ax (mpl.Axes.axis_subplot)
bbox (dict) β dict(color=βwheatβ, alpha=0.75)
xloc (scalar) β 0.05, 0.9
yloc (scalar) β 0.05, 0.9
ha (str) β ha - horizontalalignment (defaults βleftβ) va - verticalalignment (default βrightβ)
va (str) β ha - horizontalalignment (defaults βleftβ) va - verticalalignment (default βrightβ)
transform β ax.transAxes
kwargs β Others passed to ax.text.
- build_info(**kwargs)[source]
Generate a TeX-formatted string with the desired info.
- Parameters:
TeX_popt (dict) β
FitFunction.TeX_popt()dictionary, which contains keys identifying the parameter and values their value.TeX_function (str) β
FitFunction.TeX_function()contents giving the functional form in TeX.chisq_dof (bool) β If True, include chisq/dof in the info. It is printed to 2 decimal places.
relative_error (bool) β If True, print out relative error as \(\Delta(x)/x\) for all fit parameters x.
rsq (bool) β If True, include \(R^2\) coefficient of determination.
npts (bool) β If True, include the number of points in the fit.
convert_pow_10 (bool) β If True, use 10^{X} format. Otherwise, use eX format. Note that simplify_info_for_paper must be disabled.
strip_uncertaintites (bool) β If True, strip fit uncertainties from reported parameters.
simplify_info_for_paper (bool) β If True, simplify the printout to only print the quantities to their uncertainty in standard decimal (not expoential) notation. This option overrides convert_pow_10.
add_initial_guess (bool) β If True and
initial_guess_info()is not None, add (p0, fit_bounds) table to info.additional_info (str or iterable of strings) β Additional info added to the fit info annotation box.
annotate_fcn (FunctionType) β Function that manipulates the final TeX_info str before returning.
- set_initial_guess_info(new)[source]
- set_npts(new)[source]
- set_popt_psigma(popt, psigma)[source]
- set_TeX_argnames(**kwargs)[source]
Define the mapping to format LaTeX function argnames.
- set_TeX_function(TeX_function)[source]
- set_chisq_dof(new)[source]
- set_rsq(new)[source]
- val_uncert_2_string(value, uncertainty)[source]
Convert a value, uncertainty pair to a string.
Where the value is reported to the first non-zero digit of the uncertainty.
Require that
value > uncertainty.Examples
The generated string uses \(\pm\) to denote the uncertainty.
>>> tex = TeXinfo({}, {}, "", None, None) >>> a = 3.1415 >>> b = 0.01 >>> tex.val_uncert_2_string(a, b) '3.14e+00 \\pm 1e-02'