DP3
Public Member Functions | Static Public Member Functions | List of all members
dp3::ddecal::PieceWisePhaseFitter Class Reference

#include <PieceWisePhaseFitter.h>

Public Member Functions

 PieceWisePhaseFitter ()
 
 PieceWisePhaseFitter (size_t chunkSize)
 
size_t BreakPoint (const double *data, const double *weights, const double *fittedData, size_t n)
 
size_t ChunkSize () const
 
void PieceWiseFit (const std::vector< double > &nu, const std::vector< double > &data, const double *weights, std::vector< double > &fittedData)
 
void PieceWiseFit (const std::vector< double > &nu, const std::vector< double > &data, std::vector< double > &fittedData)
 
void SetChunkSize (size_t chunkSize)
 
void SlidingFit (const double *nu, const double *data, const double *weights, double *fittedData, size_t n)
 
void SlidingFit (const double *nu, const double *data, double *fittedData, size_t n)
 
size_t SlidingFitWithBreak (const double *nu, const double *data, const double *weights, double *fittedData, size_t n)
 

Static Public Member Functions

static size_t CalculateChunkSize (const std::vector< double > &frequencies)
 
template<typename Iter >
static void Unwrap (Iter first, Iter last)
 
static double WeightedMedian (std::vector< std::pair< double, double >> &values)
 

Constructor & Destructor Documentation

◆ PieceWisePhaseFitter() [1/2]

dp3::ddecal::PieceWisePhaseFitter::PieceWisePhaseFitter ( )
inline

◆ PieceWisePhaseFitter() [2/2]

dp3::ddecal::PieceWisePhaseFitter::PieceWisePhaseFitter ( size_t  chunkSize)
inline

Constructor.

Parameters
chunkSizeSize of chunk in number of samples.

Member Function Documentation

◆ BreakPoint()

size_t dp3::ddecal::PieceWisePhaseFitter::BreakPoint ( const double *  data,
const double *  weights,
const double *  fittedData,
size_t  n 
)
inline

◆ CalculateChunkSize()

static size_t dp3::ddecal::PieceWisePhaseFitter::CalculateChunkSize ( const std::vector< double > &  frequencies)
inlinestatic

it seems that 10 chunks per octave seems reasonable

◆ ChunkSize()

size_t dp3::ddecal::PieceWisePhaseFitter::ChunkSize ( ) const
inline

◆ PieceWiseFit() [1/2]

void dp3::ddecal::PieceWisePhaseFitter::PieceWiseFit ( const std::vector< double > &  nu,
const std::vector< double > &  data,
const double *  weights,
std::vector< double > &  fittedData 
)
inline

◆ PieceWiseFit() [2/2]

void dp3::ddecal::PieceWisePhaseFitter::PieceWiseFit ( const std::vector< double > &  nu,
const std::vector< double > &  data,
std::vector< double > &  fittedData 
)
inline

Perform a piece-wise fit of linear phase gradients.

The data is divided into chunks with given size, and in each chunk a line is fitted (offset & gradient). The fitted line of each chunk is written into fittedData. The resulting line will have a 'jump' between each chunk.

Parameters
nuFrequencies of the channels (in Hz).
dataThe values, same size as nu.
fittedDataA vector of at least size nu.size(), in which the fitted lines are stored.

◆ SetChunkSize()

void dp3::ddecal::PieceWisePhaseFitter::SetChunkSize ( size_t  chunkSize)
inline

◆ SlidingFit() [1/2]

void dp3::ddecal::PieceWisePhaseFitter::SlidingFit ( const double *  nu,
const double *  data,
const double *  weights,
double *  fittedData,
size_t  n 
)
inline

Performs a sliding fit of linear phase gradients (with weighting).

A window of size chunkSize is slid over the data, and a line is fitted at each position. The values near the left and right side of the border are evaluated with the fit to the most left/right window. This is slower than PieceWiseFit(), but it produces a smoother & more accurate fit. The fit is not necessarily entirely smooth, because the line fit tries to guess the right wrapping of the samples. Since that is not a linear process, this can still cause slight jumps.

Parameters
nuFrequencies of the channels (in Hz).
dataThe values, same size as nu.
weightsInverse-variance weights.
fittedDataA vector of at least size nu.size(), in which the fitted lines are stored.

◆ SlidingFit() [2/2]

void dp3::ddecal::PieceWisePhaseFitter::SlidingFit ( const double *  nu,
const double *  data,
double *  fittedData,
size_t  n 
)
inline

Performs a sliding fit of linear phase gradients (without weighting). See other SlidingFit() overload.

◆ SlidingFitWithBreak()

size_t dp3::ddecal::PieceWisePhaseFitter::SlidingFitWithBreak ( const double *  nu,
const double *  data,
const double *  weights,
double *  fittedData,
size_t  n 
)
inline

◆ Unwrap()

template<typename Iter >
static void dp3::ddecal::PieceWisePhaseFitter::Unwrap ( Iter  first,
Iter  last 
)
inlinestatic

Unwrap a range of phase values.

◆ WeightedMedian()

static double dp3::ddecal::PieceWisePhaseFitter::WeightedMedian ( std::vector< std::pair< double, double >> &  values)
inlinestatic

Calculates a weighted median. The weighted median is defined as the sample x for which the sum of all values smaller than x is less than half of the total weight, and idem for all values larger than x. For example, given the sequence 1,2,3,4,5 with weights 1,100,1,1,1; the weighted median is '2'. (sum of weight=104, values < 2 a have weight of 1, values > 2 have a weight of 3). This function is internally used by the piece-wise phase fitter.

Parameters
valuesA vector of (value, weight) pairs.
Returns
The weighted median.

calculate total weight

prefixSum is the weight sum of everything after index


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