Commit ac7eebb012d5ccf637b218f5371ef7c305c2246d

Authored by Menouard AZIB
1 parent 9d60b18e

Ignore zero point for frequency and period

src/ParamOutputImpl/Plot/InstantPlot/PlotFunction.cc
... ... @@ -165,6 +165,7 @@ namespace plot
165 165 {
166 166 minValue = pow10(minValue);
167 167 maxValue = pow10(maxValue);
  168 + lAxisRange._extend = false;
168 169 }
169 170  
170 171 lAxisRange.setMin(minValue);
... ... @@ -179,6 +180,7 @@ namespace plot
179 180 {
180 181 minValue = pow10(minValue);
181 182 maxValue = pow10(maxValue);
  183 + lAxisRange._extend = false;
182 184 }
183 185 lAxisRange.setMin(minValue);
184 186 lAxisRange.setMax(maxValue);
... ... @@ -419,12 +421,16 @@ namespace plot
419 421 AMDA::Parameters::ParameterSPtr originalParam = _parameterManager.getParameter(paramOriginID);
420 422 const double timeSampling = originalParam->getDataWriterTemplate()->getMinSampling();
421 423  
  424 + LOG4CXX_DEBUG(gLogger, "Fourier:: Signal Size = " << yValues.size());
  425 +
422 426 DiscreteFourierTransform<double, double> DFT(yValues, timeSampling);
423 427 const bool computeFFT = (function == PlotFunction::Function::FFT);
424 428 DFT.compute(computeFFT);
425 429  
426 430 std::vector<std::complex<double>> phasors = DFT.getPhasors();
427 431 yValues = DFT.computeDSP(phasors);
  432 + if (computeFFT)
  433 + LOG4CXX_DEBUG(gLogger, "FFT Next Power of 2 = " << yValues.size() << " " << DFT.highestPowerof2(8211));
428 434  
429 435 if (abscisse.getType() == Abscisse::Abscisse_Type::FREQUENCY)
430 436 xValues = DFT.getFreq(phasors, 1.0 / timeSampling); // DFT.getFrequences();
... ... @@ -432,10 +438,7 @@ namespace plot
432 438 xValues = DFT.getPeriods(phasors, 1.0 / timeSampling); // DFT.getFrequences();
433 439 }
434 440  
435   - if (ordonneeScale == Axis::Scale::LOGARITHMIC)
436   - PlotFunction::applyScale(yValues);
437   - if (abscisseScale == Axis::Scale::LOGARITHMIC)
438   - PlotFunction::applyScale(xValues);
  441 + PlotFunction::applyScale(xValues, yValues);
439 442  
440 443 std::string id = "";
441 444 if (pSerie != nullptr)
... ... @@ -451,20 +454,31 @@ namespace plot
451 454 PlotFunction::yValuesMap[id] = yValues;
452 455 }
453 456  
454   - void PlotFunction::applyScale(std::vector<double> &vect)
  457 + void PlotFunction::applyScale(std::vector<double> &vectX, std::vector<double> &vectY)
455 458 {
456   - for (std::size_t i = 0; i < vect.size(); i++)
  459 + std::vector<double> xtemp;
  460 + std::vector<double> ytemp;
  461 + for (std::size_t i = 0; i < vectX.size(); i++)
457 462 {
458   - if (vect[i] <= 0)
  463 + if ((vectX[i] <= 0 && abscisseScale == Axis::Scale::LOGARITHMIC) ||
  464 + (vectY[i] <= 0 && ordonneeScale == Axis::Scale::LOGARITHMIC))
459 465 {
460   - vect[i] = log10(10e-20);
461 466 LOG4CXX_WARN(gLogger, "Negative value found, no log calculated");
462 467 }
463 468 else
464 469 {
465   - vect[i] = log10(vect[i]);
  470 + if (abscisseScale == Axis::Scale::LOGARITHMIC)
  471 + xtemp.push_back(log10(vectX[i]));
  472 + else
  473 + xtemp.push_back(vectX[i]);
  474 + if (ordonneeScale == Axis::Scale::LOGARITHMIC)
  475 + ytemp.push_back(log10(vectY[i]));
  476 + else
  477 + ytemp.push_back(vectY[i]);
466 478 }
467 479 }
  480 + vectX = xtemp;
  481 + vectY = ytemp;
468 482 }
469 483  
470 484 void PlotFunction::drawStartDate(std::string _timeFormat, double startTime, double stopTime)
... ...
src/ParamOutputImpl/Plot/InstantPlot/PlotFunction.hh
... ... @@ -190,7 +190,7 @@ namespace plot
190 190 *
191 191 * @param vect vector of data
192 192 */
193   - void applyScale(std::vector<double> &vect);
  193 + void applyScale(std::vector<double> &vectX, std::vector<double> &vectY);
194 194 /**
195 195 * @brief Get the Min Max de xValuesMap et yValuesMap
196 196 *
... ...
src/Parameters/fonctions/fourier/DiscreteFourierTransform.cc
... ... @@ -116,7 +116,7 @@ std::vector&lt;E&gt; DiscreteFourierTransform&lt;T, E&gt;::computeDSP(std::vector&lt;std::compl
116 116 {
117 117 const int N = x.size();
118 118 std::vector<E> out;
119   - for (int k = 0; k < N / 2; k++)
  119 + for (int k = 1; k < N / 2; k++)
120 120 {
121 121 const E magnitude = (E)pow(abs(x[k]), 2);
122 122 const E dsp = (E)(1.0 / N) * magnitude;
... ... @@ -131,7 +131,7 @@ std::vector&lt;E&gt; DiscreteFourierTransform&lt;T, E&gt;::getFreq(std::vector&lt;std::complex&lt;
131 131 {
132 132 const int N = x.size();
133 133 std::vector<E> out;
134   - for (int k = 0; k < N / 2; k++)
  134 + for (int k = 1; k < N / 2; k++)
135 135 {
136 136 const E freq = (E)k * frequency_ / N;
137 137 out.push_back(freq);
... ... @@ -145,11 +145,9 @@ std::vector&lt;E&gt; DiscreteFourierTransform&lt;T, E&gt;::getPeriods(std::vector&lt;std::compl
145 145 {
146 146 const int N = x.size();
147 147 std::vector<E> out;
148   - for (int k = 0; k < N / 2; k++)
  148 + for (int k = 1; k < N / 2; k++)
149 149 {
150   - E period = (E)INT_MAX;
151   - if (k != 0)
152   - period = N / ((E)k * frequency_);
  150 + const E period = N / ((E)k * frequency_);
153 151 out.push_back(period);
154 152 }
155 153  
... ...