Fitters utilities#
The utilities_f holds some backend functionalities for the fitter class.
Available for use#
- parameter_logic(par_array: ndarray, n_par: int, selected_models) ndarray[source]#
Extract parameter values from a given function based on the number of parameters per fit and selected indices.
- Parameters:
- par_arraynp.ndarray
A 2D array where the first column contains the parameter values and the second contains its standard errors.
- n_parint
The number of parameters per fit (e.g., amplitude, mu, sigma, etc.).
- selected_modelsint, list of int, or None
Indices of model components to extract. - If None, selects all components. - If int or list of int, selects the specified components (1-based indexing).
- Returns:
- np.ndarray
A 2D array containing the selected parameter values for the specified mean and error values for the fit.
- sanity_check(x_values: List[int | float] | ndarray, y_values: List[int | float] | ndarray) Tuple[ndarray, ndarray][source]#
Convert input lists to NumPy arrays if necessary.
- Parameters:
- x_valueslist of float or np.ndarray
Input x-values that will be converted to a NumPy array if they are in list format.
- y_valueslist of float or np.ndarray
Input y-values that will be converted to a NumPy array if they are in list format.
- Returns:
- x_valuesnp.ndarray
The x-values as a NumPy array.
- y_valuesnp.ndarray
The y-values as a NumPy array.
Internal functions#
- _plot_fit(x_values: ndarray, y_values: ndarray, parameters: ndarray, n_fits: int, class_name: str, _n_fitter: Callable, _n_plotter: Callable, show_individuals: bool = False, x_label: str | None = None, y_label: str | None = None, title: str | None = None, data_label: str | None = None, fit_label: str | None = None, axis: Axes | None = None)[source]#
Base function to plot the fitted models.
- Parameters:
- x_valuesarray-like
The x-axis values.
- y_valuesarray-like
The observed data values corresponding to x_values.
- parameterstuple or list
The optimized parameters from the fitting process.
- n_fitsint
The number of fits performed.
- class_namestr
The name of the fitting model class used.
- _n_fittercallable
A function that evaluates the fitted model given x_values and parameters.
- _n_plottercallable
A function that plots individual model components if show_individuals is True.
- show_individuals: bool, optional
Whether to show individually fitted models or not.
- x_label: str, optional
The label for the x-axis.
- y_label: str, optional
The label for the y-axis.
- title: str, optional
The title for the plot.
- data_label: str, optional
The label for the data.
- axis: Axes, optional
Axes to plot instead of the entire figure. Defaults to None.
- Returns:
- plotter
The plotter handle for the drawn plot.