growthcurves.models module#

Growth curve models.

This module defines parametric growth model functions for growth curve analysis. Models are categorized into two classes:

  1. Mechanistic models: Defined as ODEs (dN/dt), fitted using ODE integration - mech_logistic, mech_gompertz, mech_richards, mech_baranyi

  2. Phenomenological models: Fitted directly to ln(OD/OD0) - phenom_logistic, phenom_gompertz, phenom_gompertz_modified, phenom_richards

growthcurves.models.evaluate_parametric_model(t, model_type, params)[source]#

Evaluate a fitted parametric model at given t points.

This function provides a unified interface for evaluating any parametric growth model, eliminating the need for repeated if-elif chains.

Parameters:
  • t – Time array or scalar

  • model_type – Model type string (e.g., ‘mech_logistic’, ‘phenom_gompertz’)

  • params – Parameter dictionary containing model-specific parameters

Returns:

OD values predicted by the model at t points

Raises:

ValueError – If model_type is not recognized

Example

>>> params = {"mu": 0.5, "K": 0.5, "N0": 0.001, "y0": 0.05}
>>> y_fit = evaluate_parametric_model(t, "mech_logistic", params)
growthcurves.models.get_all_models()[source]#

Return a set of all model names (parametric + non-parametric).

growthcurves.models.get_all_parametric_models()[source]#

Return a set of all parametric model names (mechanistic + phenomenological).

growthcurves.models.get_model_category(model_type)[source]#

Return the category of a model type.

Parameters:

model_type – Model type string

Returns:

“mechanistic”, “phenomenological”, or “non_parametric”

Return type:

Category string

Raises:

ValueError – If model_type is not recognized

growthcurves.models.mech_baranyi_model(t, mu, K, N0, h0, y0)[source]#

Solve Baranyi-Roberts ODE and return OD values at t points.

ODE: dN/dt = μ * A(t) * (1 - N/K) * N where A(t) = exp(μ*t) / (exp(h0) - 1 + exp(μ*t)) OD(t) = y0 + N(t)

Parameters:
  • t – Time array

  • mu – Maximum specific growth rate (h^-1)

  • K – Carrying capacity above baseline (maximum ΔOD)

  • N0 – Initial population above baseline at t=0

  • h0 – Dimensionless lag parameter

  • y0 – Baseline OD (offset parameter)

Returns:

OD values at each time point

growthcurves.models.mech_baranyi_ode(t, N, mu, K, h0)[source]#

Baranyi-Roberts growth ODE: dN/dt = μ * A(t) * (1 - N/K) * N where A(t) = exp(μ*t) / (exp(h0) - 1 + exp(μ*t))

Parameters:
  • t – Time (scalar)

  • N – Population (OD) at t

  • mu – Maximum specific growth rate (h^-1)

  • K – Carrying capacity (maximum OD)

  • h0 – Dimensionless lag parameter

Returns:

Rate of change

Return type:

dN/dt

growthcurves.models.mech_gompertz_model(t, mu, K, N0, y0)[source]#

Solve Gompertz ODE and return OD values at time points.

ODE: dN/dt = μ * log(K/N) * N OD(t) = y0 + N(t)

Parameters:
  • t – Time array

  • mu – Intrinsic growth rate (h^-1)

  • K – Carrying capacity above baseline (maximum ΔOD)

  • N0 – Initial population above baseline at t=0

  • y0 – Baseline OD (offset parameter)

Returns:

OD values at each t point

growthcurves.models.mech_gompertz_ode(t, N, mu, K)[source]#

Gompertz growth ODE: dN/dt = μ * log(K/N) * N

Parameters:
  • t – Time (scalar)

  • N – Population (OD) at t

  • mu – Intrinsic growth rate (h^-1)

  • K – Carrying capacity (maximum OD)

Returns:

Rate of change

Return type:

dN/dt

growthcurves.models.mech_logistic_model(t, mu, K, N0, y0)[source]#

Solve logistic ODE and return OD values at t points.

ODE: dN/dt = μ * (1 - N/K) * N OD(t) = y0 + N(t)

Parameters:
  • t – Time array

  • mu – Intrinsic growth rate (h^-1)

  • K – Carrying capacity above baseline (maximum ΔOD)

  • N0 – Initial population above baseline at t=0

  • y0 – Baseline OD (offset parameter)

Returns:

OD values at each t point

growthcurves.models.mech_logistic_ode(t, N, mu, K)[source]#

Logistic growth ODE: dN/dt = μ * (1 - N/K) * N

Parameters:
  • t – Time (scalar)

  • N – Population (OD) at t

  • mu – Intrinsic growth rate (h^-1)

  • K – Carrying capacity (maximum OD)

Returns:

Rate of change

Return type:

dN/dt

growthcurves.models.mech_richards_model(t, mu, K, N0, beta, y0)[source]#

Solve Richards ODE and return OD values at time points.

ODE: dN/dt = μ * (1 - (N/K)^β) * N OD(t) = y0 + N(t)

Parameters:
  • t – Time array

  • mu – Intrinsic growth rate (h^-1)

  • K – Carrying capacity above baseline (maximum ΔOD)

  • N0 – Initial population above baseline at t=0

  • beta – Shape parameter

  • y0 – Baseline OD (offset parameter)

Returns:

OD values at each time point

growthcurves.models.mech_richards_ode(t, N, mu, K, beta)[source]#

Richards growth ODE: dN/dt = μ * (1 - (N/K)^β) * N

Parameters:
  • t – Time (scalar)

  • N – Population (OD) at t

  • mu – Intrinsic growth rate (h^-1)

  • K – Carrying capacity (maximum OD)

  • beta – Shape parameter

Returns:

Rate of change

Return type:

dN/dt

growthcurves.models.phenom_gompertz_model(t, A, mu_max, lam, N0)[source]#

Phenomenological Gompertz model in ln-space.

ln(Nt/N0) = A * exp(-exp(μ_max * e * (λ - t) / A + 1))

Parameters:
  • t – Time array

  • A – Maximum ln(OD/OD0) (amplitude)

  • mu_max – Maximum specific growth rate (h^-1)

  • lam – Lag t (hours)

  • N0 – Initial OD at t=0

Returns:

OD values at each t point

growthcurves.models.phenom_gompertz_modified_model(t, A, mu_max, lam, alpha, t_shift, N0)[source]#

Phenomenological modified Gompertz model with decay term.

ln(Nt/N0) = A * exp(-exp(μ_max * e * (λ - t) / A + 1)) + A * exp(α * (t - t_shift))

Parameters:
  • t – Time array

  • A – Maximum ln(OD/OD0) (amplitude)

  • mu_max – Maximum specific growth rate (h^-1)

  • lam – Lag t (hours)

  • alpha – Decay rate (h^-1)

  • t_shift – Time shift for decay (hours)

  • N0 – Initial OD at t=0

Returns:

OD values at each t point

growthcurves.models.phenom_logistic_model(t, A, mu_max, lam, N0)[source]#

Phenomenological logistic model in ln-space.

ln(Nt/N0) = A / (1 + exp(4 * μ_max * (λ - t) / A + 2))

Parameters:
  • t – Time array

  • A – Maximum ln(OD/OD0) (amplitude)

  • mu_max – Maximum specific growth rate (h^-1)

  • lam – Lag time (hours)

  • N0 – Initial OD at t=0

Returns:

OD values at each time point

growthcurves.models.phenom_richards_model(t, A, mu_max, lam, nu, N0)[source]#

Phenomenological Richards model in ln-space.

ln(Nt/N0)= A * (1 + ν * exp(1 + ν + μ_max * (1 + ν)^(1 + 1/ν) * (λ - t) / A))^(-1/ν)

Parameters:
  • t – Time array

  • A – Maximum ln(OD/OD0) (amplitude)

  • mu_max – Maximum specific growth rate (h^-1)

  • lam – Lag t (hours)

  • nu – Shape parameter

  • N0 – Initial OD at t=0

Returns:

OD values at each t point

growthcurves.models.spline_from_params(params)[source]#

Reconstruct a spline from stored parameters.

Parameters:

params – Dict containing ‘t_knots’, ‘spline_coeffs’, and ‘spline_k’

Returns:

UnivariateSpline or BSpline instance.

growthcurves.models.spline_model(t, N, spline_s=None, k=3)[source]#

Fit a smoothing spline to N.

Parameters:
  • t – Time array

  • N – Values array (e.g., log-transformed OD)

  • spline_s – Smoothing factor (None = automatic)

  • k – Spline degree (default: 3)

Returns:

Tuple of (spline, spline_s) where spline is a UnivariateSpline instance.