DP3
Public Types | Public Member Functions | List of all members
dp3::ddecal::KernelSmoother< DataType, NumType > Class Template Reference

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)
 

Detailed Description

template<typename DataType, typename NumType>
class dp3::ddecal::KernelSmoother< DataType, NumType >

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.

Member Enumeration Documentation

◆ KernelType

template<typename DataType , typename NumType >
enum dp3::ddecal::KernelSmoother::KernelType
Enumerator
RectangularKernel 
TriangularKernel 
GaussianKernel 

Gaussian, trimmed off at 3 sigma

EpanechnikovKernel 

The Epanechnikov kernel is a quadratic kernel, given by 3/4 (1 - x^2)

Constructor & Destructor Documentation

◆ KernelSmoother()

template<typename DataType , typename NumType >
dp3::ddecal::KernelSmoother< DataType, NumType >::KernelSmoother ( const std::vector< NumType > &  frequencies,
KernelType  kernelType,
NumType  kernelBandwidth,
NumType  bandwidthRefFrequency,
NumType  spectralExponent,
bool  kernel_truncation 
)
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

Parameters
frequenciesVector 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.
kernelTypeType of kernel to use for smoothing
kernelBandwidthSize of the kernel (smoothing strength) in frequency units (Hz). May be 0.0 to disable frequency correction of the kernel size.
bandwidthRefFrequencyIf non-zero, sets the frequency value at which the kernel size equals the specified size with kernelBandwidth.
spectralExponentA value that specifies the exponent in the relative spectral factor of the kernel size.

Member Function Documentation

◆ Kernel()

template<typename DataType , typename NumType >
NumType dp3::ddecal::KernelSmoother< DataType, NumType >::Kernel ( NumType  distance) const
inline

Evaluate the kernel for a given position.

Parameters
distanceDistance (positive or negative) from centre of the kernel to evaluate the kernel for, in units of frequency (Hz).
Returns
Unnormalized kernel value (i.e., integral of kernel is not necessarily unity).

e^(-x^2 / sigma^2), sigma = bandwidth / 3.

3/4 * (1-x)^2;

◆ Smooth()

template<typename DataType , typename NumType >
void dp3::ddecal::KernelSmoother< DataType, NumType >::Smooth ( DataType *  data,
const NumType *  weight,
NumType  kernelSizeFactor 
)
inline

Replaces the data with a smoothed version of the data.

Parameters
dataData array of size n (as specified in constructor) that is smoothed on output.
weightAssociated weights, array of size n.
kernelSizeFactorA 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)


The documentation for this class was generated from the following file: