solarwindpy.fitfunctions.trend_fits

trend_fits.

Apply a fit along one dimention of a 2D aggregated data and then fit the results of those 1D fits along the 2nd dimension of the aggregated data.

Classes

Popt1DKeys

alias of Popt1Dkeys

TrendFit(agged, trendfunc[, trend_logx, ...])

Popt1DKeys

alias of Popt1Dkeys

class TrendFit(agged, trendfunc, trend_logx=False, ykey1d='mu', wkey1d='sigma', ffunc1d=None)[source]

Bases: object

__init__(agged, trendfunc, trend_logx=False, ykey1d='mu', wkey1d='sigma', ffunc1d=None)[source]

Note that TrendFit.make_1dfits must be called by the user.

So that any kwargs may be passed to the 1D make_fit method, which are passed to curve_fit, allowing the user to specify fit methods, bounds, etc.

Similarly, TrendFit.trend_fit.make_fit must be called by the user so that kwargs can be appropriately passed to curve_fit.

call signagure after instantiation is:

  1. Set x and y labels: TrendFunc.set_labels(x=<x label>, y=<y label>)

  2. Make the 1D fit functions: TrendFunc.make_ffunc1ds()

  3. TrendFunc.make_1dfits(): Run 1D fits

  4. TrendFunc.make_trend_func(): init trend function

  5. TrendFunc.trend_func.make_fit(): run trend fits

Parameters:
  • agged (pd.DataFrame) – x-values along the columns and y-values along the index.

  • trendfunc (fitfunctoins.FitFunction) – The function to fit the trend of the ffunc1d popts.

  • trend_logx (bool) – If True, take \(10.0^x\) for x-values passed to trendfunc_class.

  • ykey1d (str) – The keys to select y-values and weights from the 1D FitFunction`s for passing to the `FitFunction for fitting the trend.

  • wkey1d (str) – The keys to select y-values and weights from the 1D FitFunction`s for passing to the `FitFunction for fitting the trend.

  • ffunc1d (fitfunctoins.FitFunction or None) – Applied in each x-bin. If None, fitfunctions.Gaussian.

property agged
property ffunc1d_class

FitFunction to apply in each x-bin.

property trendfunc_class

FitFunction to apply each popt.

Of the ffunc1d along the x-axis.

property ffuncs

The 1D FitFunction applied in each x-bin.

property popt_1d

Optimized parameters from 1D fits.

property psigma_1d

Fit uncertainties from 1D fits.

property trend_func

trendfunc_class applied along the x-axis.

property bad_fits

Bad 1D fits identifyied when running make_1dfits.

property popt1d_keys
property trend_logx

If True, trend’s x-axis is log-scaled.

Should probably change this to pull from trend_func somehow, but unsure how to do so.

make_ffunc1ds(**kwargs)[source]

Kwargs passed to self.ffunc1d(x, y, **kwargs).

make_1dfits(**kwargs)[source]

Execute fits for all 1D functions.

Removes bad fits from ffuncs and saves them in bad_fits.

Parameters:

**kwargs – Passed to each FitFunction.make_fit()

plot_all_ffuncs(legend_title_fmt='%.0f', **kwargs)[source]

Plot all fit functions.

Parameters:
  • legend_title_fmt (str) – A string template for formatting the legend titles. Use % formatting so we can easily instert TeX into legend_title_fmt should we desire.

  • kwargs – Passed to ffunc.plot_raw_used_fit().

make_trend_func(**kwargs)[source]

Make trend function.

Parameters:

kwargs – passed to trendfunc_class(x, y, **kwargs)

plot_all_popt_1d(ax=None, only_plot_data_in_trend_fit=False, plot_window=True, **kwargs)[source]

Plot all the 1D popt appropriate for identifying the trend on ax.

Plot all the 1D popt appropriate for identifying the trend on ax.

kwargs passed to ax.errorbar

plot_trend_fit_resid(**kwargs)[source]
plot_trend_and_resid_on_ffuncs(trend_kwargs=None, fit1d_kwargs=None)[source]

Plot the trend fit on the 1D popt and the trend fit residuals.

plot_1d_popt_and_trend(ax=None, **kwargs)[source]

Plot the trend and 1D popt, without trend residuals, on ax

set_agged(new)[source]
set_fitfunctions(ffunc1d, trendfunc)[source]
set_shared_labels(**kwargs)[source]

Axis labels are shared between the trend_func and ffuncs.

Here, we update them according to placement in trend_func(), but properly locating them for ffuncs().

Parameters: