growthcurves.non_parametric module#
Non-parametric fitting methods for growth curves.
This module provides non-parametric methods for growth curve analysis, including sliding window fitting and no-growth detection.
All methods operate in linear OD space (not log-transformed).
- growthcurves.non_parametric.fit_non_parametric(t, N, method='sliding_window', window_points=15, smooth='fast', use_weights=True, **kwargs)[source]#
Calculate growth statistics using non-parametric methods.
This unified function supports multiple methods for calculating the maximum specific growth rate (Umax): - “sliding_window”: Finds maximum slope in log-transformed OD across windows - “spline”: Fits spline to entire curve and calculates from derivative
- Parameters:
t – Time array (hours)
N – OD values (baseline-corrected, must be positive)
method – Method for calculating Umax (“sliding_window” or “spline”)
window_points – Number of points in sliding window (for sliding_window method)
smooth – Smoothing mode/value for spline method. - “fast”: notebook auto-default rule mapped to lam - “slow”: GCV-selected smoothing (auto GCV) - float: manual lam value
use_weights – Whether to apply OD-dependent weighting for spline method
**kwargs – Additional arguments (for compatibility)
- Returns:
- params: Model parameters (includes fit_t_min, fit_t_max, and other
method-specific values)
model_type: Method used for fitting
- Return type:
Dict containing
- growthcurves.non_parametric.fit_sliding_window(t, N, window_points=15, step=None, n_fits=None, **kwargs)[source]#
Calculate maximum specific growth rate using the sliding window method.
Finds the maximum specific growth rate by fitting a line to log-transformed OD N in consecutive windows using the Theil-Sen estimator, selecting the window with the steepest slope.
- Parameters:
t – Time array (hours)
N – OD values (baseline-corrected, must be positive)
window_points – Number of points in each sliding window
step – Step size for sliding window (default: 1 if step is None and n_fits is None)
n_fits – Approximate number of fits to perform (default: None). Ignored if step is provided.
- Returns:
- slope: Slope of the linear fit in log space
(equals specific growth rate, h⁻¹)
intercept: Intercept of the linear fit in log space
time_at_umax: Time at maximum growth rate (hours)
model_type: “sliding_window”
Returns None if calculation fails.
- Return type:
Dict with model parameters
- growthcurves.non_parametric.fit_spline(t, N, smooth='fast', use_weights=True)[source]#
Calculate maximum specific growth rate using spline fitting.
Fits a smoothing spline to log-transformed OD N and calculates the maximum specific growth rate from the spline’s derivative.
- Parameters:
t – Time array (hours)
N – OD values
smooth – Smoothing mode/value. - “fast”: notebook auto-default rule mapped to lam - “slow”: GCV-selected smoothing (lam=None) - float: manual lam value
use_weights – Whether to apply OD-dependent weighting (default: True)
- Returns:
- t_knots: Spline knot points (t values)
spline_coeffs: Spline coefficients
spline_k: Spline degree (3)
time_at_umax: Time at maximum growth rate (hours)
model_type: “spline”
Returns None if calculation fails.
- Return type:
Dict with model parameters