User-adjustable initial guesses for decay and peak fits (v0.1.4) - #63
Merged
Conversation
fit_exp_decay (and fit_decay_irf) gain tau0/amplitude0/offset0/beta0 keyword overrides: guesses are still estimated from the data, and any user-supplied value replaces the corresponding automatic one. Scalars for n_exp = 1; for n_exp > 1 a vector whose entries are numbers or nothing (nothing = keep the automatic guess for that component). tau0 must be positive, beta0 in (0, 1] and stretched-only. fit_peaks' automatic guess construction is exposed as the public initial_peak_guesses(x, y; ...) -> (p0, n_peaks, peak_params, baseline_order), and fit_peaks now builds its automatic p0 through it, so a GUI can show the exact vector, let the user edit slots, and pass it back via the existing p0 keyword. Bump to 0.1.4. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Degenerate input (empty, <5 points, mismatched lengths) now throws ArgumentError instead of surfacing a reduce-over-empty error from the peak-detection internals — callers that map ArgumentError to a client error (QPSLab's guess endpoint) rely on this. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds user-adjustable initial guesses to the fitting API, the upstream half of QPSLab's "adjust p0 for fits" feature (the GUI lets a user type per-parameter seeds when the automatic guess converges badly).
fit_exp_decay / fit_decay_irf
New keywords
tau0,amplitude0,offset0,beta0. Semantics: automatic guesses are computed exactly as before, then any user-supplied value replaces the corresponding automatic one.n_exp = 1: numbers.n_exp > 1: vectors of lengthn_expwhose entries are numbers ornothing(nothing= keep the automatic guess for that component), e.g.tau0 = [nothing, 50.0].tau0entries must be positive and finite;beta0in(0, 1]and only withmodel = :stretched; wrong-length vectors throwArgumentError.initial_peak_guesses (new export)
initial_peak_guesses(x, y; model, n_peaks, peaks, baseline_order, min_prominence)returns(p0, n_peaks, peak_params, baseline_order)— the exact automatic parameter vectorfit_peakswould use, without fitting.fit_peaksnow builds its automaticp0through this function, so the two cannot drift. A GUI shows the vector in editable fields and passes the edited copy back viafit_peaks' existingp0keyword.Tests / docs
Full suite passes (1932/1932): new testsets cover override convergence on every model path, partial overrides,
nothing-entry vectors, all validation errors, and guess↔fit round-tripping. Docstrings updated;initial_peak_guessesadded to the peak-fitting reference page.Version bumped to 0.1.4. After merge this should be registered (QPSLab's companion branch requires
OpticalSpectroscopy = "0.1.4").🤖 Generated with Claude Code