What’s New in Revision 0.12.5
These are the changes in SpectroChemPy-0.12.5. See Release notes for a full changelog, including other versions of SpectroChemPy.
New Features
Add
scp.migrate_legacy_file()for explicit migration of legacy SCP/PSCP files to the saferaw-base64format. Legacy files with pickle-based payloads can be converted safely with an explicit trust acknowledgement (allow_unsafe_legacy=True). The source file is never modified or deleted.Add
seedparameter toscp.random()andscp.normal(). The parameter is forwarded tonumpy.random.default_rng, making it possible to obtain reproducible random numbers in scripts and gallery examples.
Bug Fixes
Fix FFT frequency-coordinate generation (PR #1563). FTIR interferogram FFT results now use a positive descending wavenumber axis from the highest retained
rfftbin toward zero, so the documented400–4000 cm^-1window again contains the calculated spectra. Generic FFT coordinates now follow thefftshift(fftfreq)order used by the transformed data, while NMR plugin FFT post-processing remains unchanged.Consolidate Sphinx-Gallery structure and rendering (PR #1564, PR #1565). Plugin examples are now staged once in canonical scientific sections, thumbnail directives are placed before module docstrings to avoid empty cells, and stale top-level plugin examples were removed.
Fix
MSCTransformer.inverse_transform()so it no longer reuses fit-dataset diagnostic coefficients positionally for independently transformed datasets.MSCTransformernow documentsa_andb_as fit-dataset diagnostics, preserves explicit masked references, computes MSC regressions from the effective paired masks, and reuses the learned reference only with compatible spectral geometry, including feature count, spectral dimension name, coordinate order and coordinate units when present.Fix sample-local preprocessing transformers so
SNVTransformerandNormalizeTransformer(dim="x")compute per-spectrum statistics on the dataset being transformed instead of reusing training spectra positionally. Theirinverse_transform()now raises an explicit error for these sample-local modes because the required per-observation factors are not learned reusable state. This is an intentional behavior break from the previous unsafe inverse, which could only work by reusing training or last-transform state positionally.Fix
dimkeyword argument in Savitzky-Golay, smoothing and Whittaker filters (#1091).savgol(),smooth(),whittaker()andFilter(...).transform()now accept adimparameter to select the processing axis. Dimension names (e.g."x") and integer indices are resolved via the standard dimension selection mechanism. Invalid types (bool,tuple,list) and unknown names raiseTypeErrororValueError.Savitzky-Golay derivatives now automatically use the signed spacing of a uniformly spaced coordinate when
deltais omitted (#1091). Forderiv > 0, thesavgol()wrapper detects the coordinate along the processed axis and derives a signed delta. An ascending coordinate yields a positive delta, a descending one yields a negative delta. The derivative sign therefore conforms to the physical variable carried by the coordinate without relying on the unit-based_reversedheuristic. An explicitdeltahas priority and disables auto-detection. On a non-uniform or missing coordinate a warning is emitted and the index-baseddelta=1.0is used as a fallback.deriv=0is unchanged.Fix sign of Savitzky-Golay derivatives when an explicit
deltais provided withcm⁻¹orppmcoordinates (#1552). The former_reversedcorrection applied(-1)**derivon the Savitzky-Golay path when the coordinate carriedcm⁻¹orppmunits, flipping the sign of odd-order derivatives on ascending coordinates. An explicitdeltais now passed to SciPy with its sign; no unit-based correction is applied. For a descending coordinate, supply a negativedeltaif the derivative should follow the physical axis. This is a numeric correction for affected calls with odd-order derivatives.Savitzky-Golay derivative units are now propagated for physically scaled paths. A derivative of order
ncarriessource_units / coordinate_units**nwhen the delta is derived from a uniform coordinate or explicitly provided while the coordinate has units. Smoothing (deriv=0) and index-based fallbacks preserve the source units unchanged. This is a scientific correction observable for datasets with physical units.
Breaking Changes
MSCTransformer.inverse_transform()now raises an explicit error. The previous behavior could appear to restore the result offit_transform()on the same dataset, but it reused training coefficients positionally and was unsafe for datasets transformed later.Migration: if you need to reverse MSC, apply the stored
a_andb_coefficients manually or refit on the target dataset. Most workflows only need the forward-corrected spectra and do not require an inverse.msc()andMSCTransformernow raise when a spectrum has zero local slope relative to the reference. The previousb_safefallback produced a zero-valued corrected spectrum, hiding an invalid MSC regression.Migration: verify that reference and sample spectra contain spectral variation (non-constant values) before calling
msc(). Constant or degenerate spectra are invalid MSC inputs.