Fit Manager#

Fit manager for handling curve fitting operations.

This module manages fit operations for curves, handles fit parameter storage and retrieval, and coordinates between UI and fit calculations.

class mdaviz.fit_manager.FitData(model_name: str, fit_result: FitResult, x_range: Tuple[float, float] | None = None)[source]#

Container for fit data associated with a curve.

class mdaviz.fit_manager.FitManager(*args: Any, **kwargs: Any)[source]#

Manages fit operations for curves.

addFit(curveID: str, model_name: str, x_data: numpy.ndarray, y_data: numpy.ndarray, x_range: tuple[float, float] | None = None, initial_params: dict[str, float] | None = None, bounds: dict[str, tuple[float, float]] | None = None) None[source]#

Add or replace a fit for a curve.

Parameters: - curveID: ID of the curve to fit - model_name: Name of the fit model to use - x_data: X values for fitting - y_data: Y values for fitting - x_range: Optional range of x values to use for fitting - initial_params: Optional initial parameter guesses - bounds: Optional parameter bounds

Raises: - ValueError: If model_name is not available or fit fails

clearAllFits() None[source]#

Remove all fits from all curves.

fitAdded#

alias of str

fitRemoved#

alias of str

fitUpdated#

alias of str

getFitCurveData(curveID: str) Tuple[numpy.ndarray, numpy.ndarray] | None[source]#

Get the fitted curve data for plotting.

Parameters: - curveID: ID of the curve

Returns: - Tuple of (x_fit, y_fit) arrays if found, None otherwise

getFitData(curveID: str) FitData | None[source]#

Get fit data for a curve.

Parameters: - curveID: ID of the curve

Returns: - FitData object if found, None otherwise

getFitParameters(curveID: str) Dict[str, float] | None[source]#

Get fit parameters for a curve.

Parameters: - curveID: ID of the curve

Returns: - Dictionary of parameter names and values if found, None otherwise

getFitQualityMetrics(curveID: str) Dict[str, float] | None[source]#

Get fit quality metrics for a curve.

Parameters: - curveID: ID of the curve

Returns: - Dictionary of quality metrics if found, None otherwise

getFitUncertainties(curveID: str) Dict[str, float] | None[source]#

Get fit parameter uncertainties for a curve.

Parameters: - curveID: ID of the curve

Returns: - Dictionary of parameter names and uncertainties if found, None otherwise

hasFits(curveID: str) bool[source]#

Check if a curve has a fit.

Parameters: - curveID: ID of the curve

Returns: - True if curve has a fit, False otherwise

removeFit(curveID: str) None[source]#

Remove the fit from a curve.

Parameters: - curveID: ID of the curve