-
Notifications
You must be signed in to change notification settings - Fork 0
Peak detection
⚙️ Generated page — do not edit here. Source:
docs/peak_detection.md. Edit it in the repository and the wiki rebuilds itself.
Module: gui/minima_analysis.py · Class: MinimaAnalysisMixin
GUI action: Fit → Initialize from minima
Before fitting, the user needs a reasonable starting point for the parameters of each component. Automatic peak detection locates the absorption peaks in the spectrum (transmission minima) and converts them into initial parameters for sextets, doublets and singlets. The algorithm combines multi-scale CWT detection and a direct channel to be robust against:
- sextets with overlapping lines or variable linewidths;
- narrow doublets that large-scale CWT might merge into a single peak;
- spectra with high noise or a sloped baseline.
The net absorption is computed as:
where
The thresholds are:
with factors core/param_overrides.py (table _PD).
The continuous wavelet transform (CWT) with the Ricker (Mexican hat) wavelet:
is applied to
Implementation with np.convolve (replaces scipy.signal.cwt removed in SciPy 1.12):
the kernel is convolved with the signal in "same" mode. To prevent the kernel from
exceeding the signal length (which would cause a ValueError due to the mode="same"
semantics with short signals), the kernel half-length is clamped:
The CWT ridge is the maximum across scales at each channel:
Peaks in scipy.signal.find_peaks using
the thresholds
To recover narrow doublets that large-scale CWT might merge into a single peak,
peaks are also searched in the absorption with fine smoothing (window ~0.15 mm/s,
always odd). The smoothed absorption is renormalized to the range of
The CWT indices (
- Direct peaks form the base list (they avoid the "valley peak" artifact that large-scale CWT can generate between the two lines of a doublet).
- A CWT peak is added only if it is not between two consecutive direct peaks (sign of a valley artifact) and is not a duplicate of one already present (distance ≤ 1 channel).
For each merged peak:
- If there is a positive CWT response, the scale with the highest response determines
the width:
$\Gamma \approx 2 \cdot a_\mathrm{best} \cdot \Delta v$ . - If there is no positive CWT response, the FWHM is estimated directly from the fine-smoothed signal: the 50 % crossings of the peak value are located to the left and right.
Peaks are sorted by smoothed depth (descending) and selected greedily, adding a peak
only if it is more than
Once the minima are detected, the initialization logic (on_init_from_minima)
assigns components:
-
Shape heuristic (
_depth_profile_hint): if one peak dominates in depth with position < 2.5 mm/s → Singlet; if two peaks are comparable and the separation falls in the doublet range → Doublet. -
Sextet search (
_best_sextet_from_peaks): linear fit$v_j = \delta + (B_{hf}/B_0) \cdot r_j^{(33)}$ by least squares over combinations of 5–6 peaks; accepted if RMS < threshold and BHF is physical. -
Estimation with 2 visible peaks (
_try_2peak_sextet_estimate): if only 2 peaks are present, BHF is estimated from the outer spacing (lines 1–2 or 5–6). - Remaining components: unassigned peaks form doublets (if the separation is in the physical range) or additional singlets.
Initial depths are rescaled so that the proposed model does not exceed the maximum absorption of the data.
- The CWT replaces
scipy.signal.cwt + ricker(removed in SciPy 1.12). - Kernel clamping (
half = min(max(5a,3), (N-1)//2)) corrects theValueError: could not broadcast input arraythat occurred with short signals (~254 points after edge trimming from folding). - Detection parameters (thresholds, ranges, tolerances) are configurable
in
core/param_overrides.pyvia_PD(peak detection) and_FI(fit init).
© Jorge Sánchez Marcos, Nieves Menéndez González — Departamento de Química Física, UAM · Wiki generado desde docs/ para Fitbauer v5.0.0
Fitbauer v5.0.0
Start
- Home
- Installation
- User flows Data
- Folding
- Calibration (33 T)
- Spectrum comparison Fitting
- Distribution fitting
- Peak detection
- Profile likelihood
- Batch fitting Reference
- Command-line tools
- NORMOS (.JOB)
- Session format
- Sextet model (spec)
- Architecture
Inicio
- Inicio
- Instalación
- Flujos de usuario Datos
- Plegado (folding)
- Calibración (33 T)
- Comparación de espectros Ajuste
- Distribuciones
- Detección de mínimos
- Verosimilitud perfilada
- Ajuste en serie Referencia
- Línea de comandos
- NORMOS (.JOB)
- Formato de sesión
- Modelo de sextete (spec)
- Arquitectura