1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

first version of prabolic freq estimation

This commit is contained in:
Manuel Pitz 2021-06-16 14:00:52 +00:00
parent 806b5ad17a
commit afe88fcf45

View file

@ -779,6 +779,15 @@ public:
{
assert(state == State::PARSED);
if (!freqEstimateTypeC) {
logger->info("No Frequency estimation type given, assume no none");
freqEstType = FreqEstimationType::NONE;
}
else if (strcmp(freqEstimateTypeC, "quadratic") == 0)
freqEstType = FreqEstimationType::QUADRATIC;
if (endFreqency < 0 || endFreqency > sampleRate)
throw RuntimeError("End frequency must be smaller than sampleRate {}", sampleRate);
@ -1142,6 +1151,48 @@ static HookPlugin<DftHook, n, d, (int) Hook::Flags::NODE_READ | (int) Hook::Flag
return { y_Fmax, i };
}
/**
* This function is calculating the mximum based on a quadratic interpolation
*
* This function is based on the following paper:
* https://mgasior.web.cern.ch/pap/biw2004.pdf
*
* In particular equation 10
*
*/
Point quadraticEstimation(double x1, double x2, double x3, double y1, double y2, double y3, unsigned maxFBin)
{
//double y_max = x2 - (y3 - y1) / (2 * ( 2 * y2 - y1 - y3));
double y_Fmax = 0;
/*Quadratic Method */
double maxBinEst = ((y3 - y1) / ( 2 * ( 2 * y2 - y1 - y3)));
logger->info("y3 - y1 {} ; y_max : {}", (y3 - y1), maxBinEst);
maxBinEst = (double)maxFBin + maxBinEst;
/*Jains Method
if (y1 > y3)
{
y_max = (double)maxFBin - 1 + (((y2 / y1) / ( 1 + (y2/y1))));
}
else
{
y_max = (double)maxFBin + ((y3 / y2) / ( 1 + (y3 / y2)));
}*/
y_Fmax = startFreqency + maxBinEst * frequencyResolution;
Point ret = {y_Fmax, 0};
return ret;
}
};
/* Register hook */