This module provides background extraction functions and smoothing functions. These functions are extracted from PyMca module SpecFitFuns.
- strip()
- snip1d()
- snip2d()
- snip3d()
- savitsky_golay()
- smooth1d()
- smooth2d()
- smooth3d()
Simple smoothing for 1D data.
For a data array \(y\) of length \(n\), the smoothed array \(ys\) is calculated as a weighted average of neighboring samples:
\(ys_0 = 0.75 y_0 + 0.25 y_1\)
\(ys_i = 0.25 (y_{i-1} + 2 y_i + y_{i+1})\) for \(0 < i < n-1\)
\(ys_{n-1} = 0.25 y_{n-2} + 0.75 y_{n-1}\)
Parameters: | data (numpy.ndarray) – 1D data array |
---|---|
Returns: | Smoothed data |
Return type: | numpy.ndarray(dtype=numpy.float64) |
Simple smoothing for 2D data: smooth1d() is applied succesively along both axis
Parameters: | data (numpy.ndarray) – 2D data array |
---|---|
Returns: | Smoothed data |
Return type: | numpy.ndarray(dtype=numpy.float64) |
Simple smoothing for 3D data: smooth2d() is applied on each 2D slice of the data volume along all 3 axis
Parameters: | data (numpy.ndarray) – 2D data array |
---|---|
Returns: | Smoothed data |
Return type: | numpy.ndarray(dtype=numpy.float64) |
Smooth a curve using a Savitsky-Golay filter.
Parameters: |
|
---|---|
Returns: | Smoothed data |
Estimate the baseline (background) of a 1D data vector by clipping peaks.
Implementation of the algorithm SNIP in 1D is described in Miroslav Morhac et al. Nucl. Instruments and Methods in Physics Research A401 (1997) 113-132.
The original idea for 1D and the low-statistics-digital-filter (lsdf) come from C.G. Ryan et al. Nucl. Instruments and Methods in Physics Research B34 (1988) 396-402.
Parameters: |
|
---|---|
Returns: | Baseline of the input array, as an array of the same shape. |
Return type: | numpy.ndarray |
Estimate the baseline (background) of a 2D data signal by clipping peaks.
Implementation of the algorithm SNIP in 2D described in Miroslav Morhac et al. Nucl. Instruments and Methods in Physics Research A401 (1997) 113-132.
Parameters: |
|
---|---|
Returns: | Baseline of the input array, as an array of the same shape. |
Return type: | numpy.ndarray |
Estimate the baseline (background) of a 3D data signal by clipping peaks.
Implementation of the algorithm SNIP in 2D described in Miroslav Morhac et al. Nucl. Instruments and Methods in Physics Research A401 (1997) 113-132.
Parameters: |
|
---|---|
Returns: | Baseline of the input array, as an array of the same shape. |
Return type: | numpy.ndarray |
Extract background from data using the strip algorithm, as explained at http://pymca.sourceforge.net/stripbackground.html.
In its simplest implementation it is just as an iterative procedure depending on two parameters. These parameters are the strip background width w, and the number of iterations. At each iteration, if the contents of channel i, y(i), is above the average of the contents of the channels at w channels of distance, y(i-w) and y(i+w), y(i) is replaced by the average. At the end of the process we are left with something that resembles a spectrum in which the peaks have been stripped.
Parameters: |
|
---|---|
Returns: | Data with peaks stripped away |