|
DP3
|
Smooths a series of possibly irregularly gridded values by a given kernel. More...
#include <KernelSmoother.h>
Public Types | |
| enum | KernelType { RectangularKernel , TriangularKernel , GaussianKernel , EpanechnikovKernel } |
Public Member Functions | |
| KernelSmoother (const std::vector< NumType > &frequencies, KernelType kernelType, NumType kernelBandwidth, NumType bandwidthRefFrequency, NumType spectralExponent, bool kernel_truncation) | |
| NumType | Kernel (NumType distance) const |
| void | Smooth (DataType *data, const NumType *weight, NumType kernelSizeFactor) |
Smooths a series of possibly irregularly gridded values by a given kernel.
The class is optimized to smooth many series which are all placed on the same grid. This is the case when smoothing the solutions on a (a possibly irregular) channel grid.
This class uses internally stored scratch space, and is therefore not thread safe. To smooth with multiple threads, instantiate a KernelSmoother for each thread.
| enum dp3::ddecal::KernelSmoother::KernelType |
|
inline |
Construct and initialize kernel smoother. With se the spectralExponent, s the kernelBandwidth, nu the frequency at which to evaluate the kernel the kernel size is calculated as: s(nu) = (nu_0 / nu) ^ se
| frequencies | Vector defining the channel frequencies: frequencies[i] specifies the frequency of channel i in Hz. The size of this vector (number of channels) defines the size of the grid n. |
| kernelType | Type of kernel to use for smoothing |
| kernelBandwidth | Size of the kernel (smoothing strength) in frequency units (Hz). May be 0.0 to disable frequency correction of the kernel size. |
| bandwidthRefFrequency | If non-zero, sets the frequency value at which the kernel size equals the specified size with kernelBandwidth. |
| spectralExponent | A value that specifies the exponent in the relative spectral factor of the kernel size. |
|
inline |
Evaluate the kernel for a given position.
| distance | Distance (positive or negative) from centre of the kernel to evaluate the kernel for, in units of frequency (Hz). |
e^(-x^2 / sigma^2), sigma = bandwidth / 3.
3/4 * (1-x)^2;
|
inline |
Replaces the data with a smoothed version of the data.
| data | Data array of size n (as specified in constructor) that is smoothed on output. |
| weight | Associated weights, array of size n. |
| kernelSizeFactor | A factor that is applied to the frequency axis, such that a larger factors causes less smoothing. |
find right-most kernel value corresponding to the first element of data
If a boundary is further than half the bandwidth away, move boundary
A value of 1 is added to make sure we are not skipping a value because of rounding errors (kernel will correctly evaluate past boundaries, so including an unnecessary value has no effect)