Commit 9d60b18eba164c593c45a185a0ee100117745712
1 parent
b57f2949
Exists in
master
and in
37 other branches
Compute Periods correctly
Showing
2 changed files
with
10 additions
and
8 deletions
Show diff stats
src/ParamOutputImpl/Plot/InstantPlot/PlotFunction.cc
... | ... | @@ -157,6 +157,7 @@ namespace plot |
157 | 157 | xAxis = _panel->getAxis(X_AXIS_ID); |
158 | 158 | } |
159 | 159 | |
160 | + Range lAxisRange = xAxis->Axis::getRange(); | |
160 | 161 | /* |
161 | 162 | * here we should use pow10 in case if min and max are computed as log values |
162 | 163 | */ |
... | ... | @@ -165,20 +166,20 @@ namespace plot |
165 | 166 | minValue = pow10(minValue); |
166 | 167 | maxValue = pow10(maxValue); |
167 | 168 | } |
168 | - Range lAxisRange = xAxis->Axis::getRange(); | |
169 | + | |
169 | 170 | lAxisRange.setMin(minValue); |
170 | 171 | lAxisRange.setMax(maxValue); |
171 | 172 | xAxis->setRange(lAxisRange); |
172 | 173 | xAxis->_used = true; |
173 | 174 | /************************************** Y AXIS RANGE *********************************************/ |
174 | 175 | PlotFunction::getMinMax(yValuesMap, &minValue, &maxValue); |
176 | + boost::shared_ptr<Axis> lYAxis = _panel->getAxis(Y_AXIS_ID); | |
177 | + lAxisRange = lYAxis->Axis::getRange(); | |
175 | 178 | if (ordonneeScale == Axis::Scale::LOGARITHMIC) |
176 | 179 | { |
177 | 180 | minValue = pow10(minValue); |
178 | 181 | maxValue = pow10(maxValue); |
179 | 182 | } |
180 | - boost::shared_ptr<Axis> lYAxis = _panel->getAxis(Y_AXIS_ID); | |
181 | - lAxisRange = lYAxis->Axis::getRange(); | |
182 | 183 | lAxisRange.setMin(minValue); |
183 | 184 | lAxisRange.setMax(maxValue); |
184 | 185 | lYAxis->setRange(lAxisRange); |
... | ... | @@ -303,7 +304,7 @@ namespace plot |
303 | 304 | ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(parameter._originalParamId); |
304 | 305 | |
305 | 306 | std::string unit = AxisLegendManager::getTransformedUnits(paramInfo->getUnits()); |
306 | - unit = "[" + unit + "]#u2#d / Hz"; | |
307 | + unit = "[" + unit + "]#u2"; | |
307 | 308 | if (PlotFunction::isSpectro) |
308 | 309 | { |
309 | 310 | Label label(lYAxis->_legend.getFont(), lYAxis->_legend.getColor()); | ... | ... |
src/Parameters/fonctions/fourier/DiscreteFourierTransform.cc
... | ... | @@ -118,8 +118,8 @@ std::vector<E> DiscreteFourierTransform<T, E>::computeDSP(std::vector<std::compl |
118 | 118 | std::vector<E> out; |
119 | 119 | for (int k = 0; k < N / 2; k++) |
120 | 120 | { |
121 | - const E magnitude = (E)pow(abs(x[k]), 1); | |
122 | - const E dsp = (E)(2.0 / N) * magnitude; | |
121 | + const E magnitude = (E)pow(abs(x[k]), 2); | |
122 | + const E dsp = (E)(1.0 / N) * magnitude; | |
123 | 123 | out.push_back(dsp); |
124 | 124 | } |
125 | 125 | |
... | ... | @@ -144,11 +144,12 @@ template <class T, class E> |
144 | 144 | std::vector<E> DiscreteFourierTransform<T, E>::getPeriods(std::vector<std::complex<E>> x, double frequency_) |
145 | 145 | { |
146 | 146 | const int N = x.size(); |
147 | - const double stepPeriod = N / sampleSpacing_; | |
148 | 147 | std::vector<E> out; |
149 | 148 | for (int k = 0; k < N / 2; k++) |
150 | 149 | { |
151 | - const E period = (E)k * frequency_; | |
150 | + E period = (E)INT_MAX; | |
151 | + if (k != 0) | |
152 | + period = N / ((E)k * frequency_); | |
152 | 153 | out.push_back(period); |
153 | 154 | } |
154 | 155 | ... | ... |