calamari.fitting.breakpoint.BreakpointResult#

class calamari.fitting.breakpoint.BreakpointResult(segmented, linear, x_break, x_break_err, slope_below, slope_below_err, slope_above, slope_above_err, slope_change, slope_change_err, delta_aic, delta_bic, rss_linear, rss_segmented, profile, profile_threshold, profile_interval, n_points, n_below, n_above, identified, warnings, params, model='segmented_linear', bent_cable=None, gamma=nan, gamma_err=nan, rss_bent_cable=nan, delta_aic_vs_segmented=nan, delta_bic_vs_segmented=nan)#

Bases: object

The outcome of fit_breakpoint(): a corner, and whether the data want one.

Read identified (and delta_bic) before x_break. A corner fitted to data with no break still has a value and a small HESSE error; neither means anything unless the comparison favours the break.

The corner model is model. Every field describes that model’s fit, except segmented and rss_segmented, which always describe the sharp corner. The fields from bent_cable onwards are filled only for model="bent_cable", and keep their defaults (None or NaN) for the default "segmented_linear".

segmented#

The segmented_linear fit, the sharp corner. Draw it with calamari.plot.plot_fit(), as any other fit. With model="bent_cable" it is the sharp-corner comparison.

Type:

calamari.fitting.engine.FitResult

linear#

The linear fit to the same points, the no-break alternative.

Type:

calamari.fitting.engine.FitResult

x_break, x_break_err

The fitted corner and its HESSE error, the canonical uncertainty (FT-1). For the bent cable, the centre of the bend, where its two arms meet when extended. NaN if the fit of model failed.

Type:

float

slope_below, slope_below_err

Slope below the corner, with its HESSE error.

Type:

float

slope_above, slope_above_err

Slope above the corner, slope_below + slope_change. Its error is propagated through the covariance by derive(), so the correlation between the two fitted slopes counts.

Type:

float

slope_change, slope_change_err

The change of slope across the corner, with its HESSE error.

Type:

float

delta_aic, delta_bic

Information criterion of the straight line minus that of the broken one (the model fitted), from ordinary least squares (see fit_breakpoint()). Positive means the break is preferred. Descriptive, not a test.

Type:

float

rss_linear, rss_segmented

The ordinary (unweighted) least-squares residual sums of squares the criteria are computed from, of the line and of the sharp corner. rss_segmented is minimised exactly over the corner within the limits, not only on the sample grid.

Type:

float

profile#

Columns x_break and rss: the unweighted residual sum of squares with the corner held at each sample position inside the limits (the grid the model’s guess searches), the other parameters solved exactly. For display: plot rss against x_break with profile_threshold as a horizontal line. For the bent cable, the half-width is profiled too (minimised at each corner, not held), and a third column gamma holds where that minimum fell.

Type:

pandas.DataFrame

profile_threshold#

The RSS level that defines profile_interval, rss * exp(1 / n_points), where rss is the minimum for model (rss_segmented or rss_bent_cable).

Type:

float

profile_interval#

(lower, upper): the smallest interval holding every corner whose profiled RSS is at or under profile_threshold, found exactly between sample positions. An end that does not come back above the threshold inside the limits is -inf or +inf: the data do not bound the corner on that side. Display-only, with the status MINOS has under FT-1: it is not a calibrated confidence interval (see fit_breakpoint()), and x_break_err stays canonical.

Type:

tuple of float

n_points, n_below, n_above

Points fitted, and how many lie strictly below and strictly above the fitted corner (zero each if the segmented fit failed).

Type:

int

identified#

True only when the fit of model and the line both converged, delta_bic > 0, and the corner is clear of its limits by more than its HESSE error. For the bent cable, also only when each straight arm keeps at least three points outside the bend. When False, warnings says why. A bend whose width is not resolved (see gamma) warns but does not unset it: the corner is still located, and the sharp one describes it as well.

Type:

bool

warnings#

The messages of the warnings fit_breakpoint() raised, in order.

Type:

tuple of str

params#

The recipe: 'model', 'limits' (the (lower, upper) bounds used on the corner), 'limits_given' (whether the caller set them), 'yerr' ('none', 'scalar' or 'array'), 'information_criteria' and 'profile_interval' (text naming the construction of each) and 'calamari_version'. For the bent cable, also 'gamma_limits', the bounds used on the half-width.

Type:

dict

model#

'segmented_linear' (the default) or 'bent_cable'.

Type:

str

bent_cable#

The bent_cable fit; None unless it was the model. Draw it with calamari.plot.plot_fit() beside segmented.

Type:

calamari.fitting.engine.FitResult or None

gamma, gamma_err

The half-width of the bend and its HESSE error, in the units of x. It is bounded below at half the median spacing of x, the narrowest bend the sampling resolves (see BENT_CABLE_GAMMA_FLOOR_SPACINGS), and a value within its error of that bound means the corner is sharp at this resolution. NaN unless the bent cable was fitted and converged.

Type:

float

rss_bent_cable#

The bent cable’s unweighted least-squares residual sum of squares, the smaller of the profiled minimum and the fitted curve’s own RSS.

Type:

float

delta_aic_vs_segmented, delta_bic_vs_segmented

Information criterion of the sharp corner minus that of the bent cable, on the same points, as for delta_bic. Positive means the rounded corner is preferred to the sharp one. Descriptive, not a test; NaN unless the bent cable was fitted.

Type:

float