solarwindpy.fitfunctions.tex_info.TeXinfo

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 FitFunction info 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_argnames to 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'