DP3
Classes | Functions
dp3::common::phase_fitting Namespace Reference

Classes

struct  FitSample
 
struct  SlopeFitRange
 

Functions

double FitSlope (const std::vector< FitSample > &data)
 
double FitSlope (const std::vector< FitSample > &data, const SlopeFitRange &range)
 
SlopeFitRange GetRange (const std::vector< FitSample > &data, aocommon::OptionalNumber< int > wrap_count_limit={})
 
double SlopeModelCost (const std::vector< FitSample > &data, double slope)
 
double UnwrapAndFit (const std::vector< FitSample > &data, double unwrapping_slope)
 

Function Documentation

◆ FitSlope() [1/2]

double dp3::common::phase_fitting::FitSlope ( const std::vector< FitSample > &  data)
inline

Fits phase data to a line, accounting for phase wraps. It optimizes slope s to approximately minimize the least squares value between the data and the model function: y = ( s x ) modulo 2pi by minimizing the cost function: w_i (y_i - s * x_i)^2 This function requires the data to be sorted by x-value. The data should have finite values (even for zero-weighted data).

While searching for the right unwrapping, the function minimizes the sum of absolute values instead of least squares. This is slightly more stable. It does a brute force search of all possible wraps. Once the right unwrapping is found, the values are unwrapped and a least-squares fit of a line to the data is performed.

Because the grid of x-value does not need to be regular, this function is suitable for finding:

  • delay values by using frequency as x-value;
  • TEC values by using wavelength or 1/nu as x-value;
  • or Faraday-depth values by using wavelength^2 as x-value.

◆ FitSlope() [2/2]

double dp3::common::phase_fitting::FitSlope ( const std::vector< FitSample > &  data,
const SlopeFitRange range 
)
inline

Same as the other FitSlope() overload, but with a parameter to provide the range. If performing the same fit multiple times, the range can be calculated once for all fits.

◆ GetRange()

SlopeFitRange dp3::common::phase_fitting::GetRange ( const std::vector< FitSample > &  data,
aocommon::OptionalNumber< int >  wrap_count_limit = {} 
)
inline

Computes the range of slopes that needs to be searched through. This only uses the x values of the data parameter, and the result can thus be reused for multiple fits if the x values stay the same. This function requires the data to be sorted by x-value.

Parameters
wrap_count_limitif set, limits the number of wraps that are searched through. The number of wraps is counted from the origin up to the largest x value. If unset, the number of wraps to be searched through is calculated from the data, such that any wrapping that can be resolved, is resolved. This number can be very high for dense x-values far from zero (e.g. when fitting a slope between 150-151 MHz with 1 kHz resolution), hence for these cases it might be useful to limit the number of wraps searched through.

◆ SlopeModelCost()

double dp3::common::phase_fitting::SlopeModelCost ( const std::vector< FitSample > &  data,
double  slope 
)
inline

◆ UnwrapAndFit()

double dp3::common::phase_fitting::UnwrapAndFit ( const std::vector< FitSample > &  data,
double  unwrapping_slope 
)
inline