Utilities and I/O
These helpers are part of the public surface for loading data, combining series, and propagating uncertainties.
Data loading helpers
- labfit.io.load_csv(path, x_col='x', y_col='y', y_err_col=None, *, default_fraction: float = 0.05, error_mode: str = 'auto', label: str = '') DataSeries[source]
- labfit.io.load_txt(path, x_col='x', y_col='y', y_err_col=None, *, default_fraction: float = 0.05, error_mode: str = 'auto', label: str = '') DataSeries[source]
- labfit.io.combine_series(*series: DataSeries | Dataset | Iterable[DataSeries]) Dataset[source]
Uncertainty helpers
- labfit.utils.propagate_errors(func: Callable, jacobian=None, covariance=None, **params)[source]
Propagate parameter uncertainties through a function.
Given a function
funcand its parameters with associated uncertainties, compute the output value and its propagated uncertainty using the standard first-order (linear) formula:\[\sigma_y = \sqrt{\mathbf{J} \, \Sigma \, \mathbf{J}^T}\]where \(\mathbf{J}\) is the Jacobian of func with respect to the parameters and \(\Sigma\) is their covariance matrix.
- Parameters:
func (callable) – The function to evaluate. Called as
func(**value_params)wherevalue_paramsexcludes any<name>_error/<name>_sigmakeywords.jacobian (callable, optional) – Function returning the partial derivatives of func with respect to each parameter, called as
jacobian(**value_params). If omitted, a central-difference numerical Jacobian is used (requirescovarianceto be provided).covariance (array-like, optional) – Full covariance matrix of the parameters. If omitted, a diagonal covariance is constructed from
<name>_erroror<name>_sigmakeywords passed as**params.**params – Parameter values and their uncertainties. For each parameter
x, passx=...and optionallyx_error=...orx_sigma=....
- Returns:
(value, uncertainty) – The function output and its propagated 1-σ uncertainty.
- Return type:
tuple of float
- Raises:
ValueError – If
jacobianis None andcovarianceis None (cannot compute a numerical Jacobian without knowing the parameter count).