plesty.fss.line_fit =================== .. py:module:: plesty.fss.line_fit .. autoapi-nested-parse:: Finding and fitting the lines of one spectrum, for :class:`plesty.fss.tracking.LineTracker`. Both steps are the analysis's own: lines are found with :meth:`~plesty.lib.data.SpectrumData.find_peaks` and fitted with :class:`~plesty.lib.analyzer.SpectrumFit`, so a line the tracker follows during a sweep is found and fitted as the analysis does after it. Functions --------- .. autoapisummary:: plesty.fss.line_fit.saved_fit plesty.fss.line_fit.check_fit_options plesty.fss.line_fit.find_lines plesty.fss.line_fit.fit_line_positions Module Contents --------------- .. py:function:: saved_fit(path: Any) -> Any Load the line fit an analysis saved, given the path of its document. Here rather than beside the tracker because this module is where a line fit is produced, and a fit read back is the same thing arriving another way — the tracker itself reaches for nothing outside this package. :param path: The document's path. :returns: The analyzer's ``fit`` output. :raises Exception: Whatever reading it raises — a document still being written, or one from a version that saved a different shape. .. py:function:: check_fit_options(fit_options: Mapping[str, Any]) -> None Refuse fit options :class:`~plesty.lib.analyzer.SpectrumFit` would refuse. :raises ValueError: If an option is invalid. .. py:function:: find_lines(wavelength: numpy.ndarray, reference: numpy.ndarray, prominence: Optional[float], distance: int) -> numpy.ndarray Return the positions of the lines in *reference*, shortest wavelength first. :param wavelength: The axis, in nm. :param reference: The spectrum to search, e.g. the median of the spectra so far. :param prominence: Minimum height of a line above its surroundings, in counts. :param distance: Minimum separation of two lines, in pixels. .. py:function:: fit_line_positions(wavelength: numpy.ndarray, counts: numpy.ndarray, seeds: numpy.ndarray, fit_options: Mapping[str, Any]) -> numpy.ndarray Fit the lines of one spectrum, starting from *seeds*, and return their positions. Fit-quality warnings are not raised: one spectrum at a time says little, and the analysis reports them for the whole sweep. :param wavelength: The axis, in nm. :param counts: The spectrum. :param seeds: Starting position of each line, in nm. :param fit_options: :class:`~plesty.lib.analyzer.SpectrumFit` options other than ``peaks``. :returns: The fitted position of each line, ``nan`` for all when the fit fails. :raises ImportError: If the fitting extra is not installed. A spectrum that cannot be fitted is ordinary and becomes ``nan``; an environment that cannot fit *anything* is not, and swallowing it means every line of every spectrum silently reads as unfittable — a viewer drawing no markers at all, with nothing to say why.