diff --git a/src/ParamOutputImpl/Plot/InstantPlot/PlotFunction.cc b/src/ParamOutputImpl/Plot/InstantPlot/PlotFunction.cc index a68f5eb..4fe866e 100644 --- a/src/ParamOutputImpl/Plot/InstantPlot/PlotFunction.cc +++ b/src/ParamOutputImpl/Plot/InstantPlot/PlotFunction.cc @@ -165,6 +165,7 @@ namespace plot { minValue = pow10(minValue); maxValue = pow10(maxValue); + lAxisRange._extend = false; } lAxisRange.setMin(minValue); @@ -179,6 +180,7 @@ namespace plot { minValue = pow10(minValue); maxValue = pow10(maxValue); + lAxisRange._extend = false; } lAxisRange.setMin(minValue); lAxisRange.setMax(maxValue); @@ -419,12 +421,16 @@ namespace plot AMDA::Parameters::ParameterSPtr originalParam = _parameterManager.getParameter(paramOriginID); const double timeSampling = originalParam->getDataWriterTemplate()->getMinSampling(); + LOG4CXX_DEBUG(gLogger, "Fourier:: Signal Size = " << yValues.size()); + DiscreteFourierTransform DFT(yValues, timeSampling); const bool computeFFT = (function == PlotFunction::Function::FFT); DFT.compute(computeFFT); std::vector> phasors = DFT.getPhasors(); yValues = DFT.computeDSP(phasors); + if (computeFFT) + LOG4CXX_DEBUG(gLogger, "FFT Next Power of 2 = " << yValues.size() << " " << DFT.highestPowerof2(8211)); if (abscisse.getType() == Abscisse::Abscisse_Type::FREQUENCY) xValues = DFT.getFreq(phasors, 1.0 / timeSampling); // DFT.getFrequences(); @@ -432,10 +438,7 @@ namespace plot xValues = DFT.getPeriods(phasors, 1.0 / timeSampling); // DFT.getFrequences(); } - if (ordonneeScale == Axis::Scale::LOGARITHMIC) - PlotFunction::applyScale(yValues); - if (abscisseScale == Axis::Scale::LOGARITHMIC) - PlotFunction::applyScale(xValues); + PlotFunction::applyScale(xValues, yValues); std::string id = ""; if (pSerie != nullptr) @@ -451,20 +454,31 @@ namespace plot PlotFunction::yValuesMap[id] = yValues; } - void PlotFunction::applyScale(std::vector &vect) + void PlotFunction::applyScale(std::vector &vectX, std::vector &vectY) { - for (std::size_t i = 0; i < vect.size(); i++) + std::vector xtemp; + std::vector ytemp; + for (std::size_t i = 0; i < vectX.size(); i++) { - if (vect[i] <= 0) + if ((vectX[i] <= 0 && abscisseScale == Axis::Scale::LOGARITHMIC) || + (vectY[i] <= 0 && ordonneeScale == Axis::Scale::LOGARITHMIC)) { - vect[i] = log10(10e-20); LOG4CXX_WARN(gLogger, "Negative value found, no log calculated"); } else { - vect[i] = log10(vect[i]); + if (abscisseScale == Axis::Scale::LOGARITHMIC) + xtemp.push_back(log10(vectX[i])); + else + xtemp.push_back(vectX[i]); + if (ordonneeScale == Axis::Scale::LOGARITHMIC) + ytemp.push_back(log10(vectY[i])); + else + ytemp.push_back(vectY[i]); } } + vectX = xtemp; + vectY = ytemp; } void PlotFunction::drawStartDate(std::string _timeFormat, double startTime, double stopTime) diff --git a/src/ParamOutputImpl/Plot/InstantPlot/PlotFunction.hh b/src/ParamOutputImpl/Plot/InstantPlot/PlotFunction.hh index 2d66b4d..7385469 100644 --- a/src/ParamOutputImpl/Plot/InstantPlot/PlotFunction.hh +++ b/src/ParamOutputImpl/Plot/InstantPlot/PlotFunction.hh @@ -190,7 +190,7 @@ namespace plot * * @param vect vector of data */ - void applyScale(std::vector &vect); + void applyScale(std::vector &vectX, std::vector &vectY); /** * @brief Get the Min Max de xValuesMap et yValuesMap * diff --git a/src/Parameters/fonctions/fourier/DiscreteFourierTransform.cc b/src/Parameters/fonctions/fourier/DiscreteFourierTransform.cc index 011cb02..792cb63 100644 --- a/src/Parameters/fonctions/fourier/DiscreteFourierTransform.cc +++ b/src/Parameters/fonctions/fourier/DiscreteFourierTransform.cc @@ -116,7 +116,7 @@ std::vector DiscreteFourierTransform::computeDSP(std::vector out; - for (int k = 0; k < N / 2; k++) + for (int k = 1; k < N / 2; k++) { const E magnitude = (E)pow(abs(x[k]), 2); const E dsp = (E)(1.0 / N) * magnitude; @@ -131,7 +131,7 @@ std::vector DiscreteFourierTransform::getFreq(std::vector out; - for (int k = 0; k < N / 2; k++) + for (int k = 1; k < N / 2; k++) { const E freq = (E)k * frequency_ / N; out.push_back(freq); @@ -145,11 +145,9 @@ std::vector DiscreteFourierTransform::getPeriods(std::vector out; - for (int k = 0; k < N / 2; k++) + for (int k = 1; k < N / 2; k++) { - E period = (E)INT_MAX; - if (k != 0) - period = N / ((E)k * frequency_); + const E period = N / ((E)k * frequency_); out.push_back(period); } -- libgit2 0.21.2