smooth_gaussian¶
Smooth a spectrum by convolution with a Gaussian kernel.
| Category | Smoothing |
| Backend | scipy - implemented here on top of scipy primitives |
| Version | 2.0.0 |
| Reads | ctx.spectrum (a Spectrum1D) |
| Writes | spectrum |
Non-finite samples (NaN/inf) are bridged by linear interpolation over the finite neighbours before the convolution, so a single bad pixel no longer spreads NaN across the kernel footprint ; the original non-finite positions are restored to NaN in the output (finite inputs are processed bit-identically to v1.0.0). v2.0.0 — uncertainty propagation : when the input carries an uncertainty, σ_out,i = sqrt(Σ_k w_k² σ_{i+k}²) with the very kernel the filter applies (normalised Gaussian truncated at 4σ) ; for white noise of σ and sigma = 2 px this gives σ_out ≈ 0.376 σ (≈ σ / sqrt(2 σ_px √π)) in the interior. Within int(4σ + 0.5) samples of either end the filter's 'nearest' padding replicates the end sample, so the kernel taps falling off the array add before squaring — the propagation reproduces the filter's exact linear operator there too, and the edge σ_out is larger (0.641 σ at the very first sample for sigma = 2). Bridged (non-finite) samples contribute no variance and get a NaN uncertainty. The correlation the kernel introduces between neighbouring output samples is NOT tracked — χ² fits on a smoothed spectrum under-estimate their parameter errors. Without an input uncertainty the brick is unchanged from v1.0.1.
Parameters¶
| Parameter | Default | Required | Description |
|---|---|---|---|
sigma |
2.0 |
- | Standard deviation of the Gaussian kernel, in samples. |
Use it¶
References¶
- scipy.ndimage.gaussian_filter1d
- Bevington & Robinson 2003, Data Reduction and Error Analysis for the Physical Sciences, 3rd ed., McGraw-Hill — §3.2, error propagation through a linear combination (σ_out² = Σ w_k² σ_k²).
Related algorithms¶
compare_smoothings- Run every smoothing kernel onctx.spectrumand collect the results.smooth_savgol- Smooth a spectrum with a Savitzky-Golay filter.